How do you install WordPress on Ubuntu 16.10 with support for Apache2, MariaDB and PHP7? Can you provide step by step guide to installing WordPress and LAMP support on Ubuntu?
This post shows you how to install WordPress on Ubuntu 16.10 with support for Apache2, MariaDB and PHP7. This step by step guide can be used by students or new users to install WordPress with ease.
We make our tutorials as simple as possible so new users can feel comfortable dealing with complicated tasks. When you’re done with this tutorial, you’ll be able to install WordPress easily and be ready to manage a WordPress blog.
As you may already know, WordPress will not function without the LAMP stack. The stack is a collection of open source software that powers majority of the websites online today. With the LAMP stack, you’ll be able to run dynamic PHP applications.
LAMP is a acronym for Linux, Apache2 MySQL or MariaDB and PHP. We already have our Linux system (Ubuntu) so our next step is to install and configure the other components of LAMP.
First update the Ubuntu server by running the commands below:
sudo apt-get update
Then continue below with installing Apache2, MariaDB and PHP
Step 1: Installing Apache2 Webserver
Apache2 or another webserver is required for WordPress to function. WordPress won’t function without it. To install Apache2, run the commands below.
sudo apt-get install apache2
When you run the commands above, you’ll see a lists of packages that will be installed as shown below:
# sudo apt-get install apache2 Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-4.8.0-22 linux-headers-4.8.0-22-generic linux-image-4.8.0-22-generic linux-image-extra-4.8.0-22-generic Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 Suggested packages: apache2-doc apache2-suexec-pristine | apache2-suexec-custom The following NEW packages will be installed: apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.1-0 0 upgraded, 9 newly installed, 0 to remove and 26 not upgraded. Need to get 1,536 kB of archives. After this operation, 6,349 kB of additional disk space will be used. Do you want to continue? [Y/n] Y
After Apache2 is installed, run the commands below to enable Apache2 to automatically startup everytime your server starts
sudo systemctl enable apache2.service
Step 2: Installing MariaDB Database server
The next step is to install MariaDB database server. WordPress uses database servers to store its content. MariaDB is a drop-in replacement for MySQL database server.
To instal MariaDB, run the commands below.
sudo apt-get install mariadb-server mariadb-client
When you run the above commands, you’ll also be prompted to confirm all the packages that are about to be installed. Type Y for yes and continue:
sudo apt-get install mariadb-server mariadb-client Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: linux-headers-4.8.0-22 linux-headers-4.8.0-22-generic linux-image-4.8.0-22-generic linux-image-extra-4.8.0-22-generic Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient20 libreadline5 libterm-readkey-perl mariadb-client-10.0 mariadb-client-core-10.0 mariadb-common mariadb-server-10.0 mariadb-server-core-10.0 mysql-common Suggested packages: libmldbm-perl libnet-daemon-perl libsql-statement-perl libipc-sharedcache-perl mailx mariadb-test tinyca The following NEW packages will be installed: libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient20 libreadline5 libterm-readkey-perl mariadb-client mariadb-client-10.0 mariadb-client-core-10.0 mariadb-common mariadb-server mariadb-server-10.0 mariadb-server-core-10.0 mysql-common 0 upgraded, 15 newly installed, 0 to remove and 26 not upgraded. Need to get 16.7 MB of archives. After this operation, 150 MB of additional disk space will be used. Do you want to continue? [Y/n] Y
After installing the database server, run the commands below to enable the server to automatically startup everytime your server starts.
sudo systemctl enable mysql.service
Next, run the commands below to secure MariaDB database server. This will allow you to set the root password, remove the test database as well as disallow root login from remote locations.
Running the commands above will display series of prompts. Answer as shown below:
sudo mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist ... Failed! Not critical, keep moving... - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure.
Step 3: Installing PHP7 on Ubuntu
The final task to complete LAMP installation and configuration is to install PHP. Again, WordPress depends on PHP and other PHP modules. To install required PHP modules that will allow WordPress to function properly, run the commands below:
sudo apt-get install php7.0 libapache2-mod-php7.0 php7.0-mysql php7.0-curl php7.0-gd php7.0-imagick php7.0-imap php7.0-mcrypt php7.0-recode php7.0-tidy php7.0-xmlrpc
The commands above show you packages that will be installed and upgraded. Type Y for yes to confirm and continue with the installation.
Reading package lists... Done Building dependency tree Reading state information... Done Note, selecting 'php-imagick' instead of 'php7.0-imagick' The following packages were automatically installed and are no longer required: linux-headers-4.8.0-22 linux-headers-4.8.0-22-generic linux-image-4.8.0-22-generic linux-image-extra-4.8.0-22-generic Use 'sudo apt autoremove' to remove them. The following additional packages will be installed: libc-client2007e libmcrypt4 librecode0 libtidy5 libxmlrpc-epi0 mlock php-common php7.0-cli php7.0-common php7.0-json php7.0-opcache php7.0-readline ttf-dejavu-core Suggested packages: php-pear uw-mailutils libmcrypt-dev mcrypt The following NEW packages will be installed: libapache2-mod-php7.0 libc-client2007e libmcrypt4 librecode0 libtidy5 libxmlrpc-epi0 mlock php-common php-imagick php7.0 php7.0-cli php7.0-common php7.0-curl php7.0-gd php7.0-imap php7.0-json php7.0-mcrypt php7.0-mysql php7.0-opcache php7.0-readline php7.0-recode php7.0-tidy php7.0-xmlrpc ttf-dejavu-core 0 upgraded, 24 newly installed, 0 to remove and 26 not upgraded. Need to get 5,178 kB of archives. After this operation, 20.1 MB of additional disk space will be used. Do you want to continue? [Y/n] Y
At this point, the LAMP stack is complete. Your Ubuntu systems is ready to host WordPress.
Step 4: Create a MariaDB database for WordPress
Now that you’ve installed MariaDB database, the next step is to create the database WordPress will use to store its content. To do that, use the guide below.
Logon to the server. When prompted for password, type the password you created earlier.
mysql -u root -p
Create a database called wpdb. The database can be called anything you like.
CREATE DATABASE wpdb;
Create a user account called wpuser for the database. This account will have the necessary rights to store, retrieve and manage WordPress content.
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'type_new_password';
Grant the new account all rights to manage the database you just created.
GRANT ALL ON wpdb.* TO wpuser@localhost;
Finally, run the commands to flush and save your changes.
FLUSH PRIVILEGES; exit
Step 5: Downloading and Configuring WordPress content
The next step is to download and configure WordPress content. Follow the steps below to get that done.
cd /tmp/ && wget http://wordpress.org/latest.tar.gz
Next, extract the downloaded content by running the commands below.
tar -xvzf latest.tar.gz
After extracting WordPress’ content, the first thing you’ll want to do is delete Apache2 default file in its root directory.
sudo rm /var/www/html/index.html
Next, move WordPress content to Apache2’s root directory by running the commands below.
sudo mv wordpress/* /var/www/html/
After moving WordPress content to its root directory, use the command below to make a copy of wp-config-sample.php file and name it wp-config.php.
The wp-config.php is the default configuration file for WordPress in its root folder.
sudo cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
Next, edit wp-config.php file and make the below changes.
sudo nano /var/www/html/wp-config.php
// ** MySQL settings – You can get this info from your web host ** //
/** The name of the database for WordPress */
/** MySQL database username */
/** MySQL database password */
Save your changes when done.
Finally, run the commands below to set the correct files and folders permissions for WordPress to function properly.
sudo chown -R www-data:www-data /var/www/html sudo chmod -R 755 /var/www/html/
After all of the above, restart Apache2 web server.
sudo systemctl restart apache2
When you’re done, open your web browser and navigate to the server IP or hostname and you’ll be greeted with WordPress site installation as show below. Continue with the setup until you’re done.
That’s how to install WordPress with support for Apache2, MariaDB and PHP 7.