コンテンツマネージメントシステムのDrupalをインストールする手順を記載します。
Table of Contents
1 Drupalをインストールする
以下のスクリプトでDrupalをインストールします。
- MYSQL_PASSWDはMySQLで使うrootユーザのパスワードです。
#!/bin/sh -e [ -z "${MYSQL_PASSWD}" ] && MYSQL_PASSWD=mysql postfix_install() { sudo pacman -Sy --noconfirm postfix sudo systemctl enable postfix cat <<EOF | sudo tee /etc/postfix/main.cf myhostname = localhost mydomain = localdomain myorigin = \$myhostname.\$mydomain mydestination = localhost, localhost.\$mydomain, \$myhostname, \$mydomain, \$myorigin compatibility_level = 2 command_directory = /usr/bin daemon_directory = /usr/lib/postfix/bin data_directory = /var/lib/postfix mail_owner = postfix inet_interfaces = all local_recipient_maps = unix:passwd.byname \$alias_maps unknown_local_recipient_reject_code = 550 mynetworks_style = subnet mynetworks = 127.0.0.0/8 alias_maps = hash:/etc/postfix/aliases alias_database = \$alias_maps debugger_command = PATH=/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin ddd \$daemon_directory/\$process_name \$process_id & sleep 5 sendmail_path = /usr/bin/sendmail newaliases_path = /usr/bin/newaliases mailq_path = /usr/bin/mailq setgid_group = postdrop inet_protocols = ipv4 EOF sudo newaliases sudo systemctl restart postfix } 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 sudo sed -i /etc/php/php.ini \ -e 's/^;extension=pdo_mysql/extension=pdo_mysql/g' \ -e 's/^;extension=mysqli/extension=mysqli/g' \ -e 's/^;extension=gd/extension=gd/g' \ -e 's/^;zend_extension=opcache/zend_extension=opcache/g' \ -e 's/^;opcache.enable=1/opcache.enable=1/g' } drupal_install() { sudo pacman -Sy --noconfirm drupal sudo sed -i /usr/share/webapps/drupal/.htaccess \ -e 's/Require all denied/Require all granted/g' } 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 # drupal configuration. sudo cp /etc/webapps/drupal/apache.example.conf \ /etc/httpd/conf/extra/drupal.conf cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.conf Include conf/extra/drupal.conf EOF sudo systemctl restart httpd } drupal_main() { postfix_install mysql_install php_install drupal_install apache_install } drupal_main