簡體   English   中英

Nginx + Magento配置問題。 正在下載PHP文件

[英]Nginx + Magento configuration problems. PHP files are being downloaded

我一直在努力讓Magento在Nginx上運行。 我不是專家,但已經對Vhost配置進行了數周的故障排除。

現在,我已經到了根本不知道要更改什么的地步。 問題是,每當我在https://mailtest.unitracer.nl/輸入索引並導航到Magento時,它都會嘗試下載PHP文件。 這個項目必須完成,我是一家公司的實習生,我真的想學習如何實現Nginx,在這里沒有人可以幫助我,所以我真的希望在這里的人能幫助我! 我在nginx中構建了兩個單獨的虛擬主機文件,一個用於我的索引,另一個用於寫備份的備份文件夾,以便我可以下載它們。 另一個純粹是針對Magento的。

我將把它們都發布在這里,包括我的nginx.conf文件。

這是我的nginx.conf文件:

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;
    }
}

這是我的另一個虛擬主機,我什至不確定我是否需要這個虛擬主機,但是沒有它我的索引將不會顯示。

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上托管它!

友好的問候,

斯特凡

相信有誤-遺失\\

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;
}

刪除位置/上的index index.php並在服務器名下設置index index.php,它將起作用,也有可能需要添加fastcgi_split_path_info ^(。+。php)(。*)$; 和fastcqi_index index.php在locationa〜.php $

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM