我在ubuntu服务器上的节点应用程序的标准端口80上使用了nginx。 / etc / nginx / sites-available /默认为:
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://localhost:3333;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
我已经安装了php7。我想使用Nginx在8585端口上提供php文件。因此,example.com:8585/info.php指向文件系统上的/var/www/html/info.php。
如何解决这个问题?
答案 0 :(得分:3)
您可以编写一个附加服务器块
server {
listen 8585;
listen somename:8585;
server_name somename alias another.alias;
root html;
index index.html index.htm;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}