Skip to content

Instantly share code, notes, and snippets.

@yacafx

yacafx/default

Last active Jun 22, 2021
Embed
What would you like to do?
NGNIX configuration for run node app and php app at the same same time - This configuration made Node and Wordpress working at the same time on two different routes.
### /etc/nginx/sites-available/default
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.php;
server_name _;
# This configuration is open under mydomain.com
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# This configuration is open under mydomain.com/myapp
location /myapp {
# alias /home/apps/myapp;
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
# If php is updated, should update the fpm php version
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
@yacafx

This comment has been minimized.

Copy link
Owner Author

@yacafx yacafx commented Aug 27, 2018

If php is updated, should update the fpm php version.

This can happen if you upgrade your server OS or if you update manually your PHP version.

@yacafx

This comment has been minimized.

Copy link
Owner Author

@yacafx yacafx commented Aug 27, 2018

This NGINX configuration made Node and Wordpress working at the same time

@marioluevanos

This comment has been minimized.

Copy link

@marioluevanos marioluevanos commented Oct 23, 2020

Hello,
I have a similar setup. With Node.js already running on a LEMP stack and would like to add WP.

And wondering if this will work as a WordPress subdomain?

Would I need a different server block?

Thanks.

@yacafx

This comment has been minimized.

Copy link
Owner Author

@yacafx yacafx commented Oct 23, 2020

Hi @marioluevanos, sure! Just you will need to keep the php configuration on the subdomain block

@marioluevanos

This comment has been minimized.

Copy link

@marioluevanos marioluevanos commented Oct 29, 2020

@yacafx Grea, I got it working. Thanks!

@ankitlogicsofts

This comment has been minimized.

Copy link

@ankitlogicsofts ankitlogicsofts commented Jun 1, 2021

Hi @yacafx, This is working fine but my pretty permalink is not working, showing error 404

@yacafx

This comment has been minimized.

Copy link
Owner Author

@yacafx yacafx commented Jun 1, 2021

Hi @ankitlogicsofts Looks like for Wordpress you will need to apply some extra configurations… here some docs that i found on the net… https://nginxlibrary.com/wordpress-permalinks

Hope this works for you! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment