说明:nginx、 mysql5.7、php7.0
1.安装之前先更新系统
sudo apt-get update
2.安装nginx
sudo apt-get install nginx
3.安装php7.0和php7.0-fpm
1.sudo apt-get install php7.0
2.sudo apt-get install php7.0-fpm
4.配置nginx使其解析php
1.打开nginx的网站配置文件
vim /etc/nginx/sites-available/default
修改成以下配置:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html; #网站目录
index index.php index.html index.htm index.nginx-debian.html;
server_name server_domain_or_IP; #绑定网站域名
location / {
try_files $uri $uri/ /index.php?$query_string; #配置转发规则
}
# 解析php
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock; #利用php-fpm套接字解析php
}
location ~ /\.ht {
deny all;
}
}
修改php7.0-fpm配置
打开其配置文件
vim /etc/php/7.0/fpm/php.ini
找到cgi.fix_pathinfo=1,将其改为cgi.fix_pathinfo=0
a. 重启nginx service nginx restart
b.重启php7.0-fpm服务 service php7.0-fpm restart
5.安装mysql5.7
1.sudo apt-get install mysql-server php7.0-mysql
2.sudo apt-get install mysql-client
网友评论