## Table of Contents
– [Creating a MySQL Database and user for WordPress](#creating-a-mysql-database-and-user-for-wordpress
– [Install additional PHP extensions](#install-additional-php-extensions
– [Adjust the apache configuration to allow for htaccess Overrides and Rewrites](#adjust-the-apache-configuration-to-allow-for-htaccess-overrides-and-rewrites
– [Download WordPress](#download-wordpress
– [Configure WordPress directory](#configure-wordpress-directory
– [Completion of the interface through the web interface](#completion-of-the-interface-through-the-web-interface
[Wordpress](https://wordpress.com/ is the most popular and accurate Content management system on the internet. WordPress is an online, open source website creation tool which can be written in PHP. It is the most comfortable, potent and useful blogging setup.
WordPress is free to install and upgrade. After the completion, the administration can be done through the web interface. Here, WordPress is done with the setup of LAMP which is a mix of (Linux, Apache, MySQL, PHP on the server Ubuntu 18.04.
The primary or initial steps that need to be followed are:
You should have access to an Ubuntu 18.04 server and created a non-root user account with sudo privileges by following our guide, [Initial server setup with Ubuntu 18.04](https://systemongrid.com/guides/how-to-do-initial-server-setup-with-ubuntu-18.04.
You should have installed LAMP stack by following our guide, How to Install Linux, Apache, MySQL, PHP (LAMP Stack on Ubuntu 18.04.
Secure your site with SSL that is used to secure the information. This technology allows encrypting the traffic from the belonging site so that connection will become secure. SSL setup will depend on the domain usage. If the domain name is provided then it will be easy to secure the site with the trusted certificates and free. If the domain is not provided then the domain will be encrypted the same but without domain validation.
# Creating a MySQL database and user for WordPress
The initial step for WordPress uses MySQL database to store the information of the user. The MySQL is already been installed according to initial setup but needs to make database and user for WordPress to use. So log into MySQL root :
$ mysql -u root -p
After the log in there will be an appearance of a password that needs to be set for MySQL after the installation. The database will be created for the control of WordPress
mysql> CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;
We will create MySQL user account separately to operate on newly created database.
Create one-function databases for security purpose and name it as the wordpressuser. As this account is created and a secure password is set, access is granted to them.
GRANT ALL ON wordpress.* TO ‘wordpressuser’@’localhost’ IDENTIFIED BY ‘password’;
Already have we have a database and user account which is made especially for WordPress. We will flush the privileges
mysql> FLUSH PRIVILEGES;
Exit the mysql
# Install additional PHP Extensions
Set up the LAMP stack we require a set of minimum extensions to acquire PHP to communicate with the MySQL. Plugins with additional PHP extensions. Each WordPress plugin has its requirements.
We will install PHP extensions for purpose of WordPress. Commands followed are:
$ sudo apt update
$ sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
We will restart the Apache by following the below commands and we can also install additional plugins,
$ sudo systemctl restart apache2
# Adjust the apache configuration to allow for .htaccess Overrides and Rewrites
So we will make some adjustments to the Apache configuration. Configuration file is required for the site /etc/apache2/sites-available/ directory.
The path /etc/apache2/sites-available/wordpress.conf has to be replaced with the configuration file provided and also in addition as the root directory. The specified root of a web in the configuration.
Note: Here, we see 000.default.conf is used in default configuration with(var/www/html as the root user.
## To enable the .htaccess overrides
So here, .htaccess files are disabled so WordPress plugins use these files in-directory tweaks according to web server behavior apache configuration file of the website:
$ sudo nano /etc/apache2/sites-available/wordpress.conf
The access of the files .htaccess AllowOverride Directive within a directory block in the root. The text to be added in the block as the additional text in the configuration file.this is written in the VirtualHost block.
This file should be saved and closed after the completion.
Enabling the Rewrite module:
Enable is done by mod_rewrite. So we can use permalink of WordPress.
$ sudo a2enmod rewrite
Enabling the changes:
The syntax is written should not have any errors before the implementation of changes.
$ sudo apache2ctl configtest
Output appears the following:
As the above syntax shows the ServerName directive to the main apache. The server name can be server domain or IP address. If syntax ok appears there is no change in the functionality.Restart the Apache for the changes to get implemented and started:
$ sudo systemctl restart apache2
# Download WordPress
Server software is configured. Downloading WordPress is easy and the latest version is more recommended for security reasons of passwords and grant access. First, change to the writable directory and then compress:
$ cd /tmp
$ curl -O https://wordpress.org/latest.tar.gz
Extract the compressed file to create directory:
$ tar xzvf latest.tar.gz
Files are moved to document root. So dummy file access is needed for WordPress to later usage. Therefore file is created.
$ touch /tmp/wordpress/.htaccess
The copy of the sample configuration file to a filename that WordPress reads :
$ cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php
Upgrade is also done for the WordPress regarding the permission issues:
$ mkdir /tmp/wordpress/wp-content/upgrade
The entire content is copied to the document root in the below command the dot is used indicating the completion of everything is in the directory which includes hidden files.
$ sudo cp -a /tmp/wordpress/. /var/www/wordpress
# Configure WordPress directory
Here, we need to setup for some items needed in WordPress directory.
## Adjusting the ownership and permissions
The ownership of all the files are given to www-data user and group.we can say this user runs the Apache web server. Here, Apache will first read and write the WordPress files to change and update the website.
Update the the ownership with clown:
$ sudo chown -R www-data:www-data /var/www/wordpress
Find commands are run to set the permissions correctly on WordPress files.
## Setting up the WordPress configuration file
According to settings the changes are to be done. The directory is provided with the secret keys for the installation purpose.
Wordpress has a secure generator with this it provides the secret codes so that there is confusion in keys while generating it. Secret keys are mainly used internally within the directory.
This link provides us the secret values. The WordPress key generator generates this:
$ curl -s https://api.wordpress.org/secret-key/1.1/salt
Warning: please do not copy these values
Note: unique values for every URL so please do not copy these values from one another.
Open the WordPress configuration file by this command:
$ sudo nano /var/www/wordpress/wp-config.php
So the screen appears like this with the dummy values:
Delete the lines and paste the values from the secret key, the line (put your unique phrase here is to be deleted from every line.
Still, we need to change and modify the database connection settings in the file.this will appear at the start of the file itself. The change follows the database name, the database user, the password associated.
One more change is that the method is to be set that the WordPress need to run with this and filesystem is set “direct”. If this fails then their results in FTP credentials.the screen appears this way:
From the above screen, we need to change database_name_ here to ‘wordpress’,username_here to ‘wordpressuser’,password_here to password.save and close the file. As it is shown below:
# Completion of the interface through the web interface
The configuration of the server is completed and installation of the web interface is done.
So in the web browser, navigate to the server domain name or IP address with this link:
Select the language interested in:
Completion of this will land in the main setup page. Here, select the name of the WordPress site and also choose the username(choose something like ‘admin’. A strong password is needed for security reasons or else select some other alternative password.
Enter the email address and also the search engine visibility if it is needed.
So the click is done then that will be taken to the next page;
If you log in then will reach to the WordPress administration dashboard:
WordPress is installed. Experience and explore the WordPress interface.