Wordpress - How to Install Wordpress on Ubuntu 16.04

## Prerequisites

First, we must make sure you have the LAMP portion of this server up and running. Since we're using Ubuntu as a foundation, we can install the entire LAMP stack with a single command. Open a terminal window and issue the following commands:

```
sudo apt-get update && apt-get upgrade
​sudo apt-get install lamp-server^

```

The above commands will install all of the necessary components for your LAMP server. During the installation, you may be prompted to create and verify a password for the MySQL administrator. If you installed your Ubuntu Server to include the MySQL functionality, chances are you set that administrator password during the operating system installation.

Next we must install the necessary PHP modules. Go back to your terminal window and issue the following command:

```
sudo apt-get install php7.0 php7.0-mysql libapache2-mod-php7.0 php7.0-cli php7.0-cgi php7.0-gd

```

We now must test to ensure that PHP is working properly by creating a test file. Issue the command *sudo nano /var/www/html/info.php* and copy the following content into the file:

```
<?php
​phpinfo();
​?>

```

With that file in place, point a browser to http://IP\_OF\_SERVER/info.php. You should be greeted by the PHP information screen

## Create the WordPress database

Before moving onto the installation of WordPress, we must first create the necessary database. From the terminal window, issue the command *mysql -u root -p*. **Note:** If you designated a specific user to serve as the MySQL administrator, you will replace root with that user. Once you're on the MySQL prompt, issue the following commands to create the database (USERNAME is the MySQL admin user, and ADMIN\_PASSWORD is the password associated with that user):

```
CREATE DATABASE wpdb;
​GRANT ALL PRIVILEGES ON wpdb.* TO 'USERNAME'@'localhost' IDENTIFIED BY 'ADMIN_PASSWORD';
​FLUSH PRIVILEGES;
​EXIT;

```

## Download and install WordPress

We're ready to download and unpack the WordPress file. Back at your terminal window, issue the following commands:

```
wget -c http://wordpress.org/latest.tar.gz
​​tar -xzvf latest.tar.gz

```

I assume you are installing WordPress on a LAMP server that will also host other services. To that end, we'll move the entire wordpress folder to */var/www/html* with the command:

```
sudo mv wordpress /var/www/html

```

Next we must give the wordpress folder the proper permissions with the commands:

```
sudo chown -R www-data:www-data /var/www/html/wordpress
​sudo chmod -R 755 /var/www/html/wordpress

```

For our next trick, we'll rename the WordPress configuration file and modify it to fit our setup. Rename the *wp-config-sample.php* file with the commands:

```
cd /var/www/html/wordpress
​sudo mv wp-config-sample.php wp-config.php

```

Open the file up for editing with the command *sudo nano wp-config.php* and locate the MySQL settings section

Change the *database\_name\_here*, *username\_here*, and *password\_here* options to reflect your MySQL installation and the WordPress database we created earlier. Save and close that file.

Restart the Apache and MySQL servers with the commands:

```
sudo systemctl restart apache2.service
​sudo systemctl restart mysql.service

```

Now point a web browser to http://IP\_OF\_SERVER/wordpress and finish the installation via the browser-based wizard. To finalize the installation, select the language for the site, set the site title, add an admin user and password (password must be a minimum of WEAK for the installation to continue), and click Install WordPress

The installation is complete, and you can log in with your admin credentials to start building your site.

## WordPress is ready to serve

WordPress is so much more than a blogging platform—after you install it, head over to the WordPress plugin repository to see just how much more you can make this platform do. You'll be surprised to find that WordPress can fill many a need.

Source: https://www.techrepublic.com/article/how-to-install-wordpress-on-ubuntu-16-04/