Now that we have nginx, HHVM and MariaDB installed, we can get into installing Wordpress! Wordpress is a comprehensive blogging platform and content management system (CMS) written in PHP. (This blog runs on Ghost, which is good if you're only blogging.) If you're building a content-driven website, Wordpress is something to consider.
As mentioned in the previous posts, HHVM and nginx gives us a faster-performing PHP webserver, as compared to a default LAMP installation. With some more effort, HHVM and nginx can be tuned even further for better performance, but that's an article for another day.
Wordpress is known for it's ease of installation. First, let's download Wordpress:
cd ~ # Enter into our home directory wget https://wordpress.org/latest.zip # Download the file at the URL
Now, let's unzip the archive.
user@hostname:~$ unzip latest.zip The program 'unzip' is currently not installed. You can install it by typing: sudo apt install unzip
Whoops, the program
unzip is not installed by default! Let's install it. (And since we're at it, install
sudo apt install zip unzip
unzip allow us to archive and unarchive files in the
.zip archive format respectively. To unarchive files, run
user@hostname:~$ ls latest.zip user@hostname:~$ unzip latest.zip Archive: latest.zip creating: wordpress/ inflating: wordpress/wp-settings.php inflating: wordpress/wp-cron.php ... inflating: wordpress/wp-config-sample.php user@hostname:~$ ls latest.zip wordpress
Inside the resulting
wordpress folder, you can see that Wordpress is just a bunch of PHP files.
To install it, simply copy the relevant files into your webroot:
sudo cp -r ~/wordpress/* /var/www/html/
The asterisk in the command is a shell expansion. Shell expansions let us type less. The asterisk in this command tells the shell to search for the files in
~/wordpress/ and replace the
~/wordpress/* with the list of files. This is equivalent to:
cp -r ~/wordpress/index.php ~/wordpress/license.txt ~/wordpress/readme.html ~/wordpress/wp-activate.php ~/wordpress/wp-admin ~/wordpress/wp-blog-header.php ~/wordpress/wp-comments-post.php ~/wordpress/wp-config-sample.php ~/wordpress/wp-content ~/wordpress/wp-cron.php ~/wordpress/wp-includes ~/wordpress/wp-links-opml.php ~/wordpress/wp-load.php ~/wordpress/wp-login.php ~/wordpress/wp-mail.php ~/wordpress/wp-settings.php ~/wordpress/wp-signup.php ~/wordpress/wp-trackback.php ~/wordpress/xmlrpc.php /var/www/html/
The tide symbol is also a shell expansion! It expands to the current user's home directory. For example:
user@hostname:~$ echo ~/hi.txt /home/user/hi.txt
Thus, the above copy command actually expands to:
cp -r /home/user/wordpress/index.php /home/user/wordpress/license.txt /home/user/wordpress/readme.html /home/user/wordpress/wp-activate.php /home/user/wordpress/wp-admin /home/user/wordpress/wp-blog-header.php /home/user/wordpress/wp-comments-post.php /home/user/wordpress/wp-config-sample.php /home/user/wordpress/wp-content /home/user/wordpress/wp-cron.php /home/user/wordpress/wp-includes /home/user/wordpress/wp-links-opml.php /home/user/wordpress/wp-load.php /home/user/wordpress/wp-login.php /home/user/wordpress/wp-mail.php /home/user/wordpress/wp-settings.php /home/user/wordpress/wp-signup.php /home/user/wordpress/wp-trackback.php /home/user/wordpress/xmlrpc.php /var/www/html/
After copying the files, they would be owned by
root (because you used the
sudo command). You need to change the permissions for the files back to
sudo chown -R www-data:www-data /var/www/html/
Now, if you revisit your website, it would have strangely remained unchanged, even though you have a index.php file.
The site is serving up the original index.html file. This means that it's not aware of the index.php file that you want to run. Let's go back and look at the configuration for this site.
sudo nano /etc/nginx/sites-enabled/default
Scroll down to around line 39:
# Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html;
Seems that we did not declare index.php to be sought for when opening the folder! Make the change, save and reload nginx configuration.
# Add index.php to the list if you are using PHP index index.php index.html index.htm index.nginx-debian.html;
sudo systemctl reload nginx
Reload the page again and it will redirect you to the setup page! Awesome!
Right, we almost forgotten to create a database and account for Wordpress to use! Let's log in to MariaDB and do it right now.
CREATE DATABASE wordpress; CREATE USER 'mywordpress'@'localhost' IDENTIFIED BY 'awesome password that is secure'; GRANT ALL PRIVILEGES ON wordpress.* TO 'mywordpress'@'localhost'; FLUSH PRIVILEGES;
You can call the user whatever you wish, and do use a different password. All the SQL queries should run successfully. You can now proceed with the installer
Click on "Run the install", and set up your blog right away!
Fill up your information, remember the password, and click on "Install WordPress". You're done! Visit the admin page (http://localhost/wp-admin/) and log in to the admin panel to get started.