ubuntu + nginx
http://localhost/正常
http://loacalhost/abc/不正常
按网上的教程,不是404,就是没法执行php(呈现php源码状态)
配置文件如下,该配置出现的是404:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.php index.htm index.nginx-debian.html;
server_name _;
location / {
try_files $uri $uri/ =404;
}
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;
}
location /abc {
alias /home/abc/web/;
index index.php;
}
location ~ ^/abc/(.*\.php)$ {
alias /home/abc/web/$1;
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;
}
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.php;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
需要调整一下
Nginx
配置,如下你参考一下,路径要自己对应好