我正在尝试在 Nginx 中配置 Wordpress 和 Laravel,但很难正确配置。
Wordpress 安装在 /var/www/site/blog Laravel 安装在 /var/www/site/exam
浏览 site.local 会调出 wordpress 网站,但 site.local/laravel 显示“未指定输入文件”。查看错误日志:无法打开主脚本:/var/www/site/exam/public//exam/index.php,它是别名加上位置,其中脚本位置是 /var/www/site/exam/public/index.php
任何反馈都将不胜感激。请参阅下面的配置文件:
server {
listen 80;
server_name site.local;
root /var/www/site/blog;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
index index.php index.html;
error_page 404 /index.php;
access_log off;
error_log /var/log/nginx/site.local-error.log error;
sendfile off;
charset utf-8;
#laravel
location /exam/ {
alias /var/www/site/exam/public/;
try_files $uri $uri/ /index.php?$args;
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
#blog
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
location ~ \.php$ {
fastcgi_pass unix:/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
答案1
我认为你需要像这样改变位置
location /laravel {
...
...
}