In order for WordPress to work you must have your LAMP server already installed and working.
Please verify your domain name is working and pointing to your apache server and you have SSL working (if required) before proceeding with the WordPress installation.
Verify mod rewrite is enabled on apache
$ sudo a2enmod rewrite
$ sudo service apache2 restart
Login to mysql and create a database and user
$ mysql -u root -p
$ CREATE DATABASE wpdatabase;
$ GRANT ALL ON wpdatabase.* TO 'wpuser'@'localhost' IDENTIFIED BY 'password';
$ FLUSH PRIVILEGES;
$ EXIT
Grab the latest WordPress version from there website and extract it.
$ cd ~
$ curl -O https://wordpress.org/latest.tar.gz
$ sudo tar xzvf latest.tar.gz
You will now see a “WordPress” directory, go inside, copy the wp-config-sample.php and edit it with the correct info.
$ cd wordpress
$ cp wp-config-sample.php wp-config.php
$ sudo nano wp-config.php
Grab secure values from wordpress and copy the output to your clipboard
$ curl -s https://api.wordpress.org/secret-key/1.1/salt/
Find these lines in the ~/wordpress/wp-config.php file and overwrite them with the secure keys you just copied.
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');
In addition to the above you will want to edit these lines with the info you created in mysql.
define('DB_NAME', 'wpdatabase'); /** MySQL database username */ define('DB_USER', 'wpuser'); /** MySQL database password */ define('DB_PASSWORD', 'password');
Now add the following line below the password line
define('FS_METHOD', 'direct');
You can now move the wordpress directory contents to their permanent location.
$ sudo cp -a ~/wordpress/. /var/www/html/example.com
The last thing to do is to secure the wordpress directories
$ cd /var/www/
$ sudo chown -R root:www-data example.com
$ sudo find example.com -type d -exec chmod g+s {} \;
$ sudo chmod g+w example.com/wp-content
$ cd example.com/wp-content
$ sudo chmod -R g+w themes
$ sudo chmod -R g+w plugins
Go ahead and browse to your website now and you should be greeted with the wordpress setup screen.