Nginx。根目录中的 drupal 和子文件夹中的 Magento
Nginx. Something like drupal in root and Magento in subfolder
在根目录中我有 Drupal。在子目录中,我有 Magento。 drupal 重写很可能与 magento 重写重叠。
Magento 主页在没有任何 nginx 配置的情况下成功打开,但链接不起作用。
我不确定,但我认为要解决我需要从 drupal 路由中排除 magento 目录的问题。
另一件事是,我不确定我是否有正确的 magento 配置。
root config:
server {
listen 80;
root /var/www/domain;
index index.php index.html index.htm;
server_name domain.com;
location /fe {
proxy_pass http://domain.com:1234/visualization;
}
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/domain;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9$
location ~ \.php$ {
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
magento config
server {
listen 80;
## SSL directives might go here
server_name domain.com; ## Domain is here twice so server_name_in_redirect will favour the www
root /var/www/domain/magento;
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
# try_files $uri $uri/ /index.php?q=$uri&$args;
expires 30d; ## Assume all files are cachable
}
## These locations would be hidden by .htaccess normally
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; }
## location ~ /\.ht { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
## location /.
location ~ /\.ht { ## Disable .htaccess and other hidden files
return 404;
}
location /api {
rewrite ^/api/rest /api.php?type=rest last;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ last;
}
location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
expires off; ## Do not cache dynamic content
fastcgi_pass unix:/var/run/php5-fpm.sock;
## fastcgi_pass 127.0.0.1:8079;
##fastcgi_read_timeout 10800s;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
最好的方法是为 magento 使用一些子域,例如 https://shop.yourdomain.com. But if you want to keep it as http://yourdomain.com/magento 您需要为 Magento 删除单独的 nginx 配置文件并将 /magento/ 位置添加到根配置。我的意思是:
location /magento/ {
root /var/www/domain/magento; #main thing
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}
location ^~ /magento/app/ { deny all; }
location ^~ /magento/includes/ { deny all; }
location ^~ /magento/lib/ { deny all; }
location ^~ /magento/media/downloadable/ { deny all; }
location ^~ /magento/pkginfo/ { deny all; }
location ^~ /magento/report/config.xml { deny all; }
location ^~ /magento/var/ { deny all; }
location ~ /magento/\.ht { deny all; }
etc.
然后你需要检查 Magento Secure/Unsecure URL。它应该是 http://yourdomain.com/magento/ 您可以通过管理面板或直接在数据库中更改它 (core_config_data table)。最后清除缓存并重启Nginx。
在根目录中我有 Drupal。在子目录中,我有 Magento。 drupal 重写很可能与 magento 重写重叠。
Magento 主页在没有任何 nginx 配置的情况下成功打开,但链接不起作用。
我不确定,但我认为要解决我需要从 drupal 路由中排除 magento 目录的问题。
另一件事是,我不确定我是否有正确的 magento 配置。
root config:
server {
listen 80;
root /var/www/domain;
index index.php index.html index.htm;
server_name domain.com;
location /fe {
proxy_pass http://domain.com:1234/visualization;
}
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/domain;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9$
location ~ \.php$ {
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
magento config
server {
listen 80;
## SSL directives might go here
server_name domain.com; ## Domain is here twice so server_name_in_redirect will favour the www
root /var/www/domain/magento;
location / {
index index.html index.php; ## Allow a static html file to be shown first
try_files $uri $uri/ @handler; ## If missing pass the URI to Magento's front handler
# try_files $uri $uri/ /index.php?q=$uri&$args;
expires 30d; ## Assume all files are cachable
}
## These locations would be hidden by .htaccess normally
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; }
## location ~ /\.ht { deny all; }
location /var/export/ { ## Allow admins only to view export folder
auth_basic "Restricted"; ## Message shown in login window
auth_basic_user_file htpasswd; ## See /etc/nginx/htpassword
autoindex on;
}
## location /.
location ~ /\.ht { ## Disable .htaccess and other hidden files
return 404;
}
location /api {
rewrite ^/api/rest /api.php?type=rest last;
}
location @handler { ## Magento uses a common front handler
rewrite / /index.php;
}
location ~ .php/ { ## Forward paths like /js/index.php/x.js to relevant handler
rewrite ^(.*.php)/ last;
}
location ~ .php$ { ## Execute PHP scripts
if (!-e $request_filename) { rewrite / /index.php last; } ## Catch 404s that try_files miss
expires off; ## Do not cache dynamic content
fastcgi_pass unix:/var/run/php5-fpm.sock;
## fastcgi_pass 127.0.0.1:8079;
##fastcgi_read_timeout 10800s;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param MAGE_RUN_CODE default; ## Store code is defined in administration > Configuration > Manage Stores
fastcgi_param MAGE_RUN_TYPE store;
include fastcgi_params; ## See /etc/nginx/fastcgi_params
}
最好的方法是为 magento 使用一些子域,例如 https://shop.yourdomain.com. But if you want to keep it as http://yourdomain.com/magento 您需要为 Magento 删除单独的 nginx 配置文件并将 /magento/ 位置添加到根配置。我的意思是:
location /magento/ {
root /var/www/domain/magento; #main thing
index index.html index.php;
try_files $uri $uri/ @handler;
expires 30d;
}
location ^~ /magento/app/ { deny all; }
location ^~ /magento/includes/ { deny all; }
location ^~ /magento/lib/ { deny all; }
location ^~ /magento/media/downloadable/ { deny all; }
location ^~ /magento/pkginfo/ { deny all; }
location ^~ /magento/report/config.xml { deny all; }
location ^~ /magento/var/ { deny all; }
location ~ /magento/\.ht { deny all; }
etc.
然后你需要检查 Magento Secure/Unsecure URL。它应该是 http://yourdomain.com/magento/ 您可以通过管理面板或直接在数据库中更改它 (core_config_data table)。最后清除缓存并重启Nginx。