1、搭建环境
本文笔者使用的服务器是腾讯云服务器。
Linux:Linux 系统(本文为 Ubuntu18.04);
Nginx:Web 服务器程序,用来解析 Web 程序;
MySQL:一个数据库管理系统;
PHP:Web 服务器生成网页的程序。
(1)安装配置Nginx
sudo apt-get install nginx
启动 Nginx
service nginx start
测试 Nginx 服务是否正常运行,在浏览器中,访问云主机公网 IP,查看 Nginx 服务是否正常运行。如果出现Welcome to Nginx 欢迎页面,说明安装配置成功。
(2)安装MySQL
sudo apt-get install mysql-server
修改密码
use mysql; update mysql.user set authentication_string=password('root') where user='root' and Host ='localhost'; update user set plugin="mysql_native_password"; flush privileges; quit;
重新启动mysql
sudo service mysql restart mysql -u root -p // 启动后输入已经修改好的密码:root
(3)安装PHP
sudo apt-get install php-fpm php-mysql
打开php的配置文件
sudo vim /etc/php/7.0/fpm/php.ini
命令行模式下,输入“/”,在输入“cgi.fix_pathinfo=1"进行关键字查找,将
cgi.fix_pathinfo=1
修改为
cgi.fix_pathinfo=0
重启PHP
sudo systemctl restart php7.2-fpm
2、配置nginx
sudo vim /etc/nginx/sites-available/default
将以下内容
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 #