Debian 9 - Deploy WordPress
This tutorial is for manually deploying wordpress on an Ubuntu 16.04 server. Alternatively, you could deploy wordpress through docker.
Install MariaDB
sudo apt-get install mariadb-server -y
Now log into the database
sudo mysql
Create the wordpress database, and then create a wordpress
user that will have access to it. Be sure to change the passwordHere
text.
CREATE database wordpress;
GRANT ALL ON `wordpress`.* to wordpress@localhost identified by 'passwordHere';
Install Apache and PHP
sudo apt-get install -y \
apache2 libapache2-mod-php7.0 \
php7.0-cli php7.0-mysql
Download wordpress
wget https://wordpress.org/latest.zip
Optional - Create Wordpress SSH User
I use SSH to update my wordpress instances, and wish to use a non-sudo user to do this. Thus I will create a wordpress user at this point.
sudo adduser wordpress
Install Wordpress
sudo apt-get install unzip -y \
&& unzip latest.zip \
&& sudo mkdir -p /var/www/wordpress \
&& sudo mv wordpress /var/www/wordpress/public_html \
&& sudo chown -R wordpress:www-data -R /var/www/wordpress \
&& sudo chmod 750 -R /var/www/wordpress
Set Umask and Add to Group
Lets set the umask and add the www-data user to the wordpress group, so that if the wordpress user creates files, the apache server can still read them.
sudo adduser www-data wordpress \
&& cd /var/www/wordpress \
&& umask 027
027
means that new files will have 740 (-rwxr-----) permissions, but new directories will have 750 (-rwxr-x---).
Update Apache
sudo vim /etc/apache2/sites-available/000-default.conf
Replace it with:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/wordpress/public_html
<Directory /var/www/wordpress/public_html/>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Restart apache for the changes to take effect
sudo service apache2 restart
Optional - Enable URL Rewrite
Your more than likely to want this feature. If you're unsure, I would err on the side of enabling it.
sudo a2enmod rewrite
sudo service apache2 restart
Web Installation
Now go to your servers IP or hostname and perform the web based installation steps, before then going through the tutorial on securing wordpress.
First published: 14th March 2019