Ubuntu
下安装nginx,查看版本号判断是否安装成功。
apt update
apt install nginx
nginx -v
显示nginx version: nginx/1.14.0 (Ubuntu)。
默认的配置文件路径为/etc/nginx/nginx.conf,查看配置文件,发现里面并无实际的配置,而是include了/etc/nginx/conf.d/*.conf以及/etc/nginx/sites-enabled/*两个目录下的配置文件。
cp /etc/nginx/sites-enabled/default /etc/nginx/sites-enabled/test
vi test
server {
listen 80 ;
server_name localhost;
location / {
root /home/test;
index index.php index.htm index.html;
}
location ~ \.php$ {
root /home/test;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi.conf;
}
}
重启Nginx服务
service nginx restart