安装:
1 |
sudo apt install nginx php7.0 php7.0-fpm php7.0-cgi php7.0-cli php-mysql php7.0-curl php7.0-gd php7.0-mcrypt |
配置:
1 |
sudo vi /etc/nginx/sites-available/default |
找到:
1 2 3 4 5 |
location / { # First attempt to server request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; } |
改为:
1 2 3 4 5 6 7 8 9 10 |
location / { index index.html index.htm index.php default.html default.html default.htm default.php; } location ~\.php$ { fastcgi_pass unix:/run/php/php7.0-fpm.sock; #fastcgi_pass 127.0.0.1:9000; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } |
上面就完成了,下面重启并测试一下:
1 |
sudo service nginx restart |
把下面的内容写入/var/www/html/phpinfo.php
1 2 3 |
<?php phpinfo(); ?> |
从浏览器打开ip/phpinfo.php, 能显示内容就表示成功了!