WordPress needs a working LAMP stack. Let start off the installation by setting up a LAMP stack first. It can be done using the following command.
apt-get install lamp-server^
We need a sudo user in Ubuntu for WordPress. Let us create one now.
adduser wordpress gpasswd -a wordpress sudo
We would also need the packages php5-gd and libssh2-php as dependencies. Let’s download these 2 packages as well.
sudo apt-get update sudo apt-get install php-gd php-ssh2
Let us now configure the database for WordPress. We would need to create a database and grant prvileges for a user.
mysql -u root -p
CREATE DATABASE wordpress; CREATE USER wordpressuser@localhost IDENTIFIED BY 'password'; GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost; FLUSH PRIVILEGES; exit
WordPress web application is available in tar.gz or zip format. We will use the tar.gz file here. Let’s download the file and untar it.
wget https://wordpress.org/latest.tar.gz tar xzvf latest.tar.gz
Now let us configure the WordPress application.
The config file for wordpress is present as a sample file named wp-config-sample.php. We will now copy the file to another name i.e. wp-config.php.
cd wordpress cp wp-config-sample.php wp-config.php
We can now edit the following lines with the appropriate values in wp-config.php
define('DB_NAME', 'wordpress'); ... define('DB_USER', 'wordpressuser'); ... define('DB_PASSWORD', 'password');
Let us now transfer the files to the apache root directory i.e. /var/www/html.
rsync -avP ~/wordpress/ /var/www/html
We need to have appropriate ownership for the files in /var/www/html. Let us change that now.
cd /var/www/html chown -R wordpress:www-data * mkdir /var/www/html/wp-content/uploads chown -R :www-data /var/www/html/wp-content/uploads
We need to make the file index.php as the first file for apache to load. We can edit the file ‘/etc/apache2/mods-available/dir.conf’ and change the following line to look like this.
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
Once this is done let us restart Apache service
service apache2 restart
Now we can load wordpress by using the following URL. We need to replace the ‘ip-address’ with appropriate IP of our server.
http://ip-address