Nginx+;Magento配置问题。正在下载PHP文件
我一直在努力让Magento在Nginx上运行。 我不是这方面的专家,但几周来我一直在用Vhost配置进行故障排除 现在我已经到了一个地步,我简直不知道要改变什么了。 问题是,每当我在输入索引并导航到Magento时,它都会尝试下载PHP文件。 这个项目必须完成,我在一家公司实习,我真的很想学习如何实现Nginx,这里没有人能帮我,所以我真的希望这里的人能帮我! 我在nginx中构建了两个独立的vhost文件,一个用于索引,另一个用于备份文件夹,我将备份写入其中以便下载它们。 另一个是纯粹为Magento设计的 我将在这里发布它们,包括我的nginx.conf文件 这是我的nginx.conf文件:Nginx+;Magento配置问题。正在下载PHP文件,php,magento,nginx,configuration,vhosts,Php,Magento,Nginx,Configuration,Vhosts,我一直在努力让Magento在Nginx上运行。 我不是这方面的专家,但几周来我一直在用Vhost配置进行故障排除 现在我已经到了一个地步,我简直不知道要改变什么了。 问题是,每当我在输入索引并导航到Magento时,它都会尝试下载PHP文件。 这个项目必须完成,我在一家公司实习,我真的很想学习如何实现Nginx,这里没有人能帮我,所以我真的希望这里的人能帮我! 我在nginx中构建了两个独立的vhost文件,一个用于索引,另一个用于备份文件夹,我将备份写入其中以便下载它们。 另一个是纯粹为Ma
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
#default_type text/html;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
这是我的magento vhost文件:
server {
listen 80;
listen 443 default ssl;
server_name mailtest.unitracer.nl www.mailtest.unitracer.nl;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
access_log /var/log/nginx/magento.access.log;
error_log /var/log/nginx/magento.error.log;
root /var/www/magento;
location / {
index index.php;
try_files $uri $uri/ @handler;
}
#deny deze mappen, niemand heeft er iets te zoeken
location /app/ { deny all; }
location /includes/ { deny all; }
location /lib/ { deny all; }
location /media/downloadable/ { deny all; }
location /pkginfo/ { deny all; }
location /report/config.xml { deny all; }
location /var/ { deny all; }
#in /var/export map moet ik user credentials instellen om /var/export te benaderen
#in htpasswd
location /var/export/ {
auth_basic "Restricted";
auth_basic_user_file htpasswd;
autoindex on;
}
#Deny access hidden files
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
location @handler {
rewrite / /index.php;
}
location ~ .php/ {
rewrite ^(.*.php)/ $1 last;
}
location ~ .php$ {
if (!-e $request_filename) {
rewrite / /index.php last;
}
expires 30d;
fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_param HTTPS $fastcgi_https;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params;
}
}
这是我的另一个vhost,我甚至不确定我是否需要这个,但是没有它我的索引将无法显示
server {
listen 80;
listen 443;
root /var/www/;
index index.php;
autoindex on;
server_name mailtest.unitracer.nl;
#SSL Directives
ssl on;
ssl_certificate /etc/nginx/ssl/server.crt;
ssl_certificate_key /etc/nginx/ssl/server.key;
ssl_session_timeout 5m;
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
ssl_prefer_server_ciphers on;
#Location for index
# location ^(.+~\.php)(/.*)$ {
# fastcgi_split_path_info ^(.+~\.php)(/.+)$;
# fastcgi_pass unix:/var/run/php5-fpm.sock;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# include fastcgi_params;
# try_files $uri $uri/ /index.php =404;
# }
#Mijn back-up server block
location /backups {
auth_basic "Restricted";
auth_basic_user_file /var/www/backups/.htpasswd;
try_files $uri $uri/ =404;
}
}
我知道PHP文件已经被传递到正确的PHP FPM套接字,因为它以前与phpmyadmin一起工作过
如果有人能帮我解决这个问题,那就太好了,我真的需要magento来工作,这样我才能理解如何在Nginx上托管它
友好的问候,
Stefan我相信有错误-缺失\
location ~ \.php$ {
expires 30d;
fastcgi_pass unix:/var/run/php5-fpm.sock;
#fastcgi_param HTTPS $fastcgi_https;
fastcgi_param HTTPS $https if_not_empty;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default;
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params;
}
删除location/上的index index.php并在servername下设置index.php,这将起作用。您还可能需要添加fastcgi_split_path_info^(+.php)(.*);和fastcqi_index.php 在locationa~.php$