說實話…
用Apache安裝phpBB真的沒難度,一次就成功! 一旦使用 Nginx 安裝 phpBB 時…,立馬給我無限的 404… 以下是個人的nginx.conf設定檔,卡在rewrite問題,請問有人會寫嗎??
代碼: 選擇全部
location / {
try_files $uri $uri/ @rewriteapp;
location ~* \.(php[345]?|phtml)$ {
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm/php-6a7bc129-0c96-47a9-9c9c-13a7e442dd42.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
try_files $uri $uri/ /app.php$is_args$args;
fastcgi_intercept_errors on;
}
location ~ /(config|common\.php|cache|files|images/avatars/upload|includes|(?<!ext/)phpbb(?!\w+)|store|vendor) {
deny all;
internal;
}
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
location /install/ {
try_files $uri $uri/ @rewrite_installapp =404;
location ~* \.(php[345]?|phtml)$ {
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm/php-6a7bc129-0c96-47a9-9c9c-13a7e442dd42.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $document_root;
try_files $uri $uri/ /install/app.php$is_args$args =404;
fastcgi_intercept_errors on;
}
}
location @rewrite_installapp {
rewrite ^(.*)$ /install/app.php/$1 last;
}
location ~ /\.svn|/\.git {
deny all;
internal;
}
gzip on;
gzip_comp_level 6;
gzip_min_length 1000;
gzip_proxied any;
gzip_disable "msie6";
# Gzip compression types
gzip_types
application/atom+xml
application/geo+json
application/javascript
application/x-javascript
application/json
application/ld+json
application/manifest+json
application/rdf+xml
application/rss+xml
application/xhtml+xml
application/xml
font/eot
font/otf
font/ttf
image/svg+xml
text/css
text/javascript
text/plain
text/xml;
# Static assets, media
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
expires 90d;
access_log off;
}
# SVG, fonts
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
add_header Access-Control-Allow-Origin "*";
expires 90d;
access_log off;
}
代碼: 選擇全部
location / {
try_files $uri $uri/ @rewriteapp;
location ~* \.(php[345]?|phtml)$ {
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm/php-6a7bc129-0c96-47a9-9c9c-13a7e442dd42.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
#fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
try_files $uri $uri/ /app.php$is_args$args;
fastcgi_intercept_errors on;
}
location ~ /(config|common\.php|cache|files|images/avatars/upload|includes|(?<!ext/)phpbb(?!\w+)|store|vendor) {
deny all;
internal;
}
}
location @rewriteapp {
rewrite ^(.*)$ /app.php/$1 last;
}
location /install/ {
try_files $uri $uri/ @rewrite_installapp =404;
location ~* \.(php[345]?|phtml)$ {
include fastcgi_params;
fastcgi_pass unix:/run/php-fpm/php-6a7bc129-0c96-47a9-9c9c-13a7e442dd42.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
# fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param DOCUMENT_ROOT $realpath_root;
try_files $uri $uri/ /install/app.php$is_args$args =404;
fastcgi_intercept_errors on;
}
}
location @rewrite_installapp {
rewrite ^(.*)$ /install/app.php/$1 last;
}
location ~ /\.svn|/\.git {
deny all;
internal;
}
gzip on;
gzip_comp_level 6;
gzip_min_length 1000;
gzip_proxied any;
gzip_disable "msie6";
# Gzip compression types
gzip_types
application/atom+xml
application/geo+json
application/javascript
application/x-javascript
application/json
application/ld+json
application/manifest+json
application/rdf+xml
application/rss+xml
application/xhtml+xml
application/xml
font/eot
font/otf
font/ttf
image/svg+xml
text/css
text/javascript
text/plain
text/xml;
# Static assets, media
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
expires 90d;
access_log off;
}
# SVG, fonts
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
add_header Access-Control-Allow-Origin "*";
expires 90d;
access_log off;
}