When I joined WisdmLabs, installing WordPress on Ubuntu was the first thing I had to do. Actually, the first thing I had to do was learn WordPress. And to learn it, I had to try things out, which meant I had to install it.
I was new to WordPress so I had to start by learning the very basics of the installation process. I read through quite a few sources, and compiled my own notes, which I’m presenting to you today as a blog post.
For of you who are in the same position I once was, this is a one stop guide to installing WordPress on Ubuntu.
Windows users worry not. The post- How to Install WordPress on Windows, should help you out.
Let’s begin with understanding the basics. We’ll learn the following:
- What is LAMP and how to install it
- How to create your database, and then,
- How to install WordPress.
What is LAMP?
LAMP (or a LAMP stack) is an open-source software bundle. LAMP is used to build dynamic web content or web applications. LAMP is an acronym for
- Linux- the operating system.
- Apache- the web server which accepts and serves web page requests.
- MySQL- the database management system which stores your website’s content.
- PHP- a server-side scripting language. WordPress is written in PHP. Apache interprets PHP to finally display the web content.
Now with Ubuntu you have Linux. So you need to install Apache, MySQL and PHP.
How to Install LAMP
For security reasons, it is recommended that you begin installation as a non-root user. If you do not have a non-root user account set up, this Ubuntu Initial Server Setup guide will be of help.
We’ll begin by updating our software to the latest versions.
sudo apt-get update
To install Apache use the following command:
sudo apt-get install apache2
Use the below command:
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
During the installation you’ll be asked to set a password for ‘root’ user. This is the root user for your MySQL database management system. Set a password and continue.
Once the installation is complete, you have to run the below command to create the database directory structure:
The last step to installing the LAMP stack is to install PHP.
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt php5-curl php5-gd php5-xmlrpc sudo service apache2 restart
With that we’re done with the default LAMP stack installation. Next, we have to create a database and install WordPress.
How to Create a Database and User
For every site you create you need a database. You already have MySQL installed, login using the root password
mysql -u root -p
Enter the password you had set at the time of MySQL installation to display the MySQL command prompt.
To create the database, use the below command in your MySQL command prompt:
CREATE DATABASE wdmdb;
It is recommended not to access the database using the MySQL root user. Hence we’ll be creating a new user (set your own username and password) and granting the user access to the database using the below commands:
CREATE USER wpuser@localhost IDENTIFIED BY 'pwd'; GRANT ALL PRIVILEGES ON wdmdb.* TO [email protected];
These commands should be followed by FLUSH PRIVILEGES to ensure that the changes are registered and then you can EXIT the MySQL command prompt.
Your database is now ready for your website, so you can now finally install WordPress 🙂
How to Install WordPress on LAMP?
Use the below commands to download the latest version of WordPress inside /www directory.
cd /var/www sudo wget http://wordpress.org/latest.tar.gz sudo tar -xzvf latest.tar.gz
Now in a browser open http://localhost/wordpress.
- Select your language of choice and click on ‘Continue’
- Next you’ll have to enter your database and user details to create the wp-config file. Click on ‘Let’s Go‘ and then enter the details- Database Name (wdmdb), User Name (wpuser), Password (pwd). The Database Host should be localhost. It is recommended to change the Table Prefix to other than wp_.
- Then click on ‘Submit‘ and then ‘Run the Install‘.
- Next, on the Welcome screen, add a site title, the admin username and password, your email address (uncheck ‘Allow search engines to index this site’ since it’s a local site) and click on ‘Install WordPress’.
- Success! Once you’re greeted by the ‘Success’ screen you’re good to go! WordPress has been successfully installed. You can login to your site by clicking on ‘Login‘, and entering your newly created admin username and password.
You can now explore the dashboard settings, customize your site by installing a new theme or by adding the plugins you need. 🙂
Found this post helpful? Share your thoughts in the comment section below.