- Edit file /etc/hostname
- Edit file /etc/hosts and replace hostname following the address "127.0.1.1"
- Reboot with
sudo reboot
- Create a new user with
adduser username - Add the user to the sudo group with
usermod -aG sudo username - Put a random string as root password to avoid log in with root user with
passwd(https://passwordsgenerator.net/)
- Generate SSH key on your computer with
ssh-keygen - Copy the SSH key to the remote server with
ssh-copy-id -i ~/.ssh/mykey user@host - Disable SSH authentication with password in
/etc/ssh/sshd_configby settingPasswordAuthentication no - Restart the SSH service with
sudo service ssh restart
- Execute this bash file (mind the interface name in the file)
- Follow instructions here
sudo locale-gen "en_US.UTF-8"sudo dpkg-reconfigure locales- Check the server locale with
locale
- Follow instructions here
- Download and install the official and latest version of MongoDB here
- In the configuration file /etc/mongodb.conf, set the location of the database :
storage.dbPath: "/var/lib/mongodb/" - Start the service :
sudo service mongodb start - Using the CLI, create a new user for the database :
db.createUser({user: "u", pwd: "p", roles: ["readWrite", "dbAdmin"]}) - In the config file, enable the access by login only :
security.authorization : enabled - Restart the service :
sudo service mongodb restart - Restore the previous database content :
mongorestore dump_folder
Documentation for MongoDB configuration file
- Check the status :
sudo service mongodb status - The service command must be the following :
/usr/bin/mongod --config /etc/mongod.conf - Check the logs :
sudo tail /var/log/mongodb/mongod.log - Fix startup issue :
sudo chown -R mongodb:mongodb /var/lib/mongodb/*
- Install Git with
sudo apt install git - Generate a new SSH key on the server and bind it to your GitHub account
- Load this key at the server startup by adding these lines at the end of the
~/.bashrcfile :
# start SSH client and add RSA keys
eval "$(ssh-agent -s)" &> /dev/null
ssh-add ~/.ssh/github_rsa &> /dev/null
- Clone the GitHub project with
[email protected]:Username/Project.git
- Add
[email protected]to the cron tasks config file sudo apt install ssmtpsudo nano /etc/ssmtp/ssmtp.conf
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
mailhub=smtp_server.com:587
# Where will the mail seem to come from?
rewriteDomain=bond.com
# The full hostname
[email protected]
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
#FromLineOverride=YES
# Use SSL/TLS before starting negotiation
UseTLS=Yes
UseSTARTTLS=Yes
# Username/Password
AuthUser=james
AuthPass=secretagent
AuthMethod=LOGIN
sudo nano /etc/ssmtp/revaliases
# sSMTP aliases
#
# Format: local_account:outgoing_address:mailhub
#
# Example: root:[email protected]:mailhub.your.domain[:port]
# where [:port] is an optional port number that defaults to 25.
james:[email protected]:smtp_server.com:587
- test the configuration by trying to send an email with
echo "Subject: hello" | sendmail [email protected]
- Install Apache 2 :
sudo apt install apache2 - Enable proxy and rewrite module :
sudo a2enmod proxy_http rewrite headersthen restart Apache :sudo service apache2 restart - Create new config file in /etc/apache2/sites-available with following content :
<VirtualHost bond.com:80>
ServerName bond.com
ServerAdmin [email protected]
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
- Enable the virtual host :
sudo a2ensitethensudo service apache2 reload - Install Certbot to enable HTTPS :
sudo apt install certbot python-certbot-apache - Install or renew HTTPS certificates :
sudo certbot - List all HTTPS certificates :
sudo certbot certificates