phpservermon and Debian 9 (Stretch)

23 Jan

Let’s assume Proxmox:

apt-get install qemu-guest-agent openssh-server

Let’s prepare to install a newer version of PHP:

apt -y install lsb-release apt-transport-https ca-certificates
wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg
echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | tee /etc/apt/sources.list.d/php.list

Update the sources:

apt-get update

Now we can install:

apt-get install apache2 mysql-server libapache2-mod-php7.4 php7.4-common php7.4-curl php7.4-dev php7.4-gd php7.4-mbstring php7.4-xml php7.4-zip php7.4-mysql postfix

Let’s secure the database server:

mysql_secure_installation

Let’s create a database:

mysql -u root -p
CREATE USER 'phpmyadmin'@'%' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON *.* TO 'phpmyadmin'@'%' WITH GRANT OPTION;
quit;

I prefer to have the site which runs phpMyAdmin is only accessible on another port:

nano /etc/apache2/ports.conf
Listen 8080

Create the directory the site source code will be located:

mkdir -p /var/vhosts/phpmyadmin/www

Download phpMyAdmin:

cd /tmp
wget https://files.phpmyadmin.net/phpMyAdmin/4.9.7/phpMyAdmin-4.9.7-english.tar.gz
tar xzf phpMyAdmin-4.9.7-english.tar.gz

We can then move it to the created folder:

cd phpMyAdmin-4.9.7-english
cp * -R /var/vhosts/phpmyadmin/www

Update Apache’s configuration:

nano /etc/apache2/sites-available/phpmyadmin.conf
<VirtualHost *:8080>
ServerName phpmyadmin
DocumentRoot "/var/vhosts/phpmyadmin/www"
<Directory />
Require all granted
</Directory>
</VirtualHost>

Assign proper permissions:

chown -R www-data:www-data /var/vhosts

Enable the site and restart the service:

a2ensite phpmyadmin
service apache2 restart

Create a user and database for phpservermon using phpMyAdmin.

http://ip-address:8080

Let’s create folders, download + extract, and move the source files for phpservermon:

mkdir -p /var/vhosts/website_name/www
mkdir -p /var/vhosts/website_name/ssl
cd /tmp
wget https://github.com/phpservermon/phpservermon/releases/download/v3.5.2/phpservermon-3.5.2.tar.gz
tar xzf phpservermon-3.5.2.tar.gz
cd phpservermon-3.5.2
cp * -R /var/vhosts/website_name/www

Update Apache’s server config:

nano /etc/apache2/sites-available/website_name.conf
<VirtualHost *:80>
ServerName website_name
Redirect / https://website_name/
</VirtualHost>
<VirtualHost *:443>
ServerName website_name
SSLEngine on
SSLCertificateFile /var/vhosts/website_name/ssl/certificate.crt
SSLCertificateKeyFile /var/vhosts/website_name/ssl/key.key
SSLCertificateChainFile /var/vhosts/website_name/ssl/ca-certificate.crt
DocumentRoot "/var/vhosts/website_name/www"
<Directory />
AllowOverride All
Require all granted
</Directory>
</VirtualHost>

Create your certificate assets:

nano /var/vhosts/website_name/ssl/key.key
nano /var/vhosts/website_name/ssl/certificate.crt
nano /var/vhosts/website_name/ssl/ca-certificate.crt

Enable the new site and the required SSL module:

a2ensite website_name
a2enmod ssl

Assign the proper owner and restart the service:

chown -R www-data:www-data /var/vhosts
service apache2 restart

4 thoughts on “phpservermon and Debian 9 (Stretch)

  1. I have not checked in here for some time since I thought it was getting boring, but the last several posts are great quality so I guess I¦ll add you back to my daily bloglist. You deserve it my friend 🙂

Leave a Reply

Your email address will not be published.