SETUP PROCESS:

INITIAL USER:

adduser myuser
passwd myuser
gpasswd -a myuser wheel
su - myuser
mkdir .ssh
chmod 700 .ssh
vi .ssh/authorized_keys
chmod 600 .ssh/authorized_keys

SSH

Made the following modifications to /etc/ssh/sshd_config:

Port 2222
PermitRootLogin no
MaxAuthTries 6
MaxSessions 10
PubkeyAuthentication yes
PasswordAuthentication no

Then restart the service: systemctl reload sshd

FTP

yum install vsftpd

Make the following modifications to the default /etc/vsftpd/vsftpd.conf file:

anonymous_enable=NO
chroot_local_user=YES
userlist_deny=NO
userlist_enable=YES
userlist_file=/etc/vsftpd/vsftpd.allowed_users
force_dot_files=YES

Then add an FTP user and restart the service:

sudo useradd myftpuser -s /sbin/nologin
sudo passwd myftpuser
sudo systemctl restart vsftpd
sudo systemctl enable vsftpd 

ERROR: “500 OOPS: vsftpd: refusing to run with writable root inside chroot()” solved by removing write permissions to home directory:

sudo chmod a-w /home/myftpuser

FIREWALLD

sudo systemctl start firewalld
sudo firewall-cmd --permanent --add-port=2222/tcp
sudo firewall-cmd --permanent --add-service=ftp
sudo firewall-cmd --reload 
sudo systemctl enable firewalld

SETTING TIME

sudo timedatectl
sudo timedatectl list-timezones | grep New
sudo timedatectl set-timezone America/New_York
sudo yum install ntp
sudo systemctl start ntpd
sudo systemctl enable ntpd

CREATING SWAP FILE

The command free -m reveals 512MB RAM and 0 SWAP space, so setup a swap:

sudo fallocate -l 512M /swapfile
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo sh -c 'echo "/swapfile none swap sw 0 0" >> /etc/fstab'

The free -m command now shows 512M SWAP.

FTP CLIENT

The LFTP client is absolutely awesome. Directory mirroring is super handy.

yum install lftp

WEB STACK

sudo yum install httpd
sudo systemctl start httpd.service
sudo firewall-cmd --permanent --add-service=http
sudo systemctl enable httpd.service
sudo yum install mariadb-server mariadb
sudo systemctl start mariadb
sudo mysql_secure_installation
sudo systemctl enable mariadb.service
sudo yum install php php-mysql
sudo systemctl restart httpd.service 
sudo yum search php-
sudo yum info php-fpm
sudo yum install php-fpm

SETUP WEB SPACE

sudo mkdir -p /var/www/dev.poism.com/public_html
sudo usermod -a -G apache myuser
sudo chmod -R 755 /var/www/dev.poism.com/public_html

SETUP VIRTUAL HOST

Create file /etc/httpd/sites-available/dev.poism.com.conf containing:

<VirtualHost *:80>
    ServerName dev.poism.com
    ServerAlias dev.poism.com
    DocumentRoot /var/www/dev.poism.com/public_html
    ErrorLog /var/www/dev.poism.com/error.log
    CustomLog /var/www/dev.poism.com/requests.log combined
</VirtualHost>

Then link it to make active and restart server:

cd /etc/httpd/sites-enabled/
ln -s /etc/httpd/sites-available/dev.poism.com.conf
sudo service httpd restart

The server lives!

Next Post