How to Install Latest WordPress on Ubuntu Server 18.04

These are the minimum steps I needed to get WordPress running on Ubuntu Server 18.04. It is based on the below guide at the time of this writing:

How to install WordPress

 

  1. During the install and setup of Ubuntu Server 18.04, the only option I chose beyond the defaults was to install Open SSH server but is not required depending on your needs.
  2. sudo apt install apache2
  3. Optional: if you want SSL support
    sudo a2enmod ssl
  4. sudo apt install mysql-server
  5. Set up a MySQL user and database for WordPress to use by using the debian-sys-maint user:sudo cat /etc/mysql/debian.cnfmysql -u debian-sys-maint -p(copy/paste the password from the previous cat output)CREATE USER ‘username’@’localhost’ IDENTIFIED BY ‘password’;CREATE DATABASE dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci;

    GRANT ALL PRIVILEGES ON dbname.* TO ‘username’@’localhost’;

  6. quit
  7. sudo apt install php libapache2-mod-php php-mysql php-gd php-xml php-mbstring
  8. By default apache will look at /var/www/html location for your WordPress install, but you can modify it with these steps
    sudo nano /etc/apache2/sites-enabled/000-default.conf
    in this example we will change DocumentRoot line to be /var/www/wordpress
  9. Optional: if you want SSL support add this entire block<VirtualHost *:443>
    ServerAdmin [email protected]
    DocumentRoot /var/www/wordpress
    SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
    </VirtualHost>
  10. cd /var/www
  11. sudo curl -O https://wordpress.org/latest.tar.gz
  12. sudo tar xfvz latest.tar.gz
  13. sudo cp wordpress/wp-config-sample.php wordpress/wp-config.php
  14. sudo nano wordpress/wp-config.php
  15. Modify database_name_here, username_here, password_here
  16. sudo chown -R www-data:www-data /var/www/wordpress
  17. Allow .htaccess permissions in Apache2 (otherwise changing the Permalinks settings in WordPress will result in 404 errors, as well as plugins that rely on subfolders to serve content).sudo nano /etc/apache2/apache2.conf
    Find the section where Directory parameters are specified and add the following block:
    <Directory /var/www/wordpress/>
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    </Directory>sudo a2enmod rewrite
  18. sudo systemctl restart apache2
  19. Done
This entry was posted in Uncategorized. Bookmark the permalink.