Getting our very own Nginx server running on our Alpine Linux virtual machine.
Welcome back to another tutorial from our Alpine Linux explorations tutorial series.
This time we are going to get our very own Nginx server running on our Alpine Linux virtual machine.
?We need to complete a number of steps to get it working correctly.
?1. We need to power on our Alpine Linux virtual machine from the Oracle Virtual Box Manager.
2. Once our Alpine Linux virtual machine execution environment has fully booted we are ready to begin the process – system ready.
?3. We need to open the Linux Terminal.
?4. We need to switch to the root user to run the necessary commands to install the Nginx server correctly.?
?5. We first need to update our Alpine Linux virtual machine execution environment. First, run the command ‘apk update’.
?6. We then need to run the command ‘apk upgrade’.
?7. Now the Alpine Linux virtual machine execution environment is fully updated.?
?8. We need to run the command ‘reboot’.
?9. Now we need to log back in, open the Linux Terminal again and switch to the root account. Now we can add the Nginx server packages. Please run the command ‘apk add nginx’.
10. Now we need to prepare a user and a user group for the nginx server to run correctly on our Alpine Linux execution environment. To achieve this, we need to run the command ‘adduser -D -g 'www' www’.
11. We also need to prepare a folder for the html files for our web pages. For this purpose, we need to run the following commands:
“mkdir /www”
“chown -R www:www /var/lib/nginx”
“chown -R www:www /www”
领英推荐
12. Now we need to create the nginx server configuration file and set it to listen on port 80 and use HTML files. We need to run the command ‘gedit /etc/nginx/nginx.conf’.
13. We also need to create the sample web page to be later able to check if our server is indeed running correctly. We need to run the command ‘gedit /www/index.html’.
14. Let’s start our new Nginx server running on our Alpine Linux virtual machine execution environment.
We need to run the command ‘rc-service nginx start’.
Since we already have the Apache web server running here listening on port 80, the process has failed.
We need to reconfigure the nginx server to run by listening on port 81.
We shall again run the command ‘gedit /etc/nginx/nginx.conf’.
Now the nginx server is active.
15. Now we need to add the nginx server to our system boot configuration. We shall run the command ‘rc-update add nginx default’.
Our great work is now completed.
We can now check our work and shut down our system.
See you in the next one!