Installation of WordPress

Install WordPress on LAMP stack

As per 2020, WordPress is the world’s most popular content management system powering 34% of all websites on the internet.

On top of that:

  • WordPress has a 60.8% market share in the CMS market
  • WordPress powers 14.7% of the world’s top websites
  • 500+ sites are built each day using WordPress while only 60-80 per day are built on platform like Shopify and Squarespace
  • The WordPress Plugin Directory features 55,000+ plugins
  • WooCommerce powers 22% of the top 1 million ecommerce sites in the world

After setting up wordpress you can almost exclusively configure administrator settings from the front end web-face.

If you need to setup a LAMP stack please view my tutorial: Install LAMP Stack

In the above tutorial you should have:

  • Created a sudo account
  • Installed LAMP stack

Let’s dive in:

SSH into your server using Putty.

WordPress uses MySQL to manage and store site and user information. We need to make a database and user for WordPress to use:

Login to MySQL administrative account:

$ mysql -u root -p

Input the password you created in the LAMP stack tutorial.

We will create a separate database for WordPress to control You can call this whatever you would like, but we will be using wordpress in this guide to keep it simple. Create the database for WordPress by typing:

mysql> CREATE DATABASE wordpress DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

Now let’s make a user account that will be used exclusively to operate the new database. Creating one-function databases is a good idea from a management and security stand-point.

We will use wordpressuser here, use whatever you would like.

Let’s 1. create the account | 2. set a password | 3. grant access to the database we created

mysql> GRANT ALL ON wordpress.* TO wordpressuser@‘localhost’ IDENTIFIED BY password;

We now have a database and user account specific to our wordpress server.

Let’s restart MySQL:



mysql> EXIT;

Installing Additional PHP Extensions:

PlugIns are an important part of WordPress lets install the most popular PHP extensions for use with WordPress:

$ sudo apt update

$ sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip

Restart Apache2.

$ sudo systemctl restart apache2

.htaccess Overrides and Rewrites:

The .htaccess file is important for WordPress to have the appropriate permissions to write and rewrite to your server.

If you followed the Installation of LAMP Stack Ubuntu tutorial you should have the configuration setup for your site already.

We’ll use /etc/apache2/sites-available/PLACEHOLDER.conf as an example here, but you should substitute the path to your configuration file where appropriate. Also, our root directory used here will be /var/www/PLACEHOLDER you should specify your own configuration.

Enable .htaccess Overrides

Open Apache2 configuration:

$ sudo nano /etc/apache2/sites-available/PLACEHOLDER.conf

To enable .htaccess files we need to set the AllowOverride directive in the directory block pointing to our document root, this goes within the VirtualHost block:

<Directory /var/www/PLACEHOLDER/>
    AllowOverride All

Ctl+X to exit and save file.

Enable rewrite module

we can enable mod_rewrite so that we can utilize the WordPress permalink feature:

$ sudo a2enmod rewrite

Configuration test to see if we made syntax errors:

$ sudo apache2ctl configtest

Look for “Syntax OK”

Restart Apache2:

$ sudo systemctl restart apache2

Download WordPress

Our server is configured and it’s time to download WordPress. Let’s get the latest version.

We will change into a writable directory and download the release:

$ cd /tmp

$ curl -O

Extract the compressed file to create the WordPress directory structure:

$ tar xzvf latest.tar.gz

Create a .htaccess file so that this will be available for WordPress later:

$ touch /tmp/wordpress/.htaccess

Copy configuration file to the filename that WordPress reads:

$ cp /tmp/wordpress/wp-config-sample.php /tmp/wordpress/wp-config.php

Create an upgrade directory so that WordPress won’t have permission issues when trying to update it’s software in the future:

$ mkdir /tmp/wordpress/wp-content/upgrade

Now copy the entire contents of the directory into our document root. use a “.” at the end of our source directory to include all contents.

$ sudo cp -a /tmp/wordpress/. /var/www/wordpress

Configure WordPress Directory

Adjust the Ownership and Permissions

Reasonable file permissions and ownership:

Let’s start by giving ownership of all the files to the www-data user and group. This is the user that the Apache webserver runs as, and Apache will need to be able to read and write WordPress files in order to serve the website and perform updates.

Use chown:

$ sudo chown -R www-data:www-data /var/www/PLACEHOLDER

Run two find commands to set permissions on WordPress Directories and Files:

$ sudo find /var/www/wordpress/ -type d -exec chmod 750 {} \;

$ sudo find /var/www/wordpress/ -type f -exec chmod 640 {} \;

Setup WordPress Config File

Secrete keys provide security to our installation. WordPress provides a secure generator for these values – Copy them.

Let’s grab secure values from the WordPress secret key generator:

$ curl -s

you will get something that looks like:


define(‘AUTH_KEY’, ‘ DO NOT COPY THESE VALUES LvX3|H =}T{t|v)A;> k)1GXC;9J-!|Y7Wm@sVFz*$kA/%&St*fXW$gU|BXDNdefine(‘SECURE_AUTH_KEY’, ‘DO NOT COPY THESE VALUES-kj8r{dFaln4}CO7-.^CEje.aWMR5Y*<t(-Z)|+?BS&iU#zB<4Y:OvA_0E@@xINb’);
define(‘LOGGED_IN_KEY’, ‘DO NOT COPY THESE VALUESk|t>IbbL;/K:=ga/U0de2@|P[@~=}^{#RFXt/&Lukw&W;sQDRpEWuwJFJJcPyY5%’);
define(‘NONCE_KEY’, ‘DO NOT COPY THESE VALUESZ[ULKlQ}sc E4^*RA1nsisigIt3<nRKk}Ax7+shAOaQ%1FPegf>~-#gogX{R /VW’);
define(‘AUTH_SALT’, ‘DO NOT COPY THESE VALUESv?ah[OjN{I<p$G<j:(-jdGk|`zpaO9;E9iwt4$l|J?KP+lEx>WfAfZmM}BxxS%<J’);
define(‘SECURE_AUTH_SALT’, ‘DO NOT COPY THESE VALUES{+z#cwpws{(+g0h3cJ/OrbW~-@w~!GX;!s(:~$TB[#g-gN~m{;?g-|vmRuM:E5o6′);
define(‘LOGGED_IN_SALT’, ‘DO NOT COPY THESE VALUESTFjy+L: V><_|r80oiz&YT4XiF]ujlE!9[#PGUwI4,1hD:au:?{R0M+qc-e&2I5~’);
define(‘NONCE_SALT’, ‘DO NOT COPY THESE VALUES9~?%2EwB|@I4=$t>Uut}+|:T)yw$bW|2`eH}?fz>_KA-u-@:.$5-/m)3b?e<5[+S’);

We need to place these values in our configuration file to set secure keys – COPY YOUR OUTPUT.

Let’s open the WordPress Configuration file:

$ sudo nano /var/www/PLACEHOLDER/wp-config.php

Find the section that contains the values for those settings:

define('AUTH_KEY',         'put your unique phrase here');
define('SECURE_AUTH_KEY',  'put your unique phrase here');
define('LOGGED_IN_KEY',    'put your unique phrase here');
define('NONCE_KEY',        'put your unique phrase here');
define('AUTH_SALT',        'put your unique phrase here');
define('SECURE_AUTH_SALT', 'put your unique phrase here');
define('LOGGED_IN_SALT',   'put your unique phrase here');
define('NONCE_SALT',       'put your unique phrase here');

Delete the text in the single quotes ‘put your unique phrase here’ paste the values your generated above. Be careful of formatting.

Now we need to modify database connection settings at the beginning of that same file.

Adjust the database name, database user and associated password we previously configured.

The other change we will make is the method that WordPress will use to write into the filesystem. By setting the filesystem to “direct” the webserver will write where it needs to.

define('DB_NAME', 'wordpress');

/** MySQL database username */
define('DB_USER', 'wordpressuser');

/** MySQL database password */
define('DB_PASSWORD', 'password');
define('FS_METHOD', 'direct');

Save the file.

Complete the installation through the Web Interface


WordPress is Installed!

By Published On: January 19th, 2016Categories: software, Technology, Tutorial, WordpressViews: 90701281 words

Spread the knowledge!


Subscribe to our free newsletter.

Related Posts

View all
  • Musings of a Project Manager 1

    Continue reading
  • Okangan College Professorship Pt. 1

    Continue reading
  • Migrate WordPress server to another server;

    Continue reading
  • Let’s Encrypt Ubunutu

    Continue reading