2017-09-14 163 views
0

我需要一個適用於Laravel和Phpbb的nginx配置。phpbb和laravel的nginx配置

我已經使用laravel銳意設置我的數字海洋的服務器,它創造了這個nginx的配置:

# FORGE CONFIG (DOT NOT REMOVE!) 
include forge-conf/djembefola.org/before/*; 

server { 
    listen 80; 
    listen [::]:80; 
    server_name djembefola.org; 
    root /home/forge/djembefola.org/public; 

    # FORGE SSL (DO NOT REMOVE!) 
    # ssl_certificate; 
    # ssl_certificate_key; 

    ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 
    ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:$ 
    ssl_prefer_server_ciphers on; 
    ssl_dhparam /etc/nginx/dhparams.pem; 

    add_header X-Frame-Options "SAMEORIGIN"; 
    add_header X-XSS-Protection "1; mode=block"; 
    add_header X-Content-Type-Options "nosniff"; 

    index index.html index.htm index.php; 

    charset utf-8; 

    # FORGE CONFIG (DOT NOT REMOVE!) 
    include forge-conf/djembefola.org/server/*; 

    location/{ 
     try_files $uri $uri/ /index.php?$query_string; 
    } 

    location = /favicon.ico { access_log off; log_not_found off; } 
    location = /robots.txt { access_log off; log_not_found off; } 

    access_log off; 
    error_log /var/log/nginx/djembefola.org-error.log error; 

    error_page 404 /index.php; 

    location ~ \.php$ { 
     fastcgi_split_path_info ^(.+\.php)(/.+)$; 
     fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; 
     fastcgi_index index.php; 
     include fastcgi_params; 
    } 

    location ~ /\.(?!well-known).* { 
     deny all; 
    } 
} 

# FORGE CONFIG (DOT NOT REMOVE!) 
include forge-conf/djembefola.org/after/*; 

的/公共文件夾是前端控制器的index.php Laravel的生活......

此外,在公用文件夾,我有和 PHPBB的安裝 - /公/板

我升級論壇,因此我需要朗姆酒phpBB的安裝程序,它駐留在:

本地主機/板/安裝,

然後調用:

本地主機/板/安裝/ app.php /更新

然後上述網址是給一個404錯誤。

我在其他地方看過,這是因爲Nginx需要正確配置才能運行安裝程序。

樣本Nginx配置for phpbb is listed here

所以我需要合併這些不知何故,但到目前爲止我的嘗試失敗了。

我嘗試添加:

location /board/ { 
    rewrite ^(.*)$ /app.php/$1 last; 
} 

現有laravel nginx的文件,但失敗了。我知道我需要把它放在nginx配置的正確位置,但我擔心我可能忽略了其他東西,因爲我在這裏猜測了一下...

任何人都可以幫忙嗎?

回答

0

基於示例配置,您可以在塊包裝中嵌套所需的規則(就像他們對/ install /目錄所做的一樣)。例如:

location /board/ { 
    try_files $uri $uri/ @rewriteapp;  

    # Deny access to internal phpbb files. 
    location ~ /(config\.php|common\.php|cache|files|images/avatars/upload|includes|(?<!ext/)phpbb|store|vendor) { 
     deny all; 
     # deny was ignored before 0.8.40 for connections over IPv6. 
     # Use internal directive to prohibit access on older versions. 
     internal; 
    } 

    # Pass the php scripts to fastcgi server specified in upstream declaration. 
    location ~ \.php(/|$) { 
     # Unmodified fastcgi_params from nginx distribution. 
     include fastcgi_params; 
     # Necessary for php. 
     fastcgi_split_path_info ^(.+\.php)(/.*)$; 
     fastcgi_param PATH_INFO $fastcgi_path_info; 
     fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; 
     fastcgi_param DOCUMENT_ROOT $realpath_root; 
     try_files $uri $uri/ /board/app.php$is_args$args; 
     fastcgi_pass php; 
    } 
} 

location @rewriteapp { 
    rewrite ^(.*)$ /app.php/$1 last; 
} 

請注意@rewriteapp不在塊換行。如果您嘗試將其放置在內部,Nginx會投訴。

只需修改路徑以匹配您的目錄。