Digital Ocean Server Setup
The easiest way to create a webserver where you have root access is with a Digital Ocean Droplet. But configuring everthing everytime you create a new server is a dawnting task. This tutorial will condensate all the initial configurations of a basic server.
Droplet Setup
This server is going to have a bit of load so I will use the $10 droplet with 1GB Ram and 30GB SSD Disk. Use the Ubuntu 14.04 x64 image. I choose Ubuntu because there is a lot of documentation for it, but probably Debian or CentOS would be a better choise as a linux distro for a web server.
After creating the droplet, get the ip and password sent to your email and login as root user:
Create a new super user
Its a good practice to create a new super user account that uses commands with sudo
instead of using the root account where all commands are executed with sudo
by default.
Type in your password and answer some stupid questions. Then give this demo user some sudo powers:
Now with the super user created switch from root to the new user:
Create a new folder for SSH keys and modify its permissions:
Now create a new file for your SSH key and paste your public key inside of it:
Press Ctrl + X
to exit nano, then Y
to save and then hit Enter
.
Now restrict the permissions of the file with your key:
After everything is done, go back to being the root user:
Now test login in as your new user in a new shell session:
If everything works, you won't need to type in your password, the server will log you in automatically using the SSH key.
Remove root login
For security reasons, its a good ideia disable the root account login thru SSH and only log in with user accounts.
To remove the root login, first make sure you can log in with a different super user account. Then log in as root and run:
Next, change PermitRootLogin
to no
.
Press Ctrl + X
to exit nano, then Y
to save and then hit Enter
.
Now restart the SSH service:
And thats it! Now when you log out of the root account, you wont be able to log in again!
If you ever have to log in as the root user again, just change this settings back as your new super user using sudo
before the commands.
Configure FTP
To change vsftpd configuration, run sudo nano /etc/vsftpd.conf
. Change the following settings:
With this configuration, the admin user will be able to log in via SFTP to any folder inside /var/www/
. After changing configurations, restart the service:
Change SWAP memory settings
For droplets with a low amount of RAM memory, its possible to increase the SWAP memory.
Install zshell
To install zshell and set it as your default shell:
After installing zshell, exit the ssh session and log back in.
Install slap
Change hostname
To check the actual server hostname, run hostname --fqdn
. Then to change to a different hostname run:
System info with Archey
To install run:
To use, just run the command archey
.
Usefull commands
sudo poweroff
- turn off the droplet. It can be turned back on in the droplet control pannel.sudo reboot
- restarts the server.landscape-sysinfo
- simple system information. Use can use the flag--exclude-sysinfo-plugins=Temperature,LandscapeLink,Processes
.find /usr/share/figlet -name *.?lf -exec basename {} \; | sed -e "s/\..lf$//" | xargs -I{} toilet -f {} {}
- Show demo of toilet fontssudo apt-get clean
- remove files from incomplete installations.sudo apt-get autoremove
- remove unused packages.sudo apt-get update
- update the package manager.sudo apt-get upgrade
- update installed apps.
Links
About me
Hi, my name is James Peret. I'm a freelance designer, programmer and filmmaker from São Paulo, Brazil. This is my blog about technical stuff.