ArchLinux 2017.10.01: CMSのJoomlaをインストールする

コンテンツマネージメントシステムのJoomlaをインストールする手順を記載します。

1 Joomlaをインストールする

以下のスクリプトはWordPressをインストールします。

  • MYSQL_PASSWDはMySQLのrootユーザのパスワードです。
#!/bin/sh

set -e

[ -z "${MYSQL_PASSWD}" ] && MYSQL_PASSWD=mysql

mysql_install()
{
  sudo pacman -Sy --noconfirm mariadb

  # Install database.
  sudo mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql

  sudo systemctl enable mariadb
  sudo systemctl start mariadb

  # Password configuration.
  cat <<EOF | sudo mysql_secure_installation

y
${MYSQL_PASSWD}
${MYSQL_PASSWD}
n
y
y
y
EOF
}

php_install()
{
  # Enable PHP extension.
  sudo pacman -Sy --noconfirm php php-mcrypt
  sudo sed -i /etc/php/php.ini \
       -e 's/^;extension=pdo_mysql.so/extension=pdo_mysql.so/g' \
       -e 's/^;extension=mysqli.so/extension=mysqli.so/g' \
       -e 's/^;extension=mcrypt.so/extension=mcrypt.so/g'
}

joomla_install()
{
  sudo pacman -Sy --noconfirm git base-devel
  git clone https://aur.archlinux.org/joomla.git
  cd joomla
  makepkg -s --noconfirm
  sudo pacman -U --noconfirm ./*.pkg.tar.xz
  cd ..
  sudo chown http:http -R /usr/share/webapps/joomla
}

apache_install()
{
  sudo pacman -Sy --noconfirm apache php-apache
  sudo systemctl enable httpd

  # php configuration.
  sudo sed -i /etc/httpd/conf/httpd.conf \
       -e 's/^LoadModule mpm_event_module/#LoadModule mpm_event_module/g' \
       -e 's/^#LoadModule mpm_prefork_module/LoadModule mpm_prefork_module/g'
  cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf
LoadModule php7_module modules/libphp7.so
AddHandler php7-script php
Include conf/extra/php7_module.conf
EOF

  # ssl configuration.
  # Country Name (2 letter code) [AU]:
  # State or Province Name (full name) [Some-State]:
  # Locality Name (eg, city) []:
  # Organization Name (eg, company) [Internet Widgits Pty Ltd]:
  # Organizational Unit Name (eg, section) []:
  # Common Name (e.g. server FQDN or YOUR name) []:
  # Email Address []:
  cat <<EOF | sudo openssl req -new -x509 -nodes -newkey rsa:4096 -days 1095 \
                   -keyout /etc/httpd/conf/server.key \
                   -out /etc/httpd/conf/server.crt
AU
Some-State
city
company
section
${WEBDAV_SERVER_FQDN}

EOF
  sudo sed -i /etc/httpd/conf/httpd.conf \
       -e 's/^#LoadModule ssl_module/LoadModule ssl_module/g' \
       -e 's/^#LoadModule socache_shmcb_module/LoadModule socache_shmcb_module/g'
  cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf
Include conf/extra/httpd-ssl.conf
EOF

  # rewrite configuration.
  sudo sed -i /etc/httpd/conf/httpd.conf \
       -e 's/^#LoadModule rewrite_module/LoadModule rewrite_module/g'
  cat << EOF | sudo tee /etc/httpd/conf/extra/redirect-to-https.conf
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}
EOF
  cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf
Include conf/extra/redirect-to-https.conf
EOF

  # joomla configuration.
  cat <<EOF | sudo tee -a /etc/httpd/conf/extra/joomla.conf
Alias /joomla /usr/share/webapps/joomla

<Directory /usr/share/webapps/joomla>
  Options FollowSymLinks
  Require all granted
</Directory>
EOF
  cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf
Include conf/extra/joomla.conf
EOF

  sudo systemctl restart httpd
}

joomla_main()
{
  mysql_install
  php_install
  joomla_install
  apache_install
}

joomla_main

2 Joomlaへアクセスする

以下のURLにアクセスしてJoomlaをセットアップします。データベースのユーザ名はrootでパスワードはMYSQL_PASSWDの値を設定してください。

https://<server>/joomla

0001_Joomla.png