Sonika
Sonika

Reputation: 35

How to install Wordpress alongside Django application in nginx

My application is running on ubuntu/nginx. I want to install wordpress on /blog url using nginx. Please let me know the best way.

Upvotes: 3

Views: 121

Answers (1)

Karmveer Singh
Karmveer Singh

Reputation: 953

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@localhost
DocumentRoot /var/www/html
ServerName example.com
ServerAlias 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 ;
}

Upvotes: 2

Related Questions