Configure WordPress

Posted on

Enable WordPress Site in Apache

Each site should have its own root directory (example /var/www/site1.com and /var/www/site2.org) for its domain.
Use mkdir to create folder then set permissions and change ownership to www-data

sudo mkdir /var/www/site1.com && sudo mkdir /var/www/site1.com/{public_html, logs}
chmod -R 755 /var/www/site1.com 
chown -R www-data:www-data /var/www/site1.com

Copy the extracted worpress folder in site1.com

sudo mv wordpress/* /var/www/site1.com/public_html 

Activate and disable websites in apache

Copy the default configuration file for each site

cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/site1.com.conf
cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/site2.com.conf

Edit the Config File for Each Site

sudo nano /etc/apache2/sites-available/site1.com.conf
<Directory /var/www/site1.com/public_html>
   Require all granted
</Directory>
<VirtualHost *:80>
    ServerAdmin webmaster@site1.com
    ServerName site1.com
    ServerAlias www.site1.com
    DocumentRoot /var/www/html/site1.com/public_html
    ErrorLog /var/www/html/site1.com/error.log
    CustomLog /var/www/html/site1.com/logs/access.log combined
</VirtualHost>

Save and Close then enable the config file

sudo a2ensite site1.com.conf

Disable any unused sites

 sudo a2dissite 000-default.conf

Restart Apache webservices

sudo systemctl restart apache2

The WordPress website should now be running. In a web browser enter http://localhost this should open the setup-config.php webpage. Select language to proceed to the welcome screen. Read the webpage information that will be needed to setup WordPress. If all the information is available click the Lets’ go! button.

Database Name:      wordpress
User Name:          root
Password:           [password]
Database Host:      site1.com
Table Prefix:       wp_

Click Submit to Proceed and then click Run the install button. The next Screen will ask about Title, username, and password for WordPress. Click the Install WordPress button then the WordPress credentials can be used to login. Open a browser and enter the web address http://localhost/wp-admin
To start customizing the WordPress site the files in the wp-content folder will need to be configured.
To get documentation on setting up and using WordPress go to https://wordpress.org/support/