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

Table of Contents

1 WordPressをインストールする


  • MYSQL_PASSWDはMySQLのrootユーザのパスワードです。
  • WORDPRESS_PASSWDはMySQLのwordpressユーザのパスワードです。

#!/bin/shset -e[ -z “${MYSQL_PASSWD}” ] && MYSQL_PASSWD=mysql[ -z “${WORDPRESS_PASSWD}” ] && WORDPRESS_PASSWD=$(openssl rand -base64 32 | head -c 32)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_installationy${MYSQL_PASSWD}${MYSQL_PASSWD}nyyyEOF cat<<EOF | sudo mysql -uroot -p${MYSQL_PASSWD}create database wordpress;grant all privileges on wordpress.* to wordpress@localhost identified by ‘${WORDPRESS_PASSWD}’;flush privileges;exitEOF}wordpress_install(){ sudo pacman -Sy –noconfirm wordpress cat <<EOF | sudo tee /usr/share/webapps/wordpress/wp-config.php<?phpdefine(‘DB_NAME’, ‘wordpress’);define(‘DB_USER’, ‘wordpress’);define(‘DB_PASSWORD’, ‘${WORDPRESS_PASSWD}’);define(‘DB_HOST’, ‘localhost’);define(‘DB_CHARSET’, ‘utf8’);define(‘DB_COLLATE’, ”);define(‘AUTH_KEY’, ‘$(openssl rand -base64 64 | head -c 64)’);define(‘SECURE_AUTH_KEY’, ‘$(openssl rand -base64 64 | head -c 64)’);define(‘LOGGED_IN_KEY’, ‘$(openssl rand -base64 64 | head -c 64)’);define(‘NONCE_KEY’, ‘$(openssl rand -base64 64 | head -c 64)’);define(‘AUTH_SALT’, ‘$(openssl rand -base64 64 | head -c 64)’);define(‘SECURE_AUTH_SALT’, ‘$(openssl rand -base64 64 | head -c 64)’);define(‘LOGGED_IN_SALT’, ‘$(openssl rand -base64 64 | head -c 64)’);define(‘NONCE_SALT’, ‘$(openssl rand -base64 64 | head -c 64)’);$table_prefix = ‘wp_’;define(‘WP_CONTENT_DIR’, ‘/usr/share/webapps/wordpress/wp-content’);define(‘DISALLOW_FILE_MODS’, false);define(‘AUTOMATIC_UPDATER_DISABLED’, false);define(‘WP_DEBUG’, false);$_SERVER[‘HTTPS’] = ‘on’;define(‘FS_METHOD’, ‘direct’);if ( !defined(‘ABSPATH’) ) define(‘ABSPATH’, ‘/usr/share/webapps/wordpress’);require_once(ABSPATH . ‘wp-settings.php’);?>EOF}php_install(){ # Enable PHP extension. sudo pacman -Sy –noconfirm php sudo sed -i /etc/php/php.ini -e ‘s/^;’ -e ‘s/^;’}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.confLoadModule php7_module modules/libphp7.soAddHandler php7-script phpInclude conf/extra/php7_module.confEOF # 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.crtAUSome-Statecitycompanysection${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.confInclude conf/extra/httpd-ssl.confEOF # 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.confRewriteEngine OnRewriteCond %{HTTPS} offRewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}EOF cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.confInclude conf/extra/redirect-to-https.confEOF # wordpress configuration. cat <<EOF | sudo tee /etc/httpd/conf/extra/wordpress.confAlias /wordpress /usr/share/webapps/wordpress<Directory /usr/share/webapps/wordpress> AllowOverride All Options FollowSymlinks Require all granted</Directory>EOF cat <<EOF | sudo tee -a /etc/httpd/conf/httpd.confInclude conf/extra/wordpress.confEOF sudo systemctl restart httpd}wordpress_main(){ mysql_install php_install wordpress_install apache_install}wordpress_main

2 WordPressへアクセスする




Android | Linux | SDL - Narrow Escape