WordPress Install

This page describes WordPress installation on the staff.fnwi.uva.nl server. Because it involves personal websites no official support can be given, but feel free to ask questions if you experience problems. You are required to update WordPress when updates are available in the Dashboard panel to avoid security risks on the server.

# login
ssh <UVANETID>@staff.fnwi.uva.nl

# rename the existing website dir
mv WWW WWW_`date +%Y-%m-%d-%H:%M:%S`
umask 002 # this sets group-write permission and sgid bit
mkdir WWW
umask $umask_old
cd WWW

# get latest version of wordpress
wget https://wordpress.org/latest.zip
unzip latest.zip
cp -r wordpress/* ./     # trick to set group to 'apache'
rm -rf wordpress

# getting some essential plugins
cd wp-content/plugins
# database plugin so we don't require a MySQL account
# download: https://wordpress.org/plugins/sqlite-integration/ (use latest version!)
wget https://downloads.wordpress.org/plugin/sqlite-integration.1.8.1.zip
unzip sqlite-integration.1.8.1.zip
cp ./sqlite-integration/db.php ..
# enable ssh connection to install/update themes,plugins and upgrade wordpress
# download: https://wordpress.org/plugins/ssh-sftp-updater-support/ (use latest version!)
wget https://downloads.wordpress.org/plugin/ssh-sftp-updater-support.0.5.zip
unzip ssh-sftp-updater-support.0.5.zip

# create some dirs
mkdir -p ../tmp/
mkdir -p ../uploads/
mkdir -p ../upgrade/
# create dir where the database is stored in
mkdir -p $HOME/wordpress-db
chmod g+w $HOME/wordpress-db

# commands to write 'wp-config-sample.php' to 'wp-config.php', the
# main wordpress configuration file
# normally done by hand but this saves time
cd ../../
linenr=`grep -nr "define('DB_COLLATE'" wp-config-sample.php | cut -d : -f 1`
head -n $linenr wp-config-sample.php > wp-config.php
echo "" >> wp-config.php
echo "// using sqlite database instead of mysql" >> wp-config.php
echo "define('DB_FILE', 'sqlite.db');" >> wp-config.php
echo "define('DB_DIR', '$HOME/wordpress-db');" >> wp-config.php
echo "define('WP_TEMP_DIR', ABSPATH . 'wp-content/tmp/');" >> wp-config.php
linenr2=`grep -nr "define('AUTH_KEY'," wp-config-sample.php | cut -d : -f 1`
linenr2=`expr $linenr2 - 1`
linenr=`expr $linenr + 1`
sed -n "$linenr,${linenr2}p" wp-config-sample.php >> wp-config.php
wget https://api.wordpress.org/secret-key/1.1/salt
cat salt >> wp-config.php
rm salt
echo "" >> wp-config.php
linenr=`grep -nr "/**#\@-" wp-config-sample.php | cut -d : -f 1`
tail --lines=+$linenr wp-config-sample.php >> wp-config.php

# this creates the 'fix_wp-content' script as workaround for setting proper group,
# group-write permission, and sgid bit on all files and directories in wp_content
# run this script when experiencing problems when uploading or updating
# and when all is ok remove the 'wp-content_remove_when_all_ok*' dir afterwards
echo '#!/bin/bash' > fix_wp-content
echo "#Script to set group-write bit, SGID bit and set owner to $USER.apache recursively for dir wp-content" >> fix_wp-content
echo "#" >> fix_wp-content
echo "umask 002" >> fix_wp-content
echo "find wp-content/ -type d -exec mkdir tmp_{} \; -exec bash -c \"cp {}/* tmp_{}/ 2> /dev/null\" \;" >> fix_wp-content
echo "mv wp-content wp-content_remove_when_all_ok_\`date +%Y-%m-%d-%H:%M:%S\`" >> fix_wp-content
echo "mv tmp_wp-content wp-content" >> fix_wp-content
chmod +x fix_wp-content

# now run the workaround script to fix 'wp-content'
bash fix_wp-content
# check if all is ok, for example the new 'wp-content' dir should have
# approximately the same size as the old:
du -s wp-content*
# When all ok remove the 'wp-content_remove_when_all_ok*' dir
# (to save disk space) at your own responsibility using:
# rm -rf wp-content_remove_when_all_ok*

# now open this link in your webbrowser and follow the instructions:
# where <YOUR-EMAIL-NAME> is the name in your @uva.nl email address


# after logging in to your website activate 'ssh-sftp-updater-support' plugin
- click 'Dashboard' (pull-down menu right from "W" top left)
- click 'Plugins'
- click 'Activate' of ssh-sftp-updater-support

# test install other plugin
- click 'Plugins'
- click 'Add new'
- search 'disable comments' (prevents people from leaving comments on website)
- click 'Install Now' of 'Disable Comments' plugin
- use ssh connection with:
hostname: staff.fnwi.uva.nl
username: <UVANETID>
Connection Type: ssh2
- click 'activate'
- click 'settings'
- click 'Everywhere'
- click 'Save Changes'

# if this works uploading and updating works
# in case of later problems first run the 'fix_wp-content' workaround script above