This is a machine-translated text that may contain errors!
🚧🚧 Work in progress! 🚧🚧
- Commands:
sudo,apt,cd,nano - Software:
nginx,apache2
Process for Installation
Before we can install the software, we need to update the APT(itude) package list (“the app store” for Linux):
sudo apt update
# Oppdaterer pakkelisten
Then we can install the desired software. Here we will install nginx, which is a very popular web server, but a popular alternative is also apache2.
sudo apt install nginx
# Installerer Nginx webserveren
# Installs the Nginx web server
Configuration of web server and files
We usually find configuration files in /etc/<program name>/. For nginx, this is therefore /etc/nginx/. We don’t need to look at this now, but if you want to change something in the configuration, such as port, extra web servers, SSL certificates and so on, this is where you should do it.
Web files, i.e. HTML, CSS, JavaScript and so on, are usually located in /var/www/html/. Here you can add your own files. For example, you can create an index.html file here with some simple HTML code.
cd /var/www/html/
sudo nano index.html
# Endre index.html filen
nano - A little about the text editor
Nano is a very basic text editor that can be used in the terminal. It is easy to use and requires little prior knowledge.
Some basic commands:
CTRL + S- Save the fileCTRL + X- Exit nano
If you press CTRL + X without saving, it will ask if you want to save the file. Press Y for yes, N for no. Then press ENTER to confirm the filename.
Starting and stopping the web server
Once the installation is complete, we can start the web server with:
sudo systemctl start nginx
# Starter nginx-tjenesten.
systemctl - what is it?
systemctl means “system control” and is a tool for controlling system services in Linux. It is used to start, stop, restart and check the status of services running in the background on the system.
systemctl start | stop | restart | status <servicename>
Then visit http://<server-ip-address>/ in your browser to see if the web server is running.
Finding the server’s IP address
To find the IP address of your server, you can use the command:
hostname -I # Capital I
Alternatively, you can use ip a or ifconfig, but these provide more information than just the IP address.
