WordPress on an Apache Server

Setting Up WordPress on an Apache Server on Ubuntu

Install the Ubuntu Operating System on your Computer’s Hard Disk physically or using a Virtualization Software.

Install the LAMP (Linux, Apache, MySQL and PHP) stack bundle by following instructions at this link.

Install WordPress Content Management System (CMS) in Ubuntu leveraging on the LAMP stack by following instructions at this link.  Before going into the “Configure Pretty Permalinks for WordPress” section in the link, the server need to be allocated a domain name or IP address which always points to the server.

A dynamic DNS service could be used to achieve the same.  One such provider is: https://www.noip.com .  You can create a free account with them and add about three hosts to a subdomain of your choosing to the domains they offer.

Make sure that the public IP address of the computer where your apache is installed is added to the host list. 

No-IP_HostName_to_DomainName_Config

Enable IP Address Reservation at the NAT Router for the machine on which the Apache Server is installed, so that it gets a reserved internal address after any reboot.

NAT_Router_Address_Reservation

Configure your NAT router so that requests that are received at port 80 (HTTP) / 443 (HTTPS) / 8245 (No-IP DUC Port) are forwarded to the internal IP address of the machine where the Apache server is installed.

NAT_Router_Port_Forwarding

Install the Linux Dynamic DNS Update Client (DUC) by following the instructions at this link.

To ensure that the No-IP DUC is running at startup and closing when the system is being shutdown, a script should be created and placed at /etc/init.d/

The contents of the script should be as shown below:

 

Please refer to instructions at this link.  It mentions further on how to test the above script, adding the correct permissions and invoking the script for multi user loads by adding the scirpt call to /etc/rc.local script file.

Continue with instructions at this link and complete instructions under the section “Configure Pretty Permalinks for WordPress”, after using the domain name acquired through No-IP as the ServerName.

In order to enable WordPress updates, without setting up FTP/SSH accounts in the server, add the below statement into /var/www/html/wp-config.php

You may refer to this link for detailed screenshots and instructions.

Making WordPress accessible from the Internet

Most ISPs block traffic to common ports (port 22, 23, 80,, etc) of the IP address allocated to their customers as a security measure against attacks.

If the HTTP port (80) is blocked by your ISP, then your WordPress site would not be reachable over the Internet, but only within your LAN (Internal network).

Internet_Access_Before_Redirection

In order to make the WordPress site available over the Internet, the NAT Router, WordPress and apache web server configurations should be modified to enable web communication over a non-standard port (example: 8080 instead of 80).

Change the NAT Router configuration to forward web requests over port 8080 to be redirected to the internal IP address of the server installation.

NAT_Router_Non-Standard_Port_Forwarding

At the WordPress site, go to Dashboard > Settings > General.  Change the WordPress Address (URL) and Site Address (URL) to point to your_site_address:8080.  

WordPress_Dashboard_URL_Configuration

Save the URL configuration change in the Settings page.

Within the Ubuntu OS, perform the below configurations with apache:

Configurations should be modified to be as shown below:

port_listen_conf

Change configurations to be as shown below:

virtualhost_port_conf

Restart apache server.

Now you should be able to reach the WordPress site by using the URL your_site_url:8080 (example: www.example.com:8080) !!!

Internet_Access_Port_Redirected

 

Enabling SSL through a Self-Signed Certificate for the WordPress Installation

Open the WordPress Dashboard -> Settings -> General.  Modify the WordPress Address (URL) and Site Address (URL) values to indicate https://your_site_address

WordPress_Dashboard_URL_Configuration_HTTPS

Check to ensure that .htaccess overrides are allowed for folder locations where the WordPress files are installed.  This is required to enable Permalinks to fuction.  The below code should be present in  your /etc/apache2/apache2.conf file.

Finally, follow instructions at this link to generate a self-signed SSL certificate, enable SSL apache modules and set SSL apache configurations.

Now, your entire site should be accessible over HTTPS !!!

Other References

Install Ubuntu 14.04 LTS in VMware Workstation: https://www.youtube.com/watch?v=w9gtQEPtnI8

http://www.ubuntu.com/download/desktop

https://mobiarch.wordpress.com/2014/05/16/creating-an-init-script-in-ubuntu-14-04/

http://www.noip.com/support/knowledgebase/what-port-does-the-dynamic-update-client-use/

http://codex.wordpress.org/Using_Permalinks

WordPress on an Apache Server

Leave a Reply

Your email address will not be published. Required fields are marked *