• Home
  • Archive
  • Tools
  • Contact Us

The Customize Windows

Technology Journal

  • Cloud Computing
  • Computer
  • Digital Photography
  • Windows 7
  • Archive
  • Cloud Computing
  • Virtualization
  • Computer and Internet
  • Digital Photography
  • Android
  • Sysadmin
  • Electronics
  • Big Data
  • Virtualization
  • Downloads
  • Web Development
  • Apple
  • Android
Advertisement
You are here:Home » Install WordPress in a Subdirectory on Nginx (Ubuntu, Rackspace Cloud)

By Abhishek Ghosh October 24, 2014 10:48 am Updated on October 24, 2014

Install WordPress in a Subdirectory on Nginx (Ubuntu, Rackspace Cloud)

Advertisement

Here is how to install WordPress in a subdirectory on Nginx taking it granted that the device is running Ubuntu as Rackspace Cloud Server PVHVM Multi-Instance (i.e. Application Server is Different than Web Server). At minimum, you should be using a standard way of installing Nginx on Rackspace Cloud on one server instance. We can NOT provide any warranty of working fine with the exact codes if your setup is quite different AS custom setup of Nginx can vary widely, i.e. Nginx can be configured with LuaJit.

 

The Ideal Example Situation to Install WordPress in a Subdirectory on Nginx (Ubuntu, Rackspace Cloud)

 

Suppose, you used a different PHP based software for podcast or used a subdomain. Now with HTTPS or with practical issues with the Podcast software, you want to use the podcast subdirectory to install a Fresh, new WordPress which is fully separate from your main WordPress – i.e. not a WordPress Multisite. There are some basic Tricks to Install WordPress in a Subdirectory on Nginx in a Standard Setup. Usually, by default pretty permalinks of WordPress will not work on the subdirectory. That is what is the basic problem which will provide you solution.

 

Install WordPress in a Subdirectory on Nginx (Ubuntu, Rackspace Cloud)

 

Read our detailed guide to install WordPress, if you are fully new. SSH to your Database Server and create a new database, an user and give the user access to the database :

Advertisement

---

/root
Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
mysql -u root -p
# change wordpress, it is an example
CREATE DATABASE wordpress;
# wordpressuser should be changed, it is example, so is password
CREATE USER wordpressuser@localhost IDENTIFIED BY 'password';
# we will use localhost on one server
# we will use the servicenet IP / Private IP with separate database server
# modify accordingly
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
exit
# may be?
apt-get update -y && apt-get upgrade
# exit from ssh if database server is different
exit

Keep the details on a separate text file. Now, SSH to your web server as root. Create the subdirectory, if does not exist :

/root
Vim
1
2
mkdir -p /usr/share/nginx/html/your-subdomain
# default location on Ubuntu for apt based nginx

Simply CD to the subdirectory and wget WordPress, un-tar it :

/usr/share/nginx/html/your-subdomain
Vim
1
2
3
4
5
6
7
8
cd /usr/share/nginx/html/your-subdomain
# default location on Ubuntu for apt based nginx
wget http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
cd wordpress
mv * .. && cd ..
rm -r wordpress latest.tar.gz && ls
# see the files

Point to the desired url on browser like :

Vim
1
https://jima.in/your-subdomain

Fill up the web form and continue to undergo infamous 5 minutes installation. (Why Infamous? It takes 60 seconds on $5 / month Hostgator, thats why it is hugely used by the spammers, Google possibly thinks WordPress can be spammy, thats why its infamous…)
Aha, WordPress will tell you that it has no right permission to write (no right to write lol) to create the file wp-config.php, instead will give you what to write as plain text file. Highlight the fully text and copy it. Create wp-config.php and paste the material, then save it :

/usr/share/nginx/html/your-subdomain
Vim
1
2
3
4
nano wp-config.php
# paste
# write out with ^ + O
# exit with ^ + X

Continue browser works. So your WordPress is ready, but many things are not ready. First, change the permissions :

/usr/share/nginx/html/your-subdomain
Vim
1
2
3
4
5
6
7
8
9
pwd
# never run "sudo chmod chown root:www-data" command while at root without path
# unix will test your knowledge instantly
# it is safe to be at the directory to change ownership
cd /usr/share/nginx/html/your-subdomain
sudo chown root:www-data /usr/share/nginx/html/your-subdomain -R
sudo chmod g+w /usr/share/nginx/html/your-subdomain -R
sudo chgrp -R www-data /usr/share/nginx/html/your-subdomain
# change /your-subdomain/

But, your pretty permalinks will not work unless you define the things how to be handled by Nginx, so open the default domain config file (i.e. /etc/nginx/sites-available/default by default) :

/etc/nginx/sites-available/default
Vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# this is almost flawless for HTTPS website
# only link to wp-admin dashboard will not work
# from frontend wordpress admin menu bar
# copy from the next line
location /your-subdomain {
    index index.php;
    rewrite ^/your-subdomain/(.*)+$ /your-subdomain/index.php?$1;
}
# stop copying
# your-subdomain is not your name, change it
# where to paste?
# within
# HTTPS server
#server {
#}
# block or post plain server block if you are not secure
# find the last "}" and paste before it
# save with ^ + O and Exit with ^ + X
# do a config test
nginx -t
# restart if output is fine
service nginx restart
# set the appropriate permalink structure from wp admin
# your w3tc 's rerite will look like this :
if (!-f "$document_root/your-subdomain/wp-content/cache/page_enhanced/$http_host/$request_uri/_index$w3tc_rewrite.html$w3tc_enc") {
  set $w3tc_rewrite 0;
}

Lot of peoples on stack overflow will flow huge knowledge on only this block, but our method will work with WordPress SEO, Genesis and W3tC without any problem. Your subdirectory will exactly follow the rules of server block, if you do not know anything about NAXSI (Nginx Anti Xss & Sql Injection), you should never try the other methods. What a particular rewrite rule can make a WordPress plugin to be point to becoming vulnerable, we will not expose. Even if you have not configured NAXSI, on Rackspace, with this rules on Infrastructure Managed, it is unlikely to invite SQL injection. Here is the philosophy of NAXSI :

Install WordPress in a Subdirectory on Nginx (Ubuntu, Rackspace Cloud)

There is nothing more to write!

Tagged With htmly nginx subdirectory , instaall wordpress subdirectory nginx , install wordpress in subdirectory nginx ubuntu , install wordpress nginx in a sub directory , nginx subdirectory privileges , nginx subdirectory rewrite joomla ubuntu , nginx wordpress in subdirectory , put wordpress in sub directory nginx , ubuntu nginx subdomain
Facebook Twitter Pinterest

Abhishek Ghosh

About Abhishek Ghosh

Abhishek Ghosh is a Businessman, Surgeon, Author and Blogger. You can keep touch with him on Twitter - @AbhishekCTRL.

Here’s what we’ve got for you which might like :

Articles Related to Install WordPress in a Subdirectory on Nginx (Ubuntu, Rackspace Cloud)

  • WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud

    Here is a Step by Step Guide on Setting Up WordPress Multisite on Nginx on Ubuntu 14.04 on HP Cloud with All Commands and the Configuration.

  • Nginx WordPress Installation Guide (All Steps)

    This is a Full Nginx WordPress Installation Guide With All the Steps, Including Some Optimization and Setup Which is Compatible With WordPress DOT ORG Example Settings For Nginx.

  • How to Install WordPress : Ubuntu 16.04, Nginx, PHP7-FPM

    Here is Step by Step Guide on How to Install WordPress on Ubuntu 16.04, Nginx, PHP7-FPM, memcached & Percona MySQL 5.7 on Cloud Server or VPS.

  • Install Phabricator on Ubuntu 14.04, Nginx (Cloud Server)

    Here are Steps to Install Phabricator on Ubuntu 14.04, Nginx Running on a Typical Cloud Server Instance. Phabricator is multipurpose software.

performing a search on this website can help you. Also, we have YouTube Videos.

Take The Conversation Further ...

We'd love to know your thoughts on this article.
Meet the Author over on Twitter to join the conversation right now!

If you want to Advertise on our Article or want a Sponsored Article, you are invited to Contact us.

Contact Us

Subscribe To Our Free Newsletter

Get new posts by email:

Please Confirm the Subscription When Approval Email Will Arrive in Your Email Inbox as Second Step.

Search this website…

 

Popular Articles

Our Homepage is best place to find popular articles!

Here Are Some Good to Read Articles :

  • Cloud Computing Service Models
  • What is Cloud Computing?
  • Cloud Computing and Social Networks in Mobile Space
  • ARM Processor Architecture
  • What Camera Mode to Choose
  • Indispensable MySQL queries for custom fields in WordPress
  • Windows 7 Speech Recognition Scripting Related Tutorials

Social Networks

  • Pinterest (24.3K Followers)
  • Twitter (5.8k Followers)
  • Facebook (5.7k Followers)
  • LinkedIn (3.7k Followers)
  • YouTube (1.3k Followers)
  • GitHub (Repository)
  • GitHub (Gists)
Looking to publish sponsored article on our website?

Contact us

Recent Posts

  • Hybrid Multi-Cloud Environments Are Becoming UbiquitousJuly 12, 2023
  • Data Protection on the InternetJuly 12, 2023
  • Basics of BJT TransistorJuly 11, 2023
  • What is Confidential Computing?July 11, 2023
  • How a MOSFET WorksJuly 10, 2023
PC users can consult Corrine Chorney for Security.

Want to know more about us?

Read Notability and Mentions & Our Setup.

Copyright © 2023 - The Customize Windows | dESIGNed by The Customize Windows

Copyright  · Privacy Policy  · Advertising Policy  · Terms of Service  · Refund Policy