Outils pour utilisateurs

Outils du site


issue196:c_c

Ceci est une ancienne révision du document !


As per the previous issue (FCM#194), the instructions are here: https://ubuntu.com/tutorials/install-and-configure-nginx#1-overview

At the end of the day, it comes down to which one you prefer, but for what we will be doing, it won't matter, thus I am showing you both sides of the coin.

Now it is really as easy as:

sudo apt install nginx

Please take your time and follow along on the few pages there are, there is more I want to show you, but take your time, make sure you understand what you are doing.

Now, while that goes, just know that this method does not allow you to install modules, etc. For that, we need to build it from source. That said, for what we are about to do, it is more than enough. Once the installation has completed we can check to see if all went to plan. Type:

ps aux | grep nginx

If you see something similar to mine, you are golden (below left).

Fire up your browser and type your IP address in the address bar. If you don’t know what your IP is, simply type:

ip a

in the terminal. Here you can see mine working (bottom left).

You should also see all the config files in /etc/nginx

To see the options, you can type:

nginx -?

At any time, you can call up the nginx website for help. https://www.nginx.com/resources/wiki/start/topics/examples/initscripts/

Let’s say you try this on a different distro in a VM.

Let us continue on Ubuntu. Since nginx runs as a service, you can check it any time with the systemctl command.

Type:

systemctl status nginx

(so if it misbehaves, you can restart the service at any time.)

This is a bit of an image heavy edition, but I know I want to see that mine is exactly like the person showing me - so look at the image below.

We may need to start the service next time we boot, but that’s OK. I don’t want mine running all the time. If you do, then use systemctl enable.

If you do not see the welcome to nginx static page, you may need to start/restart the service.

Step 3, (https://ubuntu.com/tutorials/install-and-configure-nginx#3-creating-our-own-website) a.k.a. Let's get rid of the default page.#

I am going to use nano, my preference, you can use whatever editor you have installed (see image below).

Or use vi as per the instructions (bottom right).

OK, step 4 is creating a virtual host. The virtual host will serve something static from a directory on our machines. This is where I need to point out our first deviation. I do not see nginx.conf, usually this is the file I edit, but let’s run with the tutorial.

Please have a look at the default file in the path /etc/nginx/sites-enabled/ with nano. Just use normal nano, do not sudo, we just want to look and that way, should you press a key by mistake, you cannot save the error. Great, let’s create the file as per the tutorial.

Check yours against mine as per the image top right. Aaaaand just like the previous Ubuntu tutorial, it does not work.

Troubleshooting time. Type nginx -t to diagnose any configuration errors.

However, this time it did not work as I was slow. We edited our file to point to port 81, not the default 80, so we need to append :81 to the end of the IP address in the url.

Now I feel so much better showing you BOTH ways, so meet me next time for another CnC.

As always comments to: misc@fullcirclemagazine.org

issue196/c_c.1692979269.txt.gz · Dernière modification : 2023/08/25 18:01 de auntiee