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.cnf
    mysql -u debian-sys-maint -p(copy/paste the password from the previous cat output)
    CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'; CREATE DATABASE your_dbname DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci; GRANT ALL PRIVILEGES ON your_dbname.* TO 'username'@'localhost'; FLUSH PRIVILEGES; quit;
  6. sudo apt install php libapache2-mod-php php-mysql php-gd php-xml php-mbstring
  7. 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
  8. Optional: if you want SSL support add this entire block<VirtualHost *:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/wordpress
    SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
    SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
    </VirtualHost>
  9. cd /var/www
  10. sudo curl -O https://wordpress.org/latest.tar.gz
  11. sudo tar xfvz latest.tar.gz
  12. sudo cp wordpress/wp-config-sample.php wordpress/wp-config.php
  13. sudo nano wordpress/wp-config.php
  14. Modify database_name_here, username_here, password_here
  15. sudo chown -R www-data:www-data /var/www/wordpress
  16. 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
  17. If you need to adjust maximum upload filesize and post size for PHP it is found in /etc/php/7.2/apache2/php.ini
    Then change upload_max_filesize and post_max_size
  18. sudo systemctl restart apache2
  19. Done
This entry was posted in Uncategorized. Bookmark the permalink.