1, run command

sudo apt-get update
sudo apt-get upgradeCopy the code

2. Install add-apt-repository

sudo apt-get install software-properties-common sudo add-apt-repository ppa:ondrej/php && sudo apt-get update sudo Apt - get - y install php7.2 - FPMCopy the code

3. Install common extensions

Sudo apt-get install php7.2-mysql php7.2-curl php7.2-json php7.2-mbstring php7.2- XMLCopy the code

4. Install nginx

sudo apt-get install nginx
Copy the code

5, install mysql

# Change administrator permissions
sudo su
Install mysql server and client
apt-get install mysql-server mysql-clientCopy the code

Edit the nginx configuration file

cd /etc/nginx/sites-available
cp default php
vim php
cd sites-enabled
rm default
ln -s /etc/nginx/sites-available/php /etc/nginx/sites-enabled/php

server {
Note that only one default_server can exist per server. For other project configuration files, simply delete default_server.
listen 80;
#listen [::]:80 default_server;
# Your own project path
root /var/www/cms;
# Add index.php to the list if you are using PHP
index index.html index.htm index.php index.nginx-debian.html;
Localhost = 'localhost';
server_name _;
# redirect
# return 301 https://domain name /$request_uri;
Configure URL rewriting according to framework requirements
location / {
    try_files $uri $uri/ /index.php?$query_string;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000location ~ \.php$ { include snippets/fastcgi-php.conf; Fastcgi_pass Unix: / run/PHP/php7.2 - FPM. The sock. }# orlocation ~ \.php$ { fastcgi_split_path_info ^(.+\.php)(/.+)$; Fastcgi_pass Unix: / run/PHP/php7.2 - FPM. The sock. fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME$document_root$fastcgi_script_name; include fastcgi_params; }}Copy the code

7. Thinkphp configuration

Modify the configuration file location / {if (!-e $request_filename) { rewrite ^(.*)$ /index.php? s=The $1  last;
    break; }}Copy the code

8. Laravel configuration

location / {
    try_files $uri $uri/ /index.php?$query_string;
}Copy the code

Restart Nginx and PHP7.2-fpm

service nginx restart
nginx -tCopy the code

10, modify permission, upload project (Laravel only need to give the highest permission to public and storage)

cd/var/www chmod -r 777 CMS replication command: ln-s /etc/nginx/sites-available/php /etc/nginx/sites-enabled/phpCopy the code