在 ec2 实例上为 Magento 配置 nginx 时遇到问题

trouble configuring nginx on ec2 instance for Magento

我正在尝试在 运行 NGINX 和 HHVM 的 Amazon EC2 服务器上安装 Magento 1.9。我有 HHVM 和 NGINX 运行,当我将 EC2 Serers 的 IP 放入 URL 时,我会显示 NGINX 欢迎屏幕,但是当我将 url 放入我的 Magento 应用程序时(即 http://54.???.??.???/dev-magento) 我收到 404 错误。

我将 Magento 放在 /var/www/dev-magento 而不是 /usr/share/nginx/html/。我也打算有一个 staging-magento 站点,这就是为什么我不只是将 Magento 放入 /usr/share/nginx/html/.

我已经用

设置了/etc/www/目录
sudo chown www-data:www-data * -R
sudo usermod -a -G www-data ubuntu

我还在 /etc/nginx/sites-available.dev-magento

中为 dev-magento 站点创建了一个 nginx 配置文件
server {
    # Listen on port 80 as well as post 443 for SSL connections.
    listen 80;
    #listen 443 default ssl;

    server_name 54.???.??.???/dev-magento;

    # Specify path to your SSL certificates.
   #ssl_certificate /etc/nginx/certificates/yourcertificate.crt;
    #ssl_certificate_key /etc/nginx/certificates/yourcertificate.key;

    # Path to the files in which you wish to
    # store your access and error logs.
    #access_log /path/to/your/logs/access_log;
    #error_log /path/to/your/logs/error_log;

    # If the site is accessed via mydomain.com
    # automatically redirect to www.magento.localhost.com.
    #if ($host = 'dev-magento' ) {
        #rewrite ^/(.*)$ http://www.dev-magento/permanent;
   #}

    root /var/www/dev-magento/;

    location / {
        index index.html index.php;
        try_files $uri $uri/ @handler;
    }

    # Deny access to specific directories no one
    # in particular needs access to anyways.
    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; }

    # Allow only those who have a login name and password
    # to view the export folder. Refer to /etc/nginx/htpassword.
    #location /var/export/ {
    #    auth_basic "Restricted";
    #    auth_basic_user_file htpasswd;
    #    autoindex on;
    #}

    # Deny all attempts to access hidden files
    # such as .htaccess, .htpasswd, etc...
    location ~ /\. {
         deny all;
         access_log off;
         log_not_found off;
    }

    # This redirect is added so to use Magentos
    # common front handler when handling incoming URLs.
    location @handler {
        rewrite / /index.php;
    }

    # Forward paths such as /js/index.php/x.js
    # to their relevant handler.
    location ~ .php/ {
        rewrite ^(.*.php)/  last;
    }

    # Handle the exectution of .php files.
    location ~ .php$ {
        if (!-e $request_filename) {
            rewrite / /index.php last;
        }
        expires off;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        #fastcgi_param HTTPS $fastcgi_https;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param MAGE_RUN_CODE default;
        fastcgi_param MAGE_RUN_TYPE store;
        include fastcgi_params;
    }
}

之后我运行:

sudo ln -s /etc/nginx/sites-available/dev-magento /etc/nginx/sites-enabled/
sudo service nginx restart
sudo service hhvm restart

然而,当我转到 54.???.??.???/dev-magento.

时,我仍然收到 404 页面

我想我一定是遗漏了一些非常明显的东西,因为我对 AWS 和 NGINX 配置还很陌生。

我可以通过将我的 nginx 配置文件中的服务器名称更改为 server_name dev-magento; 然后将 54.???.??.??? dev-magento 添加到我的本地机器 /etc/hosts 来解决这个问题 文件。