WordPress deployment

 Nov, 25 - 2018   no comments   Tutorials


Install on Debian
Install on RPi



The installation of WordPress is tricky. This application tries to update it-self, which is a problem when security is properly handled: WP needs disk write access to do that operation, write access to it-self, which is a security hazard.

Use Debian’s packaged version:

apt install apache2 php7 mariadb-server wordpress

You can install directly:

wget -c https://wordpress.org/latest.tar.gz -O wordpress-latest.tar.gz
tar xzvf wordpress-latest.tar.gz

DB setup

As root:

mariadb -e 'create user '\''wp'\''@'\''localhost'\'' identified by '\''xxx'\'''
mariadb -e 'grant all privileges on wp.* to '\''wp'\''@'\''localhost'\'''
mariadb -e 'create database wp'
mariadb -e 'flush privileges'

Web setup

cat > /etc/apache2/sites-available/wp.conf

        ServerAdmin webmaster@example.com
        DocumentRoot /usr/share/wordpress

        Alias /wp-content /var/www/wp-sandbox/wp-content
        <Directory /usr/share/wordpress>
            Options FollowSymLinks
            AllowOverride Limit Options FileInfo
            DirectoryIndex index.php
            Require all granted
        <Directory /var/www/wp-sandbox/wp-content>
            Options FollowSymLinks
            Require all granted

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

a2ensite wp
a2enmod rewrite
systemctl reload apache2

Configure WP

mkdir /var/www/wp-sandbox/wp-content
chown www-data:www-data /var/www/wp-sandbox/wp-content

cat > /etc/wordpress/config-
# Database access
define('DB_NAME', 'wp');
define('DB_USER', 'wp');
define('DB_PASSWORD', 'xxx');
define('DB_HOST', 'localhost');

# WordPress content outsite reference deployment
define('WP_CONTENT_DIR', '/var/www/wp-sandbox/wp-content');

# Activate debug
define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', true);

# Force writting on fs
define('FS_METHOD', 'direct');
define('FS_BASE', '/var/www/wp-sandbox/wp-content');



cd /usr/share/wordpress/wp-content/plugins
wget -c https://downloads.wordpress.org/plugin/wp-mail-smtp.zip
unzip wp-mail-smtp.zip
rm wp-mail-smtp.zip


In plugin WP Mail SMTP, PHPMailer (/usr/share/php/libphp-phpmailer/class.phpmailer.php)
doesn’t autoload SMTP class file.

Leave a Reply

Your email address will not be published. Fields with * are mandatory.