安装Nginx
    sudo apt install nginx
安装MySQL
    sudo apt install mysql-server-5.7
添加php源
    sudo add-apt-repository ppa:ondrej/php
    sudo apt update
也可以使用ppa国内源
    deb https://launchpad.proxy.ustclug.org/ondrej/php/ubuntu focal main
安装PHP
    sudo apt install php7.4
    sudo apt install php7.4-fpm
安装PHP扩展
    sudo apt install php7.4-xml php7.4-json php7.4-mysql php7.4-curl php7.4-gd php7.4-pdo php7.4-mbstring php7.4-mysqlnd php7.4-bcmath php7.4-zip php7.4-fileinfo php7.4-redis
设置MySQL用户名密码
    #查看初始用户名和密码
    cd /etc/mysql
    sudo cat debian.cnf
    #使用初始用户名密码登录mysql
    mysql -udebian-sys-maint -pGIOyPu42YoZEwRTe
    #设置密码
    use mysql;
    update mysql.user set authentication_string='yourpassword' where user='root' and Host ='localhost';
    update user set plugin="mysql_native_password" where user='root';
    #设置允许远程登录
    update user set host="%" where user='root';
    flush privileges;
    quit;
配置Nginx多域名访问
进入/etc/nginx/conf.d目录
    cd /etc/nginx/conf.d
新建站点配置
    sudo vi mysite.com.conf
    server {
        listen 80;
        listen 443 ssl http2;
        server_name .tp5.test;
        root /www/mysite.com/public;
    
        index index.html index.htm index.php;
    
        charset utf-8;
        client_max_body_size 1000M;
    
        location / {
            if (!-e $request_filename) {
                rewrite  ^(.*)$  /index.php?s=/$1  last;
                break;
            }
            
        }
    
        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt  { access_log off; log_not_found off; }
    
        access_log off;
        error_log  /var/log/nginx/tp5.test-error.log error;
    
        sendfile off;
    
        location ~ \.php(.*)$ {
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
            fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    
            fastcgi_intercept_errors off;
            fastcgi_buffer_size 16k;
            fastcgi_buffers 4 16k;
            fastcgi_connect_timeout 300;
            fastcgi_send_timeout 300;
            fastcgi_read_timeout 300;
        }
    
        location ~ /\.ht {
            deny all;
        }
    
        ssl_certificate     /etc/ssl/certs/mysite.com.crt;
        ssl_certificate_key /etc/ssl/certs/mysite.com.key;
    }
检查配置文件并重启Nginx
    sudo nginx -t
    sudo nginx -s reload
 
    
     
				