close

WordPress is a popular CMS (Content Management System) that is based on PHP and MySQL and provides the most user-friendly environment to develop and manage websites and blogs. It is used by innumerable internet users, as it is a free and open source platform that includes plugins, templates, and support and is trusted to be one of the fastest Webpage performers out there. On the contrary, LAMP (Linux, Apache, MySQL & PHP/Python/Perl) is the open source, server-side software that is stacked to provide all the right web service features to create websites and web applications using WordPress on Linux.

WordPress and LAMP stack assimilates together to provide local development and localhost environment, so you can run your Website or blog on a local server to check if the site is running without any errors before you make it live. Installing WordPress can complicated process if you haven’t set up a LAMP stack on Linux server otherwise it just takes 5 to 10 minutes to install WordPress but don’t worry we will not only guide you on how to install WordPress but also guide you on how to set up a LAMP stack on Ubuntu 18.04 using VPS.

Install and Configure LAMP Stack

Log in to your Ubuntu 18.04 VPS server using the all the right SSH details. Run these two commands to make sure your Ubuntu 18.04 software is fully updated and upgraded.

apt-get update apt-get upgrade 

Step 1: Install Apache Web server

Once you logged in your VPS server root, first you have to install Apache web server, in order to do so, type in the following command:

 apt-get install apache2  

After installing Apache2 server, you now need to enable it to start the server automatically, in order to do so type in the following command and hit Enter:

systemctl enable apache2  

Now you can check if the apache server is active or not in order to do so, type in the following command and hit Enter:

 systemctl status apache  

In the following prompt shown above, you can see that the Apache server is active and running. You may need to hit “Q” key to exit service status.

Step 2: Install and configure MySQL server

In this step you have to install MySQL server to create a database for your test site on Ubuntu 18.04 VPS, in order to do so type in the following command and hit enter:

apt-get install mysql-server  

Now in the confirmation message, enter “Y” to accept the installation.

When MySQL is installed, it is not secured with its default settings, you have to make it protected by answering a series of security questions asked after you enter the command given below:

mysql_secure_installation  

These prompts will perform tasks such as setting up a strong root password, removing anonymous users, disallowing remote root access etc. Just go through all the security task and you’ll be done securing MySQL.

Step 3 Create Database for WordPress

After installing MySQL successfully, you have to create Database for your WordPress site using MySQL server. In order to do so, type in following command and hit enter:

mysql –u root –p  

After entering the command, it will ask you to provide with the root password you set up earlier in the secure installation process. Now enter the password to proceed.

After entering MySQL prompt, type in the following commands to create a database for your WordPress site. In this phase, we have created a database named “osstuff_testblog” and for the user access, we have created a new user named “admin” and set a password in StrongPassword while entering commands. Remember to change the fields with your preferred requirements.

mysql > CREATE DATABASE osstuff_testblog;
mysql > GRANT ALL PRIVILEGES ON wordpress.* TO 'admin_user'@'localhost' IDENTIFIED BY 'StrongPassword';
mysql > FLUSH PRIVILEGES;
mysql > exit;   

Now you have successfully created Database on MySQL server for your WordPress site.

Step 4: Install PHP

Finally, the last step to set up your LAMP stack on your Ubuntu 18.04 VPS. WordPress requires a very minimal set of PHP extensions to communicate it with MySQL server, as PHP can be installed as a whole or only some of its extensions that WordPress requires. To download and install only the required PHP extensions for using WordPress type in the following command and hit enter:

apt install php php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip  

Or to install PHP as a whole, type in following command:

apt-get install php libapache2-mod-php  

Press “Y” and hit enter to accept confirmation message. Both commands will work perfectly but it is recommended to install complete PHP in your Ubuntu 18.04 VPS.

After PHP is successfully installed by entering one of the commands, you will see the following output as shown above.

Install and Configure WordPress

Step 1: Download WordPress

After successful installation of the LAMP stack, we can now install WordPress itself to use it locally. To download and install the WordPress on Ubuntu 18.04 VPS, type in the following commands given below:

cd /var/www/html  

The command above will direct you in the default web server root directory.

wget -c http://wordpress.org/latest.zip  

The command above will get and download the latest WordPress installer zip file from the WordPress official website.

unzip latest.zip  

This command above will unzip the latest zip file that has been downloaded in the selected directory.

chown -R www-data:www-data wordpress  

The command above will copy the files of zip folder and paste them in the wordpress folder created in the directory.

rm latest.zip 

The command above will delete the latest zip downloaded in the directory.

Through above commands, you have successfully created a new folder named “wordpress” in the web server root directory and copied all the latest WordPress file in the folder whose directory is now: /var/www/html/wordpress

Step 2: Modify WordPress Configuration File

Remember when you created a database in “Create Database for WordPress” phase while installing MySQL? Now you have to modify the WordPress Configuration file with the information you prescribed while creating the Database. Just type in following commands to modify the WordPress configuration file.

cd /var/www/html/wordpress 

The command above will direct you to the document directory where wordpress folder is located.

mv wp-config-sample.php wp-config.php  

The command above will move the configuration file to a sample copy.

Now open the WordPress configuration PHP file in a text editor and modify the settings by changing the database_name_here, username_here and password_here with the information you prescribed earlier. Open up a text editor by entering the following command:

nano wp-config.php 

Now change the following information according to your prescribed information, in my case database name was “osstuff_testblog”, the username was admin and password was “anonymous”.

/** The name of the database for WordPress */
define('DB_NAME', 'osstuff_testblog');
 
/** MySQL database username */

define('DB_USER', 'admin');

/** MySQL database password */

define('DB_PASSWORD', 'StrongPassword');

Now simply save and exit the file editor.

Step 3 Create Virtual Host for WordPress

We can create a virtual host file for our domain which will look like (your_domain).com. type in the following command to create the virtual host configuration file: In our case, I will replace your_domain with (Techtalk)

nano /etc/apache2/sites-available/your_domain.com.conf 

Now add the below information into the file. “Remember to change (your_domain) to your preferred name where it appears accordingly”.

<VirtualHost *:80> 

ServerAdmin admin@your_domain.com

ServerName your_domain.com

ServerAlias www.your_domain.com

DocumentRoot /var/www/html/wordpress 

<Directory /var/www/html/wordpress>

Options Indexes FollowSymLinks

AllowOverride All

Require all granted

</Directory> 

ErrorLog ${APACHE_LOG_DIR}/your_domain.com_error.log

CustomLog ${APACHE_LOG_DIR}/your_domain.com_access.log combined

</VirtualHost>

Now enable the virtual host by entering the following command

ln -s /etc/apache2/sites-available/your_domain.com.conf /etc/apache2/sites-enabled/your_domain.com.conf 

Now just save changes and restart the Apache server by running following command:

systemctl restart httpd 

Step 4: Configure WordPress

To configure WordPress open Firefox browser by entering the following command shown below:

firefox &amp; 

This will launch up the browser simply type in the name of the virtual host you created in the address bar. http://your_domain.com/

From the above configuration phase, select the language and click on continue button.

Now simply enter the required information for your website as shown above and then click on the Install WordPress button to proceed.

Now simply click on the Run this installation to install WordPress as shown above.

After successful installation, the setup will show you a success message as shown above. Simply click on the Log In button shown above.

Simply add the username and password as shown above and hit the log in button as shown above.

You have now successfully entered the WordPress dashboard for your site after a successful login, you can now customize your site from here using a LAMP stack as shown above.

That’s it! Hope this article has helped you in how to install WordPress using the LAMP stack in your Ubuntu 18.04. If you have any confusion or faced any difficulty following the instructions please let us know in the comments section below.

Tags : Install WordPress in Ubuntu 18Install Wordpress using LAMP in Ubuntu 18WordPress using LAMP in Ubuntu 18

About Author

EDITORIAL STAFF

EDITORIAL STAFF

Read latest technology news, reviews, how-to guides and other tips & tricks covering Windows, Linux, Mac & Android operating systems prepared by our team.