1, preparation,

  1. update

sudo yum update

  1. Install wget

sudo yum install wget

2. Install Nginx

Ali Cloud uses its own mirror source by default. # nginx yum repository # nginx yum repository # nginx yum repository # nginx yumCopy the code

wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

sudo rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

Start installing Nginx

sudo yum install -y nginx

Nginx start

sudo systemctl start nginx

3. Install PHP

  1. RPM install Php7 corresponding yum source

sudo rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

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

  1. The installation

sudo yum install -y php70w

  1. Installing PHP extensions (part)

sudo yum install -y php70w-mysql.x86_64 php70w-gd.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64

  1. Installing PHP FPM

sudo yum install -y php70w-fpm

  1. Start the PHP FPM

sudo systemctl start php-fpm

  1. View the startup status:

systemctl status php-fpm

4, Install MySQL

  1. Download the mysql repo source

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

  1. Install mysql – community – release – el7-5. Noarch. RPM package

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

  1. MYSQL installation

sudo yum install -y mysql-server

  1. MYSQL > alter user privileges;

sudo chown -R root:root /var/lib/mysql

  1. Restart the service:

sudo systemctl restart mysql

  1. Log in and change the password:

mysql -u root

mysql > use mysql;

mysql > update user set password=password(‘password’) where user=’root’;

mysql > flush privileges;

mysql > exit;

  1. The remote link

mysql -u root -p

mysql > use mysql;

mysql > grant all privileges on *.* to root@’%’ identified by ‘password’ with grant option;

mysql >flush privileges

5. Virtual host configuration

Copy the default configuration. Refer to server below

cp nginx.conf /conf.d xxx.cong

server{
        listen 80;
        root /usr/share/nginx/html;
        index index.html index.php index.htm;

        # Make site accessible from http://localhost/
        server_name localhost;

        gzip on;
        gzip_min_length 1k;
        gzip_buffers 4 16k;
        # gzip_http_version 1.0;
        gzip_comp_level 5;
        gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
        gzip_vary off;
        gzip_disable "MSIE [1-6]\.";


        charset UTF-8;

        location ~* .(jpg|jpeg|png|gif|css|js|swf|mp3|avi|flv|xml|zip|rar)$ {
                gzip on;
        }

        location / {
                try_files $uri $uri/ /index.php?$query_string; } location ~.php {fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name; fastcgi_split_path_info ^((? U).+.php)(/? . +) $; fastcgi_param PATH_INFO$fastcgi_path_info;
                fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; }}Copy the code

Restart Ngix and PHP-Fpm. Configuration complete.