How to Install Wordpress on Linux
1. Ensure You Have a LAMP Stack Configured (Linux, Apache, MySQL, PHP)
If you aren't sure if you have Apache, MySQL, and PHP on your system, verifying this is pretty easy.
$ which apache2
$ which httpd
You should get the directory that contains the Apache executable:
If nothing is printed to the terminal, this means that Apache is not installed.
Follow this guide to get a LAMP stack set up on your computer.
2. Download & Extract Wordpress
Once you have verified that your LAMP stack is configured and working properly, you can proceed to download Wordpress.
$ cd /var/www/html $ sudo wget https://wordpress.org/latest.tar.gz $ sudo tar -xf latest.tar.gz
3. Create a New MySQL User & Database for Wordpress
Log in to MySQL with the root user, using the password you set in your MySQL install.
(If you have forgotten it, follow this guide.)
$ mysql -u root -p
mysql> CREATE DATABASE newdatabase; mysql> CREATE USER 'newuser' IDENTIFIED BY 'newpassword'; mysql> GRANT ALL PRIVILEGES ON newdatabase.* to 'newuser'; mysql> FLUSH PRIVILEGES; mysql> quit
You should create your own user name, and set a secure password, especially if this is not a local install.
4. Give Wordpress Proper Permissions
In order for Wordpress to run the installation (and to later upload content), you must give Apache write permissions to the directory Wordpress is in.
$ cd /var/www/html $ sudo chown -R www-data:www-data wordpress/
$ cd /var/www/html $ sudo chown -R apache:apache wordpress/
If you saved wordpress in a different directory, be sure to use that name instead in the above commands.
5. Install Wordpress
Enter the Database Name, User, and Password that you configured earlier.
If all went well, you will see a page with a button that says "Run the Install".
If you get an error that reads "Cannot Connect to the Database":
1) You have either entered the wrong information for the database & user, or
2) That user doesn't have privileges to the database.
In that case, go back to Step 3 and check that you have followed the steps correctly.
If you get a page reading that Wordpress is unable to create the wp-config.php file, this means Wordpress does not have write permissions to the directory.
Ensure you have completed Step 4 above.
It should be noted that in some VPS setups, the public html folder is not
In this case, the owner and group should be set to the owner of this directory.
If everything was completed successfully, you will see the following page:
You can now set the Site Title, Wordpress Username & Password.
You're done! If all of the steps have been followed, you should now have Wordpress configured on your server.
If you do encounter any errors not covered here, as always, Google that shit!
I have been tinkering with Linux and coding for many years. It is extremely rare that I run into a problem I can't find an answer to.
It can be frustrating at times, but if you dig deep enough, you can always solve the problem.
(And learn something new at the same time! Yay!)
Thanks for reading!