Nginx

在nginx上部署concrete5

  • April 21, 2017

我有一個可在 apache 伺服器中“開箱即用”的具體站點。但是我在 nginx 中執行它時遇到了很多麻煩。

以下是我正在使用的 nginx 配置:

server {
   root /home/test/public;
   index index.php;

   access_log /home/test/logs/access.log;
   error_log /home/test/logs/error.log;

   location / {
           # First attempt to serve request as file, then
           # as directory, then fall back to index.html
           try_files $uri $uri/ index.php;
           # Uncomment to enable naxsi on this location
           # include /etc/nginx/naxsi.rules
   }
   # pass the PHP scripts to FastCGI server listening on unix socket
   #
   location ~ \.php($|/) {
           fastcgi_pass unix:/tmp/phpfpm.sock;
           fastcgi_split_path_info ^(.+\.php)(/.+)$;
           fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
           fastcgi_param PATH_INFO $fastcgi_path_info;
           include fastcgi_params;
   }
   location ~ /\.ht {
           deny  all;
   }
}

我能夠獲得首頁,但內頁有問題。內頁顯示“拒絕訪問”。可能重寫不起作用,實際上我認為它查詢並嘗試直接執行 php 文件,而不是通過具體的調度程序。

我完全迷失在這裡。

提前謝謝你的幫助。

將配置更改為:

server {
   root /home/test/public;
   index index.php;

   access_log /home/test/logs/access.log;
   error_log /home/test/logs/error.log;

   location / {
           # First attempt to serve request as file, then
           # as directory, then fall back to index.html
           try_files $uri $uri/ /index.php/$request_uri;
           # Uncomment to enable naxsi on this location
           # include /etc/nginx/naxsi.rules
   }

   # pass the PHP scripts to FastCGI server listening on unix socket
   #
   location ~ \.php($|/) {
           set $script $uri;
           if ($uri ~ "^(.+\.php)(/.+)") {
                   set $script $1;
           }
           include fastcgi_params;
           fastcgi_param SCRIPT_FILENAME $document_root$script;
           fastcgi_intercept_errors on;
           fastcgi_pass unix:/tmp/phpfpm.sock;
   }

   location ~ /\.ht {
           deny  all;
   }
}

這要歸功於宿醉和他提供的連結。

我仍然不清楚我做錯了什麼,也許 nginx 專家可以幫助我理解。

引用自:https://serverfault.com/questions/402726