WordPress is a free and open source website and blogging tool that uses PHP and MySQL. It was created in 2003 and is now the platform of choice for many new websites.
Obviously you must have the LAMP stack installed before you can do any of this so LAMP Install Tutorial.
Step One – Download WordPress
you can get WordPress straight from WordPress; just enter this command in the terminal
That command will download the zipped wordpress package straight to your home directory. Now to unzip it
tar -xzvf latest.tar.gz
Step Two – Create the WordPress Database and User
If you have phpmyadmin installed you can do this entire step from there, and save yourself some time if you don’t proceed.
After we unzip the wordpress files, there will be a directory called
wordpress in the home directory.
Before we get going, we need to create the MySQL database for wordpress.
first log into the MySQL Shell:
mysql -u root -p
Login using your MySQL root password (The one you set for MySQL while you were installing it), and then we need to create a wordpress database, a user in that database, and give that user a new password. All MySQL commands must end with a semi-colon
First, let’s make the database. You can use whatever databasename, username, and password, you prefer:
CREATE DATABASE wordpress; Query OK, 1 row affected (0.00 sec)
Then we need to create the new user.
CREATE USER wpman@localhost; Query OK, 0 rows affected (0.00 sec)
Set the password for the new user:
SET PASSWORD FOR wpman@localhost= PASSWORD("pass"); Query OK, 0 rows affected (0.00 sec)
Finish up by granting all privileges to the new user. Without this, the wordpress installer will not even start:
GRANT ALL PRIVILEGES ON wordpress.* TO wpman@localhost IDENTIFIED BY 'pass'; Query OK, 0 rows affected (0.00 sec)
Then refresh MySQL:
FLUSH PRIVILEGES; Query OK, 0 rows affected (0.00 sec)
Exist out of the MySQL shell:
Step Three – Setup the WordPress Configuration
The first step is to copy the sample wordpress configuration file, in the wordpress directory, into a new file which we will use as the wordpress config
cp ~/wordpress/wp-config-sample.php ~/wordpress/wp-config.php
Then open the wordpress config file we just created:
sudo nano ~/wordpress/wp-config.php
Find the section containing the fields below and enter the correct name for your database, username, and password
// ** MySQL settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define('DB_NAME', 'wordpress'); /** MySQL database username */ define('DB_USER', 'wpman'); /** MySQL database password */ define('DB_PASSWORD', 'pass');
Save and Exit.
Step Four – Copying the Files
We are on the home stretch now, all that we have to do is copy the wordpress files that are sitting in our home directory, and move the to the website’s root directory.
sudo rsync -avP ~/wordpress/ /var/www/
Then we need to enable a few things
For the wordpress form to work you need to make sure that ~php5-gd~ is installed if it not
sudo apt-get install php5-gd
then we need to allow for Pretty Permalinks (like the one you clicked to view this tutorial)
sudo a2enmod rewrite
after that we need to allow the apache user ownership of the directory
sudo chown -R www-data:username /var/www && sudo chmod -R 755 /var/www
then we need to edit the website configuration file
If you are using the default apache configuration (no virtual hosts), the apache directory rules for the website would be in one of two places,
sudo nano /etc/apache2/sites-enabled/000-default.conf
sudo nano /etc/apache2/apache2.conf
open one of the files and look for:
<Directory /var/www/> Options Indexes FollowSymLinks AllowOverride All Require all granted
AllowOveride None to
AllowOverride All. This is required so that wordpress can use
Save and Close the document.
Finally. Restart Apache
sudo service apache2 restart
Step Five – Access the WordPress Installation
After all that hard work, you can now go ahead to the rest of the wordpress installation.
Reference: Digital Ocean