Reputation: 179
I have a Magento 2 installed in /var/www/html/ folder using mydomain.com and I added a Wordpress in /var/www/html/pub/wp/ folder using mydomain.com/wp/ When I tried to access mydomain.com/wp/readme.html it's working fine but all php files are not accessible so I can't connect to admin mydomain.com/wp/wp-login.php and see my Wordpress.
I added this to my nginx configuration but it's not working :
location /wp/ {
index index.html index.php;
try_files $uri $uri/ /wp/index.php?q=$uri&args;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /wp/index.php;
include fastcgi.conf;
}
}
Upvotes: 2
Views: 1093
Reputation: 538
I had the same issue but turned out it was due to Varnish. If anyone else has the same issues, try this:
Add this to above your server block in nginx config
map $http_x_forwarded_proto $https_flag {
default off;
https on;
}
server {
listen 8080; .....
Then add this to your magento nginx.conf file located in your Magento Install (I added it after the "# PHP entry point for main application" block)... like this
# PHP entry point for main application
location ~ ^/(index|get|static|errors/report|errors/404|errors/503|health_check)\.php$ {
try_files $uri =404;
fastcgi_pass fastcgi_backend;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param PHP_FLAG "session.auto_start=off \n suhosin.session.cryptua=off";
fastcgi_param PHP_VALUE "memory_limit=756M \n max_execution_time=18000";
fastcgi_read_timeout 600s;
fastcgi_connect_timeout 600s;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /wp/ {
try_files $uri $uri/ /index.php?q=$uri&$args;
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_param HTTPS $https_flag;
fastcgi_pass unix:/run/php/php8.2-fpm.sock;
}
}
Upvotes: 0
Reputation: 1
My magento project installed on docker. My WP site installed in pub/wp/. When installing i used this documentation https://fishpig.co.uk/magento/wordpress-integration/docs/
I faced with the same problem.
I resolve this problem by changing fastcgi_pass value to the value what is used in my docker container (fastcgi_backend):
location /wp/ {
index index.html index.php;
try_files $uri $uri/ /wp/index.php$is_args$args;
location ~ \.php$ {
fastcgi_pass fastcgi_backend;
fastcgi_index /wp/index.php;
include fastcgi.conf;
}
After that you need to change siteurl and home value in wp_options table
Upvotes: 0
Reputation: 1697
You have installed WordPress at pub/wp but your Nginx config refers just to /wp/. Either modify your Nginx config to refer to /pub/wp/ or move WordPress to the root (eg. /wp/).
https://fishpig.co.uk/magento/wordpress-integration/nginx/
upstream fastcgi_backend {
server 127.0.0.1:9000;
}
server {
listen 80;
# Magento 2 base URL
server_name m2.latest.composer.fp.com;
# Magento 2 root directory
set $MAGE_ROOT /home/magento2/html;
set $MAGE_DEBUG_SHOW_ARGS 1;
include /home/magento2/html/nginx.conf.sample;
# WordPress is installed in pub/wp
location /wp/ {
index index.html index.php;
try_files $uri $uri/ /wp/index.php?q=$uri&args;
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /wp/index.php;
include fastcgi.conf;
}
}
}
Upvotes: 3