These steps will install a local WordPress development environment, including Apache, MySQL, and PHP, so that you can develop WordPress plugins or themes on your local Ubuntu (or other Linux) computer.
This has been tested on Ubuntu 16.04 LTS, Ubuntu 16.10, and Ubuntu 14.04 LTS. This also works on the LXDE light desktop, or Xubuntu, Lubuntu, etc.
All of the commands on this page (except for one) will be typed into the terminal. Open your terminal with
If you have already installed LAMP locally, then skip down to Create a Database for WordPress. (LAMP stands for “Linux, Apache, MySQL, and PHP,” which is a widely used web server software bundle.)
Install the LAMP server stack (Apache, MySQL, and PHP)
During the installation (which runs with the following commands), you will be prompted to enter a password for MySQL. Write it down since you will need it again.
sudo apt-get update sudo apt-get install lamp-server^
Set up MySQL
When it asks you, enter the password which you wrote down above. Then, choose “N” if you don’t want to change your password. Then, choose “Y” for the rest of the questions.
Create a Database for WordPress
mysql -u root -p
When prompted, enter your MySQL password which you created while installing MySQL above.
Create the database. You can change ‘wordpress’ to your desired database name.
CREATE DATABASE wordpress;
Create a database user. You can change ‘wordpressuser’ to your desired username.
CREATE USER wordpressuser@localhost;
Create a password for this user. You can change ‘yourpassword’ to your desired password.
SET PASSWORD FOR wordpressuser@localhost= PASSWORD("yourpassword");
Grant access to the database. Change ‘wordpress’, ‘wordpressuser’, and ‘yourpassword’ accordingly, if you changed them in the previous 3 steps.
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'yourpassword';
Refresh the database:
Move to the local server’s root directory:
Get the latest version of WordPress:
sudo wget https://wordpress.org/latest.tar.gz
Extract WordPress from the package, and create a
sudo tar -xzvf latest.tar.gz sudo cp wordpress/wp-config-sample.php wordpress/wp-config.php sudo rm latest.tar.gz
sudo gedit wordpress/wp-config.php
You can replace “gedit” above with your text editor of choice, for example, “subl” for Sublime Text.
In the opened file, we’re going to paste in the database name, database username, and database password from the “Create a Database for WordPress” step.
- Replace “database_name_here” with your database name. (In the example above, we used “wordpress” as the database name.)
- Replace “username_here” with your database username. (In the example above, we used “wordpressuser” as the username for the database.)
- Replace “password_here” with your database password.
- Save and exit the file.
Move WordPress to the local server’s root directory.
cd ~ sudo rsync -avP /var/www/html/wordpress/ /var/www/html/ sudo rm -rf /var/www/html/wordpress
sudo chown -R www-data:www-data /var/www/html sudo chgrp -R www-data /var/www/html sudo chmod -R 775 /var/www/html
In your browser, go to
localhost/wp-admin/install.php, and complete the WordPress installation steps.
/wp-admin/install.php, and complete the WordPress installation steps.)
That’s it. Now, you can develop and test WordPress themes and plugins in your own local environment, on your own computer, rather than having to upload everything to an online server/hosting account.