How To Install Wordpress On Ubuntu 16.04 With LAMP
Wordpress is a powerful blogging platform that has come to be used for content management, e-commerce and more. The steps below detail how to install Wordpress on Ubuntu 16.04 with LAMP.
LAMP stands for Linux, Apache, MySQL and PHP. We will be installing Apache, MySQL and PHP on Ubuntu Linux 16.04. Once these elements are in place, we will then install Wordpress.
How To Install Wordpress On Ubuntu 16.04 With LAMP
1. Connect to your server through SSH using an SSH client, such as puTTY.
2. Login to your server at the SSH prompt, using your OS username and password.
3. Install the apache2 and apache2-utils packages. This installs Apache web server and some add-on programs useful for Apache web server.
user01@srv01:~$ sudo apt-get install apache2 apache2-utils
4. Use the systemctl command to enable the apache2 service to run when the server boots up.
user01@srv01:~$ sudo systemctl enable apache2
5. Use the systemctl command to start apache2 service now.
user01@srv01:~$ sudo systemctl start apache2
6. Navigate to http://your_server_address, where your_server_address is the name (or IP address) of your server. You should see a web page like that shown below.
7. Install MySQL server and MySQL client. The MySQL client will allow you to work with the database from the command line. The mysql-server installation prompts to change the root password, as shown below.
user01@srv01:~$ sudo apt-get install mysql-client mysql-server
8. Various settings in the mySQL database need to configured to be more secure. If you were prompted to set the root password as part of the mysql-server install, say 'n' to resetting the root password. Otherwise, choose 'y' and reset it. Choose 'y' for all the remaining options.
user01@srv01:~$ sudo mysql_secure_installation
9. Install PHP 7. Wordpress is written in PHP and requires PHP to run.
user01@srv01:~$ sudo apt-get install php7.0 php7.0-mysql libapache2-mod-php7.0 php7.0-cli php7.0-cgi php7.0-gd
10. To view what PHP settings we have, run the following command to create a PHP file:
If you are comfortable with editing files with vi, run the command:
user01@srv01:~$ sudo vi /var/www/html/info.php
Otherwise, you may want to try nano:
user01@srv01:~$ sudo nano /var/www/html/info.php
11. Type the following into vi or nano and save the file.
<?php
phpinfo();
?>
12. You can navigate to http://your_server_address/info.php and review the output of the phpinfo() function. It looks like this:
13. Use wget to download the latest version of Wordpress.
user01@srv01:~$ wget -c http://wordpress.org/latest.tar.gz
14. Use tar to extract the tar.gz file.
user01@srv01:~$ tar xzvf latest.tar.gz
15. Use the cp command to copy the files from the newly extracted wordpress directory to the apache2 root directory. The -R tells the command to recursively copy all the directories.
user01@srv01:~$ sudo cp -R wordpress/* /var/www/html
16. The user www-data is an account that was create the apache2 package to own the files that will be served by the Apache web server. Run the chown command below to ensure that www-data owns all the files in the apache2 root directory. The -R again denotes to recursively apply the change to directories.
user01@srv01:~$ sudo chown -R www-data:www-data /var/www/html
17. The command chmod is short for "change mode," and you use it to change the permissions on files and directories.
user01@srv01:~$ sudo chmod -R 755 /var/www/html
18. Connect to the mysql client using the root password we set earlier. This is the same mysql client that was installed earlier as part of the mysql-client package.
user01@srv01:~$ mysql -u root -p
19. Create the mySQL database to house your Wordpress installation. Stick with alphanumeric (A-Z, a-z, 0-9) characters and the underscore (_) for your database name if at all possible. Special characters here will need to be escaped every time the database name is referenced and will be a pain for everyone involved, including you, in the future.
mysql> CREATE DATABASE your_blog_name;
20. Next, create a database user which Wordpress will use to access the database. Best practice dictates that you create a dedicated user for each application. So we will name it wp_dbuser and give it a password that meets your security requirements.
mysql> CREATE USER wp_dbuser IDENTIFIED BY 's5cUr3_p455w0rd';
21. Now, with the database user created, grant it all privileges on your Wordpress database.
mysql> GRANT ALL PRIVILEGES ON your_blog_name.* TO 'wp_dbuser'@'localhost';
22. Use the FLUSH PRIVILEGES command to force the privileges to take effect now.
mysql> FLUSH PRIVILEGES;
23. Type exit to leave the mysql client.
mysql> exit;
24. If you went to http://your_server_address right now, you would likely continue to see the same Apache Ubuntu Default Page we saw before. This is because the default Apache config, when looking for the default page, chooses * before *.php, and so displays the index provided by Apache before the index.php provided by Wordpress. You could delete the index, but we will simply rename it to index.orig.
user01@srv01:~$ sudo mv /var/www/html/index /var/www/html/index.orig
25. Now we are ready to begin the actual Wordpress installation. Open your Web browser and type in http://your_server_address where your_server_address is the URL for your site. You should be prompted with the Wordpress installation asking for your default language, like below. Choose your preferred language and click the "Continue" button.
26. Next, you are welcomed to Wordpress and the installation tells you all the information it will need on the next screen. Click "Let's go!" to continue.
27. When Wordpress can communicate with your database, using the information you provided, you will see a page like this. Click the "Run the installation" button to begin to installation.
28. The next screen will ask you for information about your blog: the blog name, username, password, email address and whether you want search engines to index your site. Fill out the information and click "Install Wordpress."
29. When everything goes as planned, you will see the page below. Click "Log in" to log in, using the password you created on the previous step.
30. This takes you into the Wordpress Dashboard, which is where all your administrative functions are done in Wordpress.
31. If you click the Home Icon at the top of the page, it will take you to your blog. Click on it and take a look. It should look very similar to this.
We hope this article has been helpful in showing you how to install Wordpress on Ubuntu 16.04 with LAMP. Wordpress is a powerful Web application to start a blog and we hope we have shown you how to get it set up for your needs.
Tags :