Let the web server run
RuSITE | caorussell | March 10, 2020, 8:40 a.m.

There are a dozen ways to build a site. WordPress is one of these good choices. It's quite easy to set up, just after a few steps' installations and you will get a beautiful site. But as a GEEK (more or less), I would rather design and code all by myself. I am not gonna use WordPress for my site, but I may show the way how to set it up later. 

Now let's keep working on the web server, Nginx and uWSGI.

vim is a code editor, which can be used on the command-line interface. It is available on almost all Linux systems and friendly to users while editing some configuration files. Try to remember the main keyboard shortcuts, and it will help much. I'm sure you will like it as I do one day.

Most Linux servers may pre-installed it. But it can be manually installed as well via the apt.

sudo apt install vim


1.uWSGI

Use the vim to create a python file for test use.

vim test.py

Save the following codes to the file. :wq!

# test.py
def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return [b"Hello World"]

Run the test.py file on server port 9000.

uwsgi --http :9000 --wsgi-file test.py

Open the test page through the web browser, and you should see the "Hello World" on it. Then go back to the terminal window, CTRL+C to stop the uWSGI.

www.caorussell.com is my domain name, here and after, please replace it by your own URL.

www.caorussell.com:9000/

2. Nginx

Check the current Nginx version.

sudo nginx -v

Start the Nginx server.

sudo /etc/init.d/nginx start
[ ok ] Starting nginx (via systemctl): nginx.service.

Check the status and make sure Nginx works well.

curl -I 127.0.0.1
HTTP/1.1 200 OK
Server: nginx/1.14.2
Date: Fri, 27 Mar 2020 05:41:47 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Fri, 27 Mar 2020 03:39:22 GMT
Connection: keep-alive
ETag: "5e7d756a-264"
Accept-Ranges: bytes

Open the test page through the web browser, and you should see the greeting from Nginx.

www.caorussell.com

Check Nginx progress.

ps -ef | grep nginx
root        84     1  0 13:37 ?        00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data    85    84  0 13:37 ?        00:00:00 nginx: worker process
www-data    86    84  0 13:37 ?        00:00:00 nginx: worker process
www-data    87    84  0 13:37 ?        00:00:00 nginx: worker process
www-data    88    84  0 13:37 ?        00:00:00 nginx: worker process
caoruss+   904   223  0 13:45 pts/0    00:00:00 grep nginx

Stop the Nginx Server.

sudo /etc/init.d/nginx stop
[ ok ] Stopping nginx (via systemctl): nginx.service.

Each of them is working well now, but what we really need is their collaboration.