OpenSUSE Leap 42: WordPressをインストールする


Table of Contents

1 WordPressをインストールする

  • WORDPRESS_DOMAINをお使いの環境のFQDNに変更してください。
  • この記事ではhttpsの為にgensslcertで作成したSSL/TLS証明書を使っています。別にSSL/TLS証明書を用意している場合は変更してください。

#!/bin/shset -e[ -z “${WORDPRESS_DOMAIN}” ] && WORDPRESS_DOMAIN=opensuse-14-wordpress.hiroom2.comWORDPRESS_PASSWD=$(openssl rand -base64 32 | head -c 32)opensuse_install_mysql(){ sudo zypper -n in mariadb sudo systemctl enable mysql sudo systemctl start mysql cat<<EOF | sudo mysql -u rootcreate database wordpress;grant all privileges on wordpress.* to wordpress@localhost identified by ‘${WORDPRESS_PASSWD}’;flush privileges;exitEOF}opensuse_install_wordpress(){ O=http://download.opensuse.org A=${O}/repositories/server:/php:/applications/openSUSE_Leap_42.2/ sudo zypper ar -f -n Applications ${A} Applications sudo zypper -n –gpg-auto-import-keys up sudo zypper -n in wordpress cat <<EOF | sudo tee /etc/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’, ‘/srv/www/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’, ‘/srv/www/wordpress’);require_once(ABSPATH . ‘wp-settings.php’);?>EOF}opensuse_install_apache(){ sudo zypper -n in apache2 sudo gensslcert cat <<EOF | sudo tee /etc/apache2/conf.d/wordpress.conf<VirtualHost _default_:443> SSLEngine on SSLCertificateFile /etc/apache2/ssl.crt/server.crt SSLCertificateKeyFile /etc/apache2/ssl.key/server.key ServerName ${WORDPRESS_DOMAIN} DocumentRoot /srv/www/wordpress DirectoryIndex index.php index.html ErrorLog /var/log/apache2/wp-error.log TransferLog /var/log/apache2/wp-access.log Alias /wp-content /srv/www/wordpress/wp-content <Directory /srv/www/wordpress> Options FollowSymLinks Require all granted </Directory> <Directory /srv/www/wordpress/wp-content> Options FollowSymLinks Require all granted </Directory></VirtualHost>EOF for t in FW_CONFIGURATIONS_EXT FW_CONFIGURATIONS_DMZ FW_CONFIGURATIONS_INT; do sudo sed -e “s/^${t}=”(.*)”/${t}=”1 apache2-ssl”/g” -i /etc/sysconfig/SuSEfirewall2 done sudo systemctl restart SuSEfirewall2 sudo a2enflag SSL sudo a2enmod ssl sudo a2enmod php5 sudo systemctl enable apache2 sudo systemctl restart apache2}opensuse_main(){ opensuse_install_mysql opensuse_install_wordpress opensuse_install_apache}opensuse_main

2 WordPressへアクセスする

WORDPRESS_DOMAINで設定したFQDNにhttps経由でアクセスします。

https://<WORDPRESS_DOMAIN>

マシンの証明書を組み込んでいないので、Chromeの場合は以下の警告が出てアクセスできません。”ADVANCED”を表示させて”Proceed to <server> (unsafe)”をクリックすることで、このウェブサイトに例外的にアクセスするようにします。

Firefox等でも同様にこのウェブサイトを例外的にアクセスできるようにしてください。

0001_YourConnectionIsNotPrivate.png

ロケールの設定画面が表示されます。

0002_SetLocale.png

アカウント作成画面が表示されます。アカウント作成の後にログインして、ブログ記事の投稿やWordPressの管理が可能になります。

0003_WordPress.png

Android | Linux | SDL - Narrow Escape