server { listen 80 default_server; listen [::]:80 default_server;
# SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Read up on ssl_ciphers to ensure a secure configuration. # See: https://bugs.debian.org/765782 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf;
root /home/devil/www;
# Add index.php to the list if you are using PHP index index.html index.htm index.php index.nginx-debian.html;
server_name _;
location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri$uri/ =404; index index.php index.html index.htm; }
# pass PHP scripts to FastCGI server # location ~ \.php$ { root /home/devil/www; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; fastcgi_split_path_info ^(.+\.php)(/.+)$; # # With php-fpm (or other unix sockets): fastcgi_pass unix:/var/run/php/php7.4-fpm.sock; # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; }
# deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /\.ht { deny all; } }
按下Esc键后,输入:wq并回车以保存并关闭配置文件。
运行以下命令测试nginx配置文件中是否存在语法错误
1
sudo nginx -t
3.运行以下命令重新启动Nginx服务。
1
sudo systemctl restart nginx
4.运行以下命令设置Nginx服务开机自启动。
1
sudo systemctl enable nginx
步骤五:配置MySQL
1.运行以下命令进入MySQL命令提示符界面。
1
sudo mysql
2.运行以下命令重新设置root用户密码。
1
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '123';