OpenSUSE Leap 42: Install WordPress

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

1 Install WordPress

  • Change WORDPRESS_DOMAIN to your machine's FQDN.
  • This article uses SSL/TLS certicication file by gensslcert for https. Please change your SSL/TLS certification file.
#!/bin/sh

set -e

[ -z "${WORDPRESS_DOMAIN}" ] && \
  WORDPRESS_DOMAIN=opensuse-14-wordpress.hiroom2.com
WORDPRESS_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 root
create database wordpress;
grant all privileges on wordpress.* to wordpress@localhost
  identified by '${WORDPRESS_PASSWD}';
flush privileges;
exit
EOF
}

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
<?php
define('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 Access to WordPress

Access to your FQDN via https.

https://<WORDPRESS_DOMAIN>

Because the chrome does not have this page's certification, the crome warns the following and cannot to access to this page. You need to click "ADVANCED" and "Proceed to <server> (unsafe)". The other browser will needs the similar way.

0001_YourConnectionIsNotPrivate.png

Locale setting is displayed.

0002_SetLocale.png

Account setting is displayed. After creating account, you can login to WordPress, create blog page and manage WordPress.

0003_WordPress.png