我有一堆网站使用nginx + php-fastcgi很好用,我没有抱怨!唯一不起作用的是名为Gallery3的PHP库应用程序。遗憾的是,我必须在这个应用程序中使用Apache。我遇到的问题如下:
gallery.wfto.cc - 不起作用(下载一个包含index.php的PHP代码的未命名文件,因为它没有被解析)
gallery.wfto.cc/ - 不起作用(同样的事情)
gallery.wfto.cc/index.php - 不起作用(同样的事情)
gallery.wfto.cc/index.php/ - 作品。
gallery.wfto.cc:9001(所有变种) - 作品。
我不知道发生了什么事。我在下面列出了大部分配置。 /etc/nginx/conf.d/proxy.conf是一个通用的代理配置,没什么特别的。
##NGINX CONFIG##
server {
listen 80; ## listen for ipv4
listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www/vhosts/wfto.cc/subdomains/gallery;
server_name gallery.wfto.cc;
access_log /var/log/nginx/gallery.wfto.cc.access.log;
location / {
proxy_pass http://127.0.0.1:9001;
include /etc/nginx/conf.d/proxy.conf;
}
}
## APACHE CONFIG ##
<VirtualHost *:9001>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/vhosts/wfto.cc/subdomains/gallery
<IfModule mod_fastcgi.c>
AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -host 127.0.0.1:9000 -pass-header Authorization
</IfModule>
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/vhosts/wfto.cc/subdomains/gallery/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
答案 0 :(得分:0)
在apache conf中添加:
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
答案 1 :(得分:0)
我不知道在什么时候开始工作,但如果您要更改服务器配置,请确保完全清除浏览器的缓存。
答案 2 :(得分:0)
我知道这是一个古老的话题,但由于 Gallery3 has gone through a revival,对于那些在谷歌上搜索解决方案并在此处找到您的问题的人来说,可能值得添加另一个更新的答案。
>@jonmiller 的以下解决方案有效:http://jonamiller.com/2015/02/15/gallery3-on-nginx/
因为互联网变化无常,网站来来往往(他的博客只有 2015 年的两篇文章,显然他没有更新……),考虑到所有功劳都归功于 Jon Miller,这里是工作配置:
server {
server_name <gallery_url>;
listen 80;
root <path_to_gallery_installion>;
access_log <path_to_log_locations>;
error_log <path_to_log_locations>;
index index.php;
location / {
location ~ /(index\.php/)?(.+)$ {
try_files $uri /index.php?kohana_uri=$2&$args;
location ~ /var/thumbs/.*/.album.jpg {
# Direct access to album thumbs explicity allowed
}
location ~ /\.(ht|tpl(\.php?)|sql|inc\.php|db)$ {
deny all;
}
location ~ /var/(uploads|tmp|logs) {
deny all;
}
location ~ /bin {
deny all;
}
location ~ /var/(albums|thumbs|resizes) {
rewrite ^/var/(albums|thumbs|resizes)/(.*)$ /file_proxy/$2 last;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|ttf)$ {
try_files $uri /index.php?kohana_uri=$uri&$args;
expires 30d;
}
}
location = /index.php {
include fastcgi_params;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_pass localhost:9000; // adjust as necessary
}
}
}
根据 Jon Miller 的说法,使上述所有工作正常进行的真正技巧是更改 application/config/config.php
上的一行:
$config["index_page"] = "";
免责声明:我已将上述解决方案(应归功于 Jon Miller)作为功能请求发布在 official repository for Gallery the Revival on GitHub 上以包含在文档中(README.md,一个单独的文件,无论如何),因为对于 Gallery3 管理员来说至关重要的是要知道他们现在可以在 nginx
和(至少)PHP 7.4 下使用它。