安装nginx
apt install curl gnupg2 ca-certificates lsb-release
echo "deb http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list
curl -o /tmp/nginx_signing.key https://nginx.org/keys/nginx_signing.key
gpg --dry-run --quiet --import --import-options show-only /tmp/nginx_signing.key
sudo mv /tmp/nginx_signing.key /etc/apt/trusted.gpg.d/nginx_signing.asc
apt update
apt install nginx
安装php7.2
sudo apt-get install php7.2 php7.2-fpm php7.2-mysql
配置nginx
vim /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
location / {
root /html/blog;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /html/blog;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param HTTPS on;
include fastcgi_params;
}
}
配置php
grep "^listen" /etc/php/7.2/fpm/pool.d/www.conf
listen = 127.0.0.1:9000
listen.owner = www-data
listen.group = www-data
测试
mkdir -p /html/blog
cat /html/blog/index.php
<?php
phpinfo();
?>
访问
http://192.168.8.11/