Install VSFTPD, APACHE, PHP 7, MARIA DB, Wordpress on DEBIAN 10 (Google Cloud)

Code Kaze
4 min readJul 17, 2021

First, you have to open PORT in the VPC Network menu on the GCP page.
I don’t want to get too deep here, try opening all ports for now.

1. Install Apache & Maria DB

Run this command:

sudo su -
sudo apt-get update && sudo apt -y upgrade
sudo apt install apache2 apache2-utils mariadb-server mariadb-client git -ysudo systemctl start apache2
sudo systemctl enable apache2
sudo systemctl start mariadb
sudo systemctl enable mariadb
  • Restart Apache (Required)
sudo systemctl restart apache2
  • Configure MySQL

With root access, run this command:

mysql -u root

Optional: Enable Remote Access to Maria DB

Edit File:

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

change:

bind-address=127.0.0.1

to:

bind-address=0.0.0.0

Restart Maria DB

sudo systemctl restart mysql.service
sudo systemctl restart mariadb.service

Create The User

Login to Mysql, run this command:

create user 'root'@'%' identified by '123';
grant all privileges on *.* to 'root'@'%' identified by '123';
flush privileges;

Exit mysql console

exit

2. Install PHP7.3

Run this command:

sudo apt install php7.3 libapache2-mod-php7.3 php7.3-mysql php-common php7.3-cli php7.3-xml php7.3-gd php7.3-mbstring php7.3-common php7.3-json php7.3-opcache php7.3-readline php7.3-curl -ysudo a2enmod php7.3sudo systemctl restart apache2
  • Set Maximum Upload Size
sudo nano /etc/php/7.3/apache2/php.ini

Set:

upload_max_filesize = 500M
post_max_size = 500M

or Run this command:

curl -o /etc/php/7.3/apache2/php.ini https://gist.githubusercontent.com/codekaze/410671fda20ccb20b7d6326654dc1e20/raw/4b09a06b6399c6c0dae8732fd4c54a5a1133efbc/gistfile1.txt
  • Now, lets enable .httaccess
nano /etc/apache2/apache2.conf

Change AllowOverride to All (Directory/ & Directory /var/www/)

AllowOverride All

or Run this command:

curl -o /etc/apache2/apache2.conf https://gist.githubusercontent.com/codekaze/9cec5b4f042c3237c69b60193d2f9ad4/raw/aecc0ba538baca206bdceaf8c0d4f05b34ea2450/apache2.conf

Restart Apache2

sudo service apache2 restart

3. Install VSFTPD

Run this command:

sudo apt-get install vsftpd -y
systemctl start vsftpd
systemctl enable vsftpd

Edit vsftpd.conf with this command:

sudo nano /etc/vsftpd.conf

Add the following lines at the end of the file:

listen=NO
listen_ipv6=YES
anonymous_enable=NO
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
use_localtime=YES
xferlog_enable=YES
connect_from_port_20=YES
chroot_local_user=YES
secure_chroot_dir=/var/run/vsftpd/empty
pam_service_name=ftp
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key
ssl_enable=Yes
pasv_enable=Yes
pasv_min_port=10000
pasv_max_port=10100
allow_writeable_chroot=YES
ssl_tlsv1=YES
ssl_sslv2=NO
ssl_sslv3=NO
force_local_logins_ssl=NO
force_local_data_ssl=NO

or Run this command:

curl -o /etc/vsftpd.conf https://gist.githubusercontent.com/codekaze/1dcff44d18743b437f8560b1ee2ac4f3/raw/25608e4ba086b32e0c3f47ac012d5f26ab7826f6/vsftpd.conf

Press Ctrl+O and Ctrl+X to save and exit the file.
Then, Restart VSFTPD Service

sudo systemctl restart vsftpd

Create FTP User

sudo useradd -m test
sudo passwd test

Change “test” to your desired username

Edit User Home Directory

usermod --home /var/www/html test
sudo chown -R test:test /var/www//html

Change “test” to your desired username

Ok, now you have an ftp account. Generally, it uses the public/external ip you have as the host.

If you are using FileZilla, make sure the transfer type is Active Mode.

host: 101.101.202.4 (Your IP)
username: test
password: your-password

4. Install Let’s Encrypt on Apache2

Run this command:

sudo apt install snapd
sudo snap install core
sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot --apache

They will ask for your data. Please fill in correctly.

5. Install GIT

sudo apt-get install git -y

6. Install Wordpress

cd /var/www/htmlcurl -O https://wordpress.org/latest.zip && unzip latest.zip && mv wordpress/* . && rm -rf wordpress

Login to Mysql

mysql -u root

Create new database

create database codekaze_db

Now open your site url or ip:
Example: https://codekaze.com or https://192.168.23.44

Follow wordpress installation instruction,
It will ask you to create wp-config.php

cd /var/www/htmlnano wp-config.php

Add this lines of code to wp-config.php and then save.

<?php
define( 'WP_CACHE', true );
define('FS_METHOD', 'direct');
define('FTP_BASE', '/var/www/html/');
define('FTP_USER', 'root');
define('FTP_PASS', 'YOUR-PASSWORD');
define('FTP_HOST', 'codekaze.com');
define('FTP_SSL', false);
define( 'DB_NAME', 'codekaze_db' );
define( 'DB_USER', 'root' );
define( 'DB_PASSWORD', 'YOUR-PASSWORD' );
define( 'DB_HOST', 'localhost' );
define( 'DB_CHARSET', 'utf8mb4' );
define( 'DB_COLLATE', '' );
define( 'AUTH_KEY', 'u@9n)s=gmn_UjRr.`3pk2$$jr]|tPh)Ln8~Ncz!rY+]dET5|,-xlub<J:4Q3zM|Q' );
define( 'SECURE_AUTH_KEY', 'bapM;{ApN0DHPR{R&zU1cf%G)pW`9mE#MZ|4#[|[:?5r^?H!X>*N;4hcZHGA[#EM' );
define( 'LOGGED_IN_KEY', '8U78ta3nC%J+ke?!&`*B;MCW8m.jvdHxYoH9a^7]/duXQpCy#o`!- NsqxoGDKN5' );
define( 'NONCE_KEY', 'vm19[9#kre%kq:{V0^W/v8FKN6?ioF*0wgLHI9[=A#59_]Qi_YAtmFh>m0e=43j/' );
define( 'AUTH_SALT', 'zc@A0sk`//<BUq_P>S:bK&83%/nM7(^vs8Oh*Z;*w}^uTH+<hc8~NT#:;aw`u_!I' );
define( 'SECURE_AUTH_SALT', 'E}x*rC-d/0hXo`yBk|2$OiWbJ#0/Ub`Q,,VQk-W>ke6|2uRXEqk`m.HM.dBr2N,.' );
define( 'LOGGED_IN_SALT', 'o:upg3M(Sebc;#Y#^|olu?vK~s>l#?YqcIHu`Sy/X}-DjV0.qy7I[%kNt+j):s;/' );
define( 'NONCE_SALT', ')8N5nDn!2PH~[A=,[iy=$Qx?DkPCsL`zYqoyb9/xv8^r=!NgD6Z-Jpa_@mUC.]|w' );
$table_prefix = 'wp_';
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
require_once ABSPATH . 'wp-settings.php';

References:
https://www.digitalocean.com/community/tutorials/how-to-secure-apache-with-let-s-encrypt-on-debian-10
https://phoenixnap.com/kb/how-to-reset-mysql-root-password-windows-linux
https://www.linuxbabe.com/debian/install-lamp-stack-debian-10-buster
https://vitux.com/how-to-install-vsftpd-ftp-server-with-tls-on-debian-10/
https://gist.github.com/BFTrick/11294357

--

--