How to install Wordpress alongside Django application in nginx How to install Wordpress alongside Django application in nginx wordpress wordpress

How to install Wordpress alongside Django application in nginx


You can run apache behind nginx. Below steps worked for me.

1 Install wordpress at /var/www/html/blog using apache server listening at port 8080. Go to /etc/apache2/sites-available/000-default.conf and edit config like below.

<VirtualHost *:8080>ServerAdmin webmaster@localhostDocumentRoot /var/www/htmlServerName example.comServerAlias www.example.com<IfModule mod_setenvif.c>    SetEnvIf X-Forwarded-Proto "^https$" HTTPS</IfModule><Directory /var/www/html/blog>    Options Indexes FollowSymLinks    AllowOverride All    Require all granted</Directory>ErrorLog ${APACHE_LOG_DIR}/your_domain.com_error.log CustomLog ${APACHE_LOG_DIR}/your_domain.com_access.log combined </VirtualHost>

2 Go to /etc/apache2/ports.conf and edit config like below and restart apache server.

Listen 8080<IfModule ssl_module>     Listen 443</IfModule><IfModule mod_gnutls.c>    Listen 443</IfModule>

3 Add below code to your nginx setting.

location /blog/ {    proxy_set_header X-Real-IP  $remote_addr;    proxy_set_header X-Forwarded-For $remote_addr;    proxy_set_header Host $host;    proxy_set_header X-Forwarded-Proto $scheme;    proxy_pass http://127.0.0.1:8080 ;}