2017-05-04 124 views
0

首先我對這個服務器的東西是全新的,所以請耐心等待我。我在下面的鏈接爲我的magento網站,但我在這裏發佈,因爲它是一個服務器配置問題。nginx/apache/php-fpm的配置問題

https://www.rosehosting.com/blog/magento-2-with-redis-varnish-and-nginx-as-ssl-termination/

我的nginx的配置文件:

upstream fastcgi_backend { 
    server unix:/var/run/www.sock ; 
} 

server { 
    server_name website.com www.website.com; 
    listen 8080; 
    set $MAGE_ROOT /var/www/html/; 
    set $MAGE_MODE production; # or developer 

    access_log /var/log/nginx/website.com-access.log; 
    error_log /var/log/nginx/website.com-error.log; 

    include /var/www/html/nginx.conf.sample; 
} 

server { 

    listen 443 ssl http2; 
    server_name website.com www.website.com; 

    ssl_certificate /ssl/cert; # change with your SSL cert 
    ssl_certificate_key /ssl/key; # change with your SSL key 
    ssl_protocols    TLSv1 TLSv1.1 TLSv1.2; 
    ssl_ciphers    'AES128+EECDH:AES128+EDH:!aNULL'; 
    ssl_session_cache shared:SSL:10m; 
    ssl_session_timeout 24h; 
    keepalive_timeout 300s; 

    location/{ 
     proxy_pass http://127.0.0.1; 
     proxy_set_header Host $http_host; 
     proxy_set_header X-Forwarded-Host $http_host; 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header Ssl-Offloaded "1"; 
     proxy_set_header  X-Forwarded-Proto https; 
     proxy_set_header  X-Forwarded-Port 443; 
     #proxy_hide_header X-Varnish; 
     #proxy_hide_header Via; 
     proxy_set_header X-Forwarded-Proto $scheme; 
    } 
} 

我的Apache配置文件:

<IfModule mod_ssl.c> 

    <VirtualHost *:8443 > 
     ServerName "website.com:443" 
     ServerAlias "www.website.com" 
     ServerAlias "ipv4.website.com" 
     ServerAdmin "email" 
     UseCanonicalName Off 

     DocumentRoot "/var/www/html/" 
     CustomLog /var/www/logs/access_ssl_log combined 
     ErrorLog "/var/www/logs/error_log" 

     <IfModule mod_suexec.c> 
      SuexecUserGroup "apache" "apache" 
     </IfModule> 


     <IfModule mod_sysenv.c> 
      SetSysEnv PP_VHOST_ID "c0cadc45-f0fe-460b-a746-f0cf7e323d99" 
     </IfModule> 

     ScriptAlias "/cgi-bin/" "/var/www/html/cgi-bin/" 

     SSLEngine on 
     SSLVerifyClient none 
     SSLCertificateFile /ssl/cert-eE2sPr 
     SSLCACertificateFile /ssl/cert-EBBnFs 

     TimeOut 200001 
#<IfModule mpm_event_module> 
#ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1 
#</IfModule> 
#ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/var/www/html/$1 

     <Directory /var/www/html/> 
     AllowOverride All 
      <IfModule mod_perl.c> 
       <Files ~ (\.pl$)> 
        SetHandler perl-script 
        PerlHandler ModPerl::Registry 
        Options +ExecCGI 
        allow from all 
        PerlSendHeader On 
       </Files> 
      </IfModule> 
      <filesMatch "\.php$"> 
      SetHandler "proxy:fcgi://localhost:9000" 
      </filesMatch> 


     SSLRequireSSL 

      Options -Includes +ExecCGI 

     </Directory> 
     <IfModule mod_rewrite.c> 
      RewriteEngine On 
      #RewriteCond %{HTTP_HOST} ^website.com$ [NC] 
      #RewriteRule ^(.*)$ https://www.website.com$1 [L,R=301] 
     </IfModule> 


     <IfModule mod_security2.c> 
     </IfModule> 

     <Location /> 
     CacheEnable disk 
     CacheHeader on 

     CacheDefaultExpire 600 
     CacheMaxExpire 86400 
     CacheLastModifiedFactor 0.5 

     ExpiresActive on 
     ExpiresDefault "access plus 5 minutes" 

     Header set Cache-Control "max-age=290304000, public" 
     FileETag All 
     </Location> 

    </VirtualHost> 

</IfModule> 
<VirtualHost *:8080 > 
    ServerName "website.com:80" 
    ServerAlias "www.website.com" 
    ServerAlias "ipv4.website.com" 
    ServerAdmin "email" 
    UseCanonicalName Off 

    DocumentRoot "/var/www/html/" 
    CustomLog /var/www/logs/access_log combined 
    ErrorLog "/var/www/logs/error_log" 

    <IfModule mod_suexec.c> 
     SuexecUserGroup "apache" "apache" 
    </IfModule> 


    <IfModule mod_sysenv.c> 
     SetSysEnv PP_VHOST_ID "c0cadc45-f0fe-460b-a746-f0cf7e323d99" 
    </IfModule> 

    ScriptAlias "/cgi-bin/" "/var/www/html/cgi-bin/" 

    <IfModule mod_ssl.c> 
     SSLEngine off 
    </IfModule> 

    TimeOut 200001 

    <Directory /var/www/html/> 
    AllowOverride All 
     <IfModule mod_perl.c> 
      <Files ~ (\.pl$)> 
       SetHandler perl-script 
       PerlHandler ModPerl::Registry 
       Options +ExecCGI 
       allow from all 
       PerlSendHeader On 
      </Files> 
     </IfModule> 
     <IfModule mod_fcgid.c> 
      <Files ~ (\.fcgi$)> 
       SetHandler fcgid-script 
       Options +ExecCGI 
      </Files> 
     </IfModule> 
    <filesMatch "\.php$"> 
     SetHandler "proxy:fcgi://localhost:9000" 
    </filesMatch> 

     Options -Includes +ExecCGI 

    </Directory> 

    <IfModule mod_rewrite.c> 
     RewriteEngine On 
     #RewriteCond %{HTTP_HOST} ^website.com$ [NC] 
     #RewriteRule ^(.*)$ http://www.website.com$1 [L,R=301] 
    </IfModule> 


    <IfModule mod_security2.c> 
    </IfModule> 

    <Location /> 
     CacheEnable disk 
     CacheHeader on 

     CacheDefaultExpire 600 
     CacheMaxExpire 86400 
     CacheLastModifiedFactor 0.5 

     ExpiresActive on 
     ExpiresDefault "access plus 5 minutes" 

     Header set Cache-Control "max-age=290304000, public" 
     FileETag All 
    </Location> 

</VirtualHost> 

至於我可以告訴大家,我已經正確地做了一切,但我發現一個404 nginx沒有找到錯誤,我可以看到nginx運行正常,所以我哪裏出錯了?

+0

你'proxy_pass HTTP://127.0。 0.1;'語句應該指定一個端口(除非你真的想代理端口80)? –

回答

0

事實證明,這是一個配置的問題,我用的是apache用戶,當我應該使用nginx的用戶和nginx的組Apache組,現在可