This post is part of a step-by-step series on installing WordPress on Linux (CentOS 6)
- MySQL has been installed and secured
- WordPress Directory has been Installed
- MySQL database for WordPress has been made
- wp-config.php has been appropriately configured with database settings and security keys
Now that our WordPress site has been installed and configured we just need to put it somewhere Apache can find it.
Knowing the Root Directory of your Site
If you already have a site up and running you should know where the root directory of that site is.
Default root directory of Apache
If you have left Apache with its default configuration then the root directory will probably look something like this on CentOS:
For other OSes it may vary a bit.
Custom root directory
If, however, for example, you have multiple sites being served by Apache then they can’t all have the same root directory. In that case we will have to modify Apache’s configuration. First let’s choose/make a place to put our WordPress blog:
[ahmed@amayem ~]$ sudo mkdir /var/testblog
Let’s make sure its permissions are the same as
[ahmed@amayem ~]$ ls -l /var/www drwxr-xr-x 12 root root 4096 Aug 29 17:59 html [ahmed@amayem ~]$ ls -l /var drwxr-xr-x 2 root root 4096 Sep 2 18:42 testblog drwxr-xr-x 7 root root 4096 Mar 28 18:54 www
Looks like it is the same.
Knowing the WP Base Directory
This is where all the WP files are. When installing using yum we found it at the following directory:
If you installed it directly without yum then it is where you unzipped your WP file.
Moving the WP Base Directory Contents to Root Directory of your Site.
Now that we have decided where our site root directory will be let’s move the WP files there:
[ahmed@amayem ~]$ sudo mv /usr/share/wordpress/* /var/testblog/ [ahmed@amayem ~]$ ls /var/testblog/ index.php wp-config-sample.php wp-login.php wp-activate.php wp-content wp-mail.php wp-admin wp-cron.php wp-settings.php wp-blog-header.php wp-includes wp-signup.php wp-comments-post.php wp-links-opml.php wp-trackback.php wp-config.php wp-load.php xmlrpc.php
Looks like we have success.
Configuring Apache if Using a Custom Site Root Directory
Go to the Apache configuration and open it for editing using
vi or your favourite editor:
[ahmed@amayem ~]$ sudo vi /etc/httpd/conf/httpd.conf
Go to the bottom by entering
NameVirtualHost *:80 is commented (has a
# at the beginning of a line), then uncomment it by removing the
#. Then add the following with your information. For more on copy pasting in vi check here:
<VirtualHost *:80> ServerName test.amayem.com ServerAlias www.test.amayem.com DocumentRoot /var/testblog/ </VirtualHost>
Note that if you had a site running previously on the default root then you should also put another one with the info for your original site with the
DocumentRoot pointing to the
default Apache root so that the original site is unaffacted.
Exit insert mode using
ctrl+c then save by entering
:x. Now we need to restart apache:
[ahmed@amayem ~]$ sudo apachectl restart