Install VSFTPD, APACHE, PHP 8.1, MARIA DB, Wordpress on DEBIAN 10 (Google Cloud)
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 update
sudo apt install -y lsb-release ca-certificates apt-transport-https software-properties-common gnupg2 zipsudo apt-get update && sudo apt -y upgradesudo apt install apache2 apache2-utils mariadb-server mariadb-client git -ysudo systemctl start apache2 && systemctl enable apache2 && sudo systemctl start mariadb && sudo systemctl enable mariadb && systemctl restart apache2
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
or run this command:
curl -o /etc/mysql/mariadb.conf.d/50-server.cnf https://gist.githubusercontent.com/codekaze/173298da8ef419e9e35aad1a1957d57b/raw/6ea0553f57c079946469e5a1759d3a71311f7455/gistfile1.txt
Restart Maria DB
sudo systemctl restart mysql.service
sudo systemctl restart mariadb.service
- Configure MySQL
With root access, run this command:
mysql -u root
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 PHP8.1
Run this command:
sudo apt install wgetecho "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/sury-php.listwget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -sudo apt update
— -
sudo apt install php8.1 libapache2-mod-php8.1 php8.1-mysql php-common php8.1-cli php8.1-xml php8.1-gd php8.1-mbstring php8.1-common php8.1-opcache php8.1-readline php8.1-curl php8.1-sqlite3 php8.1-zip -ysudo a2enmod php8.1sudo systemctl restart apache2
- Set Maximum Upload Size
sudo nano /etc/php/8.1/apache2/php.ini
Set:
upload_max_filesize = 500M
post_max_size = 500M
or Run this command:
curl -o /etc/php/8.1/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.
!!!! READ ME !!!!
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
Before install let’s encrypt please update your domain A Record to your VPS IP Address.
Run this command:
sudo apt install snapd
sudo snap install core
sudo snap refresh coresudo 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. Set Permission to Execute Command in PHP File
Run:
sudo visudo
Add this line to the opened file:
www-data ALL=NOPASSWD: ALL
Save! and now you can run shell_exec from your PHP as sudoers!
Example:
<?php
// check shell_exec is installed if(!function_exists('shell_exec')) {
echo "shell_exec is'nt enabled";
} // run a command
$output = shell_exec('sudo php -v');
echo "<pre>$output</pre>";
5. Install GIT
sudo apt-get install curl software-properties-common
curl -sL https://deb.nodesource.com/setup_16.x | sudo bash -sudo apt-get install git -y
sudo apt install nodejs -y
curl -sS https://getcomposer.org/installer -o composer-setup.php
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
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