我有一個 yii2 高級模板應用程式在 centos 9 上運行,帶有 nginx 和 php 8.1。設定虛擬主機配置如下:
server { lis ten 80; server_name mydomain.com; root /home/lamtab/xp-app-main/app/appadmin/web; index index.php index.html index.htm index.nginx-debian.html; access_log "/var/log/nginx/mydomain.com.access.log"; error_log "/var/log/nginx/mydomain.com.error.log"; location / { try_files $uri /index.php$is_args$args; } location ~* .php$ { # With php-fpm unix sockets fastcgi_pass unix:/run/php-fpm/www.sock; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; } fastcgi_buffers 8 16k; fastcgi_buffer_size 32k; fastcgi_connect_timeout 90; fastcgi_send_timeout 90; fastcgi_read_timeout 90; }
網域的錯誤日誌報告
FastCGI 在 stderr 中發送:“主腳本未知”,同時從上游讀取回應標頭...”
以及nginx的錯誤日誌報告
index.php」失敗(13:權限被拒絕)
有什麼線索嗎?
P粉6620895212023-12-16 13:11:32
就我而言,我白白浪費了幾個小時,結果我只需要在 ubuntu 22.04 中重新啟動 php8.1-fpm 服務。嘗試一下也許會有幫助。我的conf檔案看起來像這樣
server { listen 80 default_server; root /home/user/your_project/public/; index index.php index.html index.htm; access_log /home/user/your_project/nginx-access.log; error_log /home/user/your_project/nginx-error.log; server_name localhost; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.php$ { try_files $uri index.php =404; fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } }