nginx / apache / php-fpm

时间:2017-05-04 14:41:22

标签: php apache nginx

首先,我对这个服务器的东西全新,所以请耐心等待我。我正在关注我的magento网站下面的链接,但我在这里发帖是因为它是服务器配置问题。

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 not found错误,我可以看到nginx运行得很好所以我哪里出错?

1 个答案:

答案 0 :(得分:0)

事实证明,这是一个配置问题,当我应该使用nginx用户和nginx组时,我正在使用apache用户和apache组,现在它可以正常工作