<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Paulwratt</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Paulwratt"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Paulwratt"/>
	<updated>2026-04-26T14:24:18Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx&amp;diff=18012</id>
		<title>Nginx</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx&amp;diff=18012"/>
		<updated>2020-08-19T10:38:39Z</updated>

		<summary type="html">&lt;p&gt;Paulwratt: updated (in-page) anchor links for seemless transition&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://nginx.org/en/ Nginx] (engine x) is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
Nginx package is available in the Alpine Linux repositories. To install it run:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk update&lt;br /&gt;
apk add nginx}}&lt;br /&gt;
&lt;br /&gt;
Creating new user and group &#039;www&#039; for nginx&lt;br /&gt;
{{Cmd|adduser -D -g &#039;www&#039; www}}&lt;br /&gt;
&lt;br /&gt;
Create a directory for html files&lt;br /&gt;
{{Cmd|mkdir /www&lt;br /&gt;
chown -R www:www /var/lib/nginx&lt;br /&gt;
chown -R www:www /www&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
You may want to make backup of original nginx.conf file before writting your own&lt;br /&gt;
{{Cmd|mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig}}&lt;br /&gt;
&lt;br /&gt;
Configuring Nginx to listen to port 80 and process .html or .htm files&lt;br /&gt;
{{Cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user                            www;&lt;br /&gt;
worker_processes                auto; # it will be determinate automatically by the number of core&lt;br /&gt;
&lt;br /&gt;
error_log                       /var/log/nginx/error.log warn;&lt;br /&gt;
#pid                             /var/run/nginx/nginx.pid; # it permit you to use /etc/init.d/nginx reload|restart|stop|start&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections          1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include                     /etc/nginx/mime.types;&lt;br /&gt;
    default_type                application/octet-stream;&lt;br /&gt;
    sendfile                    on;&lt;br /&gt;
    access_log                  /var/log/nginx/access.log;&lt;br /&gt;
    keepalive_timeout           3000;&lt;br /&gt;
    server {&lt;br /&gt;
        listen                  80;&lt;br /&gt;
        root                    /www;&lt;br /&gt;
        index                   index.html index.htm;&lt;br /&gt;
        server_name             localhost;&lt;br /&gt;
        client_max_body_size    32m;&lt;br /&gt;
        error_page              500 502 503 504  /50x.html;&lt;br /&gt;
        location = /50x.html {&lt;br /&gt;
              root              /var/lib/nginx/html;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample page ==&lt;br /&gt;
{{Cmd|vi /www/index.html}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html lang=&amp;quot;en&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;meta charset=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;HTML5&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
    Server is online&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Controlling nginx ==&lt;br /&gt;
&lt;br /&gt;
=== Start Nginx ===&lt;br /&gt;
After the installation Nginx is not running. To start Nginx, use &#039;&#039;start&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx start}}&lt;br /&gt;
&lt;br /&gt;
You will get a feedback about the status.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 * Caching service dependencies ...                     [ ok ]&lt;br /&gt;
 * /run/nginx: creating directory&lt;br /&gt;
 * /run/nginx: correcting owner                         &lt;br /&gt;
 * Starting nginx ...                                   [ ok ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Test configuration ===&lt;br /&gt;
When you&#039;ve made any changes to your nginx configuration files, you should check it for errors before restarting/reloading nginx.&amp;lt;br&amp;gt;&lt;br /&gt;
This will check for any duplicate configuration, syntax errors etc. To do this, run:&lt;br /&gt;
{{Cmd|nginx -t}}&lt;br /&gt;
&lt;br /&gt;
You will get a feedback if it failed or not. If everything is fine, you&#039;ll see the following and can then move ahead to reload the nginx server.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok&lt;br /&gt;
nginx: configuration file /etc/nginx/nginx.conf test is successful&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reload and Restart Nginx ===&lt;br /&gt;
Changes made in the configuration file will not be applied until the command to reload configuration is sent to nginx or it is restarted.&amp;lt;br&amp;gt;&lt;br /&gt;
Reloading will do a &amp;quot;hot reload&amp;quot; of the configuration without server downtime. It will start the new worker processes with a new configuration and gracefully shutdown the old worker processes. If you have pending requests, then these will be handled by the old worker processes before it dies, so it&#039;s an extremely graceful way to reload configs.&lt;br /&gt;
If you want to reload the web server, use &#039;&#039;reload&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx reload}}&lt;br /&gt;
If you want to restart the web server, use &#039;&#039;restart&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx restart}}&lt;br /&gt;
&lt;br /&gt;
=== Stop Nginx ===&lt;br /&gt;
If you want to stop the web server, use &#039;&#039;stop&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx stop}}&lt;br /&gt;
&lt;br /&gt;
=== Runlevel ===&lt;br /&gt;
Normally you want to start the web server when the system is launching. This is done by adding Nginx to the needed runlevel.&lt;br /&gt;
{{Cmd|rc-update add nginx default}}&lt;br /&gt;
&lt;br /&gt;
Now Nginx should start automatically when you boot your machine next time. To test that run:&lt;br /&gt;
{{cmd|reboot}}&lt;br /&gt;
&lt;br /&gt;
To make sure that Nginx is started run:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;ps aux | grep nginx&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You should get something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  263 root       0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf&lt;br /&gt;
  264 www        0:00 nginx: worker process&lt;br /&gt;
  310 root       0:00 grep nginx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Nginx ==&lt;br /&gt;
This section is assuming that nginx is running and sample html page &amp;quot;/www/index.html&amp;quot; is created. Launch a web browser and point it to your web server.&lt;br /&gt;
You should get:&lt;br /&gt;
&amp;lt;pre&amp;gt;Server is online&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If Nginx is not started check Nginx log file&lt;br /&gt;
{{cmd|less /var/log/nginx/error.log}}&lt;br /&gt;
&lt;br /&gt;
Make sure that configuration file does not contain errors. Edit the file in case there are any errors.&lt;br /&gt;
{{cmd|nginx -t&lt;br /&gt;
vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&lt;br /&gt;
== Nginx with PHP ==&lt;br /&gt;
&lt;br /&gt;
[[Nginx_with_PHP#Configuration_of_PHP5|Setting Up Nginx with PHP5]] &amp;lt;br&amp;gt;&lt;br /&gt;
[[Nginx_with_PHP#Configuration_of_PHP7|Setting Up Nginx with PHP7]] &amp;lt;br&amp;gt;&lt;br /&gt;
[[Nginx_as_reverse_proxy_with_acme_(letsencrypt)|Setting Up Nginx as Reverse Proxy with acme (Let&#039;s Encrypt)]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Paulwratt</name></author>
	</entry>
</feed>