关闭防火墙

systemctl stop firewalld
systemctl disable firewalld

关闭selinux

vim /etc/selinux/config
将状态设置为 disabled
reboot 重启


yum 更新源 清除缓存并更新

yum clean all
yum makecache
yum -y update

安装nginx

安装源

yum install epel-release
yum update 更新
yum -y install nginx

查看nginx 版本

nginx -v


安装MySQL

yum -y install php-mysql

wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm

rpm -ivh mysql-community-release-el7-5.noarch.rpm

yum install mysql-community-server

查看MySQL 版本

mysql -V

启动MySQL

systemctl start mysqld

查看MySQL 状态

systemctl status mysqld

设置开机启动MySQL

systemctl enable mysql
systemctl daemon-reload

配置MySQL

mysql_secure_installation


安装php

添加epel 源

yum install \
https://repo.ius.io/ius-release-el7.rpm \
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

添加Webtatic源

rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装PHP

yum -y install php70w-devel php70w.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-pdo.x86_64 php70w-mysqlnd php70w-fpm php70w-opcache php70w-pecl-redis php70w-pecl-mongodb

失败后 ,安装 _yum -y install php —skip-broken ; 再不行,制定报错包 : _yum -y install php72w-


配置nginx

备份nginx 文件

cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak

修改配置文件

vim /etc/nginx/nginx.conf

添加以下文件 到 include 和 error 中间

  1. #将location / 大括号内的信息修改为以下所示,配置网站被访问时的默认首页。
  2. location / {
  3. index index.php index.html index.htm;
  4. }
  5. #添加下列信息,配置Nginx通过fastcgi方式处理您的PHP请求。
  6. location ~ .php$ {
  7. root /usr/share/nginx/html; #将/usr/share/nginx/html替换为您的网站根目录,本教程使用/usr/share/nginx/html作为网站根目录。
  8. fastcgi_pass 127.0.0.1:9000; #Nginx通过本机的9000端口将PHP请求转发给PHP-FPM进行处理。
  9. fastcgi_index index.php;
  10. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  11. include fastcgi_params; #Nginx调用fastcgi接口处理PHP请求。
  12. }

启动 nginx 服务

systemctl start nginx

查看nginx 状态

systemctl status nginx

设置nginx 自启动

systemctl enable nginx


启动 php-fpm

systemctl start php-fpm

设置php-fpm 自启动

systemctl enable php-fpm

重启服务

systemctl restart nginx
systemctl restart php-fpm
systemctl restart mysqld