RSS

Installing Wordpress on Debian 10

Debian is an excellent Linux distribution for servers.

💻 In this video, I install Wordpress Lamp stack (Linux, Apache, MySQL, and PHP) on a Debian Linux virtual machine.

# Wordpress 5.7 install on Debian 10

####### FIX VIM AS EACH USER ######
## fix problem with pasting with right click:
echo "set mouse-=a" >> ~/.vimrc
## turn on syntax highlighting
echo ":syntax on" >> ~/.vimrc

### COLOR PROMPT ###
vi ~/.bashrc
# add to ~/.bashrc
force_color_prompt=yes
PS1="\[\033[01;31m\]\u\[\033[00;37m\]@\h:\w\$ "

# Create a small swap file just in case, 
# review page: https://www.digitalocean.com/community/tutorials/how-to-add-swap-space-on-debian-9
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
cp /etc/fstab /etc/fstab.bak
echo '/swapfile none swap sw 0 0' | sudo tee -a /etc/fstab

# Review swappiness from page: https://mariadb.com/kb/en/configuring-swappiness/
# probably returns 60
sysctl vm.swappiness
# Edit file
vi /etc/sysctl.conf
# Add:
vm.swappiness = 5

# reboot
init 6

# check swappiness again
sysctl vm.swappiness

# Verify that you have 1G of swap available to the kernel:
free -m

apt update
apt install gnupg gnupg2 software-properties-common dirmngr curl

# To install MariaDB Community Edition, start here: 
# https://downloads.mariadb.org/mariadb/repositories/#distro=Debian&mirror=truenetwork

# sudo apt-get install software-properties-common dirmngr -- ALREADY DONE!
apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
add-apt-repository 'deb [arch=amd64,arm64,ppc64el] https://mirror.mva-n.net/mariadb/repo/10.5/debian buster main'

apt update
apt install mariadb-server

#verify mariadb is running
service mariadb status

# Secure the database:
mysql_secure_installation
# create new DB schema and user
mysql -u root -p
mysql> CREATE DATABASE wp;
mysql> CREATE USER `wpuser`@`localhost` identified by 'password';
mysql> GRANT ALL ON wp.* TO `wpuser`@`localhost`;
mysql> FLUSH PRIVILEGES;
mysql> exit
# an easy command to remember where the mariadb system and error log is found, 
# and to edit the database parameters, add to ~/.bashrc
vi ~/.bashrc
alias log='tail -100 /var/log/syslog | grep mysql'
alias params='vi /etc/mysql/my.cnf'

# Install PHP
apt install php libapache2-mod-php php-mysql
apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip

# install apache2
apt install apache2

# enable apache rewrite
a2enmod rewrite

# create a wp configuration in apache
vi /etc/apache2/sites-available/wordpress.conf
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/wordpress
        ServerName 3o3.duckdns.org
        ServerAlias www.3o3.duckdns.org
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
      <Directory /var/www/wordpress/>
         Options Indexes FollowSymLinks
         AllowOverride all
         Require all granted
      </Directory>
</VirtualHost>
# enable site:
ln -s /etc/apache2/sites-available/wordpress.conf /etc/apache2/sites-enabled/

cd /var/www/
curl -O https://wordpress.org/latest.tar.gz
tar xzvf latest.tar.gz
chown -R  www-data:www-data /var/www

service apache2 restart