Setting up Wordpress
2 minutes read •
Priliminary Setup
Set hostname
sudo vim /etc/hostname
For example the put the following line as hostname.
myserver
Setup /etc/hosts
sudo vim /etc/hosts
For example the put the following line as hosts.
127.0.0.1 localhost
:: localhost
127.0.1.1 wordpress mywebsite.com
Create New User
sudo useradd -m -g users -G sys,adm -s /bin/bash dev
sudo passwd dev
Add the user to sudo
sudo usermod -aG sudo dev
Wordpress Setup
Install packages
sudo apt install -y mariadb-server apache2 apache2-utils unzip imagemagick libmagickcore-6.q16-6-extra libapache2-mod-php php-imagick php-curl php-gd php-intl php-mbstring php-mysql php-soap php-xml php-zip
-
You can also install
php-xmlrpcif you need. But it is best to not install this one. -
Check
apache2status.
sudo systemctl status apache2
Setup MariaDB
- Check
mariadbstatus.
sudo systemctl status mariadb # It should be active and running.
- Securing mariadb.
sudo mysql_secure_installation
For the unix_socket authentication we can answer no. That will enable standard authentication and will work just fine.
- Login as database root user.
sudo mariadb -u root -p
- Create new user for
wordpress.
CREATE USER 'wordpress'@'localhost' IDENTIFIED BY 'password';
- Create a database named
db.
CREATE DATABASE IF NOT EXISTS db CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
- Check the created database.
SHOW DATABASES;
- Grant priviliges to the new user.
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress'@'localhost';
- Flush and save changes.
FLUSH PRIVILEGES;
- Quit mariadb.
quit;
Download and Extract WordPress
cd /var/www
sudo wget https://wordpress.org/latest.zip
sudo unzip latest.zip
sudo chown -R www-data:www-data wordpress
Add a configuration file for WordPress to Apache
- Create new
.conffile for wordpress.
sudo vim /etc/apache2/sites-available/wordpress.conf
- Add the following lines in the
.conffile
<VirtualHost *:80>
DocumentRoot /var/www/wordpress
<Directory /var/www/wordpress>
Options FollowSymLinks
AllowOverride All
DirectoryIndex index.php
Require all granted
</Directory>
<Directory /var/www/wordpress/wp-content>
Options FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
-
You can also set
AllowOverride Limit Options FileInfo. But that will create some problems when securing thewp-loginwith apachehtpasswd. -
Disable the default site and enable the new wordpress site.
sudo a2dissite 000-default.conf
sudo a2ensite wordpress.conf
- Enable some
apachemodules.
sudo a2enmod rewrite
- Restart
apache2.
sudo systemctl restart apache2
After all of that, access your site and then fill out form in the web browser. Then, you’re all set!