This is an opinionated memo that lists the steps to set up an Ubuntu server for web service or website.
1. General Initialization
The step 1 is what I will do for all new servers, even for my personal Linux laptop.
1.1 Update Server first
1 | # This step may take some time, just be patient |
When this step is done, you can restart your server. But usually, I will restart after I have everything installed.
1.2 Install Basic Tools
1 | # Maybe most of them are already bundled with Ubuntu |
I really like zsh
, and I will also enable oh-my-zsh. But this is optional, even I highly recommend it.
2. Setup for Web Server
2.1 Install Necessary Software
1 | sudo apt install openjdk-11-jre mariadb-server nginx |
Java
I install open Java 11 here, based on your own requirement, you can either install Java 8 or Java 14, whatever you want. The reason why I just install JRE not JDK is because I will only need Java Runtime in this server, and I will never try to compile or build any Java projects.
1 | # Check whether java is installed correctly |
MariaDB
It is almost the same as MySQL. Personally, I choose Mariadb these days. An important reason is that they have different licenses.
If you take Open Source seriously, this is something that you should care. 如何选择开源许可证
Configure MariaDB
1 | sudo mysql_secure_installation |
Verify MariaDB
1 | # You should see similar output as below: |
NginX
As a reverse proxy, NginX is very helpful. Usually, I use it as a load balancer.
Simply open http://your-server-ip
, you will see a page showing these words
1 | Welcome to nginx! |