Saturday, December 5, 2015

Additional Server Setup

Firewall

Add the ufw firewall and open only those ports needed to serve web pages.

Allow SSH access to the server
sudo ufw allow ssh

Allow TCP access on port 80
sudo ufw allow 80/tcp

Allow TCP access on port 443 (https)
sudo ufw allow 443/tcp

Enable ufw
sudo ufw enable 

Check the ufw status
sudo ufw show added

Timezone Configuration

Set the timezone for your server to where you live.
sudo dpkg-reconfigure tzdata

Select your Country
Select your State/Provence 

Install NTP 

NTP is automatic time adjustment.
sudo apt-get update

sudo apt-get install ntp

It will automatically start the service and restart it if the server needs rebooting.

Add SwapFile

Swap file is where the operating system stores less often used commands usually kept in RAM. It's merely a precaution to add a swapfile to prevent server crash in the event it runs out of memory.

Make the swap file that same size as the total RAM on the system. 1G of RAM requires a 1G swapfile.

Allocate a gig of space for the swapfile
sudo fallocate -l 1G /swapfile

Change access permission for the swapfile
sudo chmod 600 /swapfile

Tell the OS to make the /swapfile a swapfile
sudo mkswap /swapfile

Turn the swap file on
sudo swapon /swapfile

Set up the system so that the swapfile is turned on a reboot
sudo sh -c 'echo "/swapfile none swap sw 0 0" >> /etc/fstab'

No comments:

Post a Comment