Ubuntu 16.04: Install Joomla

This article will describe installing Joomla which is a content management system.

1 Install Joomla

  • This article uses default SSL/TLS certicication file for https. Please change your SSL/TLS certification file.
  • If you use http instead of https, change 443 to 80 and delete SSLXXX directive in /etc/apache2/sites-available/joomla.conf.
  • JOOMLA_PASSWD is password of joomla user in MySQL.
#!/bin/sh

set -e

MYSQL_VERSION=5.7
[ -z "${MYSQL_PASSWD}" ] && \
  MYSQL_PASSWD=mysql
[ -z "${JOOMLA_PASSWD}" ] && \
  JOOMLA_PASSWD=joomla
[ -z "${PHPMYADMIN_PASSWD}" ] && \
  PHPMYADMIN_PASSWD=phpmyadmin

ubuntu_install_mysql()
{
  cat <<EOF | sudo debconf-set-selections
mysql-server-${MYSQL_VERSION} mysql-server/root_password password ${MYSQL_PASSWD}
mysql-server-${MYSQL_VERSION} mysql-server/root_password_again password ${MYSQL_PASSWD}
EOF
  sudo apt install -y mysql-server

  cat<<EOF | sudo mysql -uroot -p${MYSQL_PASSWD}
grant all privileges on joomla.* to joomla@localhost
  identified by '${JOOMLA_PASSWD}';
flush privileges;
exit
EOF
}

ubuntu_install_phpmyadmin()
{
  cat <<EOF | sudo debconf-set-selections
phpmyadmin phpmyadmin/reconfigure-webserver multiselect apache2
phpmyadmin phpmyadmin/dbconfig-install boolean true
phpmyadmin phpmyadmin/mysql/admin-pass password ${MYSQL_PASSWD}
phpmyadmin phpmyadmin/mysql/app-pass password ${PHPMYADMIN_PASSWD}
phpmyadmin phpmyadmin/app-password-confirm password ${PHPMYADMIN_PASSWD}
phpmyadmin phpmyadmin/setup-username string admin
phpmyadmin phpmyadmin/setup-password password ${PHPMYADMIN_PASSWD}
EOF
  sudo apt install -y phpmyadmin
}

ubuntu_install_joomla()
{
  sudo apt-get install -y php-mysql php-json php-curl
  JOOMLA3=https://downloads.joomla.org/cms/joomla3

  wget -q ${JOOMLA3}/3-7-2/Joomla_3-7.2-Stable-Full_Package.tar.bz2
  sudo mkdir -p /var/www/joomla
  sudo tar jxf Joomla_3-7.2-Stable-Full_Package.tar.bz2 -C /var/www/joomla
  rm -f Joomla_3-7.2-Stable-Full_Package.tar.bz2
}

ubuntu_install_apache()
{
  sudo apt install -y apache2 libapache2-mod-php

  sudo chown -R www-data:root /var/www/joomla

  cat <<EOF | sudo tee /etc/apache2/sites-available/joomla.conf
<VirtualHost _default_:443>
  SSLEngine on
  SSLCertificateFile    /etc/ssl/certs/ssl-cert-snakeoil.pem
  SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

  Alias /joomla /var/www/joomla

  <Directory /var/www/joomla>
    Options FollowSymLinks
    Require all granted
  </Directory>
</VirtualHost>
EOF
  sudo a2enmod ssl
  sudo a2enmod php7.0
  sudo a2ensite joomla
  sudo systemctl enable apache2
  sudo systemctl restart apache2
}

ubuntu_main()
{
  ubuntu_install_mysql
  ubuntu_install_phpmyadmin
  ubuntu_install_joomla
  ubuntu_install_apache
}

ubuntu_main

2 Access to Joomla

Access to the following URL and setup Joomla. Username of database is joomla and password of database is JOOMLA_PASSWD value.

https://<server>/joomla