3254effab3547d0768151e1aa14cf94d56927528
By:
irakliGM

How to install wordpress blog on my existing wordpress website?

February 15, 2016 1.8k views
WordPress Nginx Ubuntu

I have a fully functional wordpress website running on ubuntu 14.04 nginx. I need to run a wp blog on this link : www.mywebsite.com/blog . I tried using the same tutorial like creating wp website but could not succeed. In brief, I need to install another wp to mywebsite.com/blog link. Can smb help me?

1 Answer

Hey there,

You would need to create a second database and upload the WordPress file to the folder within the main site's DocumentRoot. Since /blog is something that the main WordPress installation will try to redirect and interpret, I would recommend naming placing this second WordPress site in a folder named articles or news instead.

If that doesn't work, reply back with the steps you are getting hung up on.

Happy coding,

Jon Schwenn
Platform Support Specialist
DigitalOcean

  • Hi Jon. Thanks for reply. I followed your suggestions, here is what i have got.

    1) I created folder called "articles" within the main site's DocumentRoot.
    2) I created another database(followed this tutorial: https://www.digitalocean.com/community/tutorials/how-to-install-wordpress-with-nginx-on-ubuntu-14-04)
    3) Then I downloaded latest wordpress. Modified wp-config.php appropriately(modifying database creditentials) and recursively copied wp files to /var/www/html/articles folder. did permission issues successfully.

    After that I am trying to modify nginx server block and this is where I hang up.
    As you know I already have one functional website, so /etc/nginx/sites-enabled already contains configuration file called "wordpress". this file's server part looks like this :

    server {
    listen 80;
    server_name www.gungameshub.com gungameshub.com;
    rewrite ^/(.*) https://www.gungameshub.com/$1 permanent;
    }

    server {
    listen 443 defaultserver ssl;
    listen [::]:80 default
    server ipv6only=on;

        root /var/www/html;
        index index.php index.html index.htm;
    
        server_name www.gungamehub.com;
    
        ssl on;
    
        ssl_certificate www.gungameshub.com.chained.crt;
        ssl_certificate_key www.gungameshub.com.key;
    
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
        ssl_prefer_server_ciphers on;
        ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
    
        location / {
                # try_files $uri $uri/ =404;
                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 /usr/share/nginx/html;
        }
    
        location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
        }
    

    }

    I tried to create file like above for gungameshub.com/blog server configuration, but i have duplicate host listening errors. Honestly, i do not know how to manage from here, do i have to modify this "wordpress" file and how? or do i have to create new one? also, do i need subdomain to get www.gungameshub.com/blog?

    Sorry for so many questions, but I am new at VPS and still happy for deploying main website ;d good times when cPanel did everything for me ;d
    any help will be appreciated ;)

    • If everything is contained in a folder within the main DocumentRoot, you would not need to do anything in the server block. You only need one server block file.

      You could do blog.gungameshub.com instead of www.gungameshub.com/articles. The blog subdomain would need it's own server block file and you would place the DocumentRoot outside of the original site's directory.

      Happy coding,

      Jon Schwenn
      Platform Support Specialist
      DigitalOcean

      • thank you jon ;) it works now !

      • Jon everything works fine besides one little issue. I successfully installed second wordpress : www.gungameshub.com/articles. Custom permalinks work fine on the main website. Default plain permalinks work fine on gungameshub.com/articles, but when I change from default to custom permalink (/game/%postname%/) and when I try to access link like gungameshub.com/articles/game/example-post I get 404 Sorry, the search is not found! (that 404 page has main website's design, so I doubt that custom permalinks are looked up under main wordpress, not the second one(/articles)). Do I have to modify nginx server block? Everything works fine, just this is left.

        Main site is placed here: /var/www/html
        Article`s site is placed here /var/www/html/articles
        This is my nginx server block:

        server {
            listen 80;
            server_name www.gungameshub.com gungameshub.com;
            rewrite ^/(.*) https://www.gungameshub.com/$1 permanent;
        }
        
        server {
            listen 443 default_server ssl;
            listen [::]:80 default_server ipv6only=on;
        
            root /var/www/html;
            index index.php index.html index.htm;
        
            server_name www.gungamehub.com;
        
            ssl on;
        
            ssl_certificate www.gungameshub.com.chained.crt;
            ssl_certificate_key www.gungameshub.com.key;
        
            ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
            ssl_prefer_server_ciphers on;
            ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
        
            #block user agent bots
            include /etc/nginx/block.conf;
        
            set $cache_uri $request_uri;
        
            # POST requests and urls with a query string should always go to PHP
            if ($request_method = POST) {
                set $cache_uri 'null cache';
            }
            if ($query_string != "") {
                set $cache_uri 'null cache';
            }
        
            # Don't cache uris containing the following segments
            if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {
                set $cache_uri 'null cache';
            }
        
            # Don't use the cache for logged in users or recent commenters
            if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_logged_in") {
                set $cache_uri 'null cache';
            }
        
            # Use cached or actual file if they exists, otherwise pass request to WordPress
            location / {
                try_files /wp-content/cache/supercache/$http_host/$cache_uri/index.html $uri $uri/ /index.php ;
            }
        
            location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires 20y;
                log_not_found off;
            }
        
            location = /mobile {
                return 301 /m;
            }
        
            location ~ \.php$ {
                try_files $uri =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
            }
        }
        
        
        • I figured out. It works now. If somebody else need it is the solution:
          For subdirectories dir1 and dir2, you could wrap the try_files with locate blocks, something like:

          location /dir1/ {
          try_files $uri $uri/ /dir1/index.php?$args;
          #...
          }

          location /dir2/ {
          try_files $uri $uri/ /dir2/index.php?$args;
          #...
          }

Have another answer? Share your knowledge.