在过去的几天里,我一直在执行将我们的 Magento 网站从共享主机迁移到 VPS 的任务。VPS 使用带有 php-fpm 的 Nginx。
笔记目前我们在转移域名时也遇到了问题,因此当我尝试测试 VPS 时,我一直使用它的 ipv4 地址。
问题
当我在浏览器中访问服务器的地址时,页面的标题是“404 Not Found”,没有加载 css,但是显示了链接等 html 元素;当我尝试访问 Magento 后端时,我被重定向到“欢迎使用 Nginx”页面。
虚拟主机配置
server {
# Listen on port 80 as well as post 443 for SSL connections.
listen 80;
listen 443 default ssl;
server_name 176.126.242.85;## yourdomain.com www.yourdomain.com;
# 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 yourdomain.com
# automatically redirect to www.yourdomain.com.
#if ($host = 'yourdomain.com' ) {
# rewrite ^/(.*)$ http://176.126.242.85/$1permanent;
#}
root /var/www/infepos;
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)/ $1 last;
}
# Handle the exectution of .php files.
location ~ .php$ {
if (!-e $request_filename) {
rewrite / /index.php last;
}
expires off;
fastcgi_pass 127.0.0.1:9000;
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;
}
}
我是 Magento 和 Nginx 的新手,如能得到任何帮助我将非常感激。
答案1
我设法解决了该错误。
问题是我的默认虚拟主机与我的自定义虚拟主机具有相同的服务器名称