0 关闭防火墙
0.1 关闭防火墙
systemctl stop firewalld.service
0.2 取消开机启动防火墙
systemctl disable firewalld.service
0.3 关闭selinux
vim /etc/selinux/config #SELINUX=enforcing #注释掉 #SELINUXTYPE=targeted #注释掉 SELINUX=disabled #增加 :wq! #保存退出 setenforce 0 #使配置立即生效
1 配置第三方源
1.1 备份系统默认源
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
1.2 下载网易yum源配置文件
cd /etc/yum.repos.d wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
1.3 生成缓存
yum clean all yum makecache
1.4 安装epel源
yum install epel-release
1.5 安装remi源
rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
2 安装mariaDB
2.1 安装mariaDB
yum -y install mariadb*
2.2 启动mariaDB
systemctl start mariadb.service
2.3 开机启动mariaDB
systemctl enable mariadb.service
2.4 为root用户添加密码
mysql_secure_installation
回车,根据提示输入Y
输入2次密码,回车
根据提示一路输入Y
最后出现:Thanks for using MySQL!
配置数据库权限:
grant all privileges on *.* to 'root'@'%' identified by 'password' with grant option;
MySql密码设置完成,重新启动 MySQL:
systemctl restart mariadb.service #重启MariaDB
3 安装apache
3.1 安装apache
yum install -y httpd
3.2 启动apache
systemctl start httpd.service
3.3 开机启动apache
systemctl enable httpd.service
3.4 修改apache配置
vim /etc/httpd/conf/httpd.conf Options Indexes FollowSymLinks #修改为:Options Includes ExecCGI FollowSymLinks(允许服务器执行CGI及SSI,禁止列出目录) #AddHandler cgi-script .cgi #修改为:AddHandler cgi-script .cgi .pl (允许扩展名为.pl的CGI脚本运行) AllowOverride None #修改为:AllowOverride All (允许.htaccess) DirectoryIndex index.html #修改为:DirectoryIndex index.html index.htm Default.html Default.htm index.php(设置默认首页文件,增加index.php) :wq! #保存退出 systemctl restart httpd.service #重启apache
4 安装php
4.1 安装php5.6
yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common
4.2 启动php-fpm
systemctl start php-fpm systemctl enable php-fpm
以下安装过程可选
5 安装nginx
5.1 安装nginx
yum install -y nginx
5.2 启动nginx
systemctl start nginx systemctl enable nginx
5.3 配置nginx
vim /etc/nginx/nginx.conf
server中添加
index index.php index.html index.htm; location ~ \.php$ { root /usr/share/nginx/html; include fastcgi_params; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; include fastcgi_params; }
5.4 修改权限
chmod 777 /usr/share/nginx/html -R
6 安装redis
6.1 安装redis
yum -y install redis
6.2 配置redis
vim /etc/redis.conf
注释 bind 127.0.0.1