2019独角兽企业重金招聘Python工程师标准>>>
1.首先输入用户名和密码进行登录
2.升级更新软件包
sudo apt-get update
sudo apt-get upgrade
判断都填y
3.安装nginx
sudo apt-get install nginx
在浏览器输入你的ip地址测试是否安装成功
4.安装数据库
sudo apt-get install mysql-server php7.2-mysql
输入mysql -u root -p 测试数据库安装是否成功
quit 可以退出
5.安装php-fpm
sudo apt-get install php7.2-fpm
6.配置php-fpm
sudo vi /etc/php/7.2/fpm/php.ini
将;cgi.fix_pathinfo=1改成cgi.fix_pathinfo=0(还要去掉分号) 位置在全屏状态下的40%的第一行,看右下角
修改保存内容的方法自己查看vi 的操作
7.重启php-fpm
sudo service php7.2-fpm restart
8.解决nginx打开php文件总是显示下载php文件的问题
sudo vi /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
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm 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;
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
#include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.0-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;
#}
}
修改去掉注释保存
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
}
注意:fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;修改为fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
因为我安装的是php7.2 查看路径/run/php/php7.2-fpm.sock 如下目录所指:
9.重启nginx
sudo service nginx restart
10.测试nginx是否解析php
cd /var/www/html
sudo vi phpinfo.php
在phpinfo.php中输入
11.修改权限
1)首先进入服务器根目录 cd /var/www/html
2)再使用chmod sudo chmod 777 html/