LINUX-centos7服务器环境安装的那些坑
LINUX-centos7服务器环境安装的那些坑
亲自测试能用的
第一步 安装php
一定要加上--skip-broken,否则根本无法安装,依赖的程序实在是太多了,我走过这个弯路;
yum -y install php* --skip-broken
第二步 安装apache
yum install httpd
设置HTTPD自动启动
systemctl enable httpd.service
yum安装的httpd,在/etc/httpd/conf.d/目录下添加vhosts.conf后重启即可,vhosts.conf文件格式如下
<VirtualHost *:80>
ServerName www.test.com
DocumentRoot "/website/siteone"
DirectoryIndex index.html index.php
<Directory "/website/siteone">
Options -Indexes +FollowSymlinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
启动 service httpd start
注意了下面的是关键
关闭关闭SELINUX
因为他不干人事,导致你们到处配置出问题,会导致APACHE站点目录出现无权限访问的提示
vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
#SELINUX=enforcing
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
:wq! #保存退出
setenforce 0 #使配置立即生效
第三步 安装MYSQL
千万不能简单的运行 yum install mysql,安装的根本不是mysql,而是变种的MariaDB
应该是rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
查看当前可用的mysql安装资源
yum repolist enabled | grep "mysql.*-community.*"
安装
yum -y install mysql-community-server
设置将其开机启动
systemctl enable mysqld
启动
systemctl start mysqld
设置密码
mysql_secure_installation
进去MYSQL
mysql -uroot -p
mysql>use mysql;
mysql>GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '962360' WITH GRANT OPTION;
最后关闭防火墙
iptables -F
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)
进行测试