Skip to content

Instantly share code, notes, and snippets.

@cedced19
Last active June 18, 2016 10:05
Show Gist options
  • Save cedced19/a7ba4382f0d67b3100eb to your computer and use it in GitHub Desktop.
Save cedced19/a7ba4382f0d67b3100eb to your computer and use it in GitHub Desktop.
Configuration of Nginx in /etc/nginx/sites-enabled
<!DOCTYPE html><html><head><meta charset="utf-8"><title>Cédric | 404</title><link href="/favicon.ico" rel="shortcut icon" type="image/x-icon"><style type="text/css">html{font-size:200%;font-family:futura-pt,sans-serif;line-height:1.5em;text-align:center}body{background-color:#34495e;color:#ecf0f1;margin:0 auto;height:100%}::selection{color:#34495e;background-color:#ecf0f1}</style></head><body><h1>Not found !</h1></body></html>
<!DOCTYPE html><html><head><meta charset="utf-8"><title>Cédric | 500</title><link href="/favicon.ico" rel="shortcut icon" type="image/x-icon"><style type="text/css">html{font-size:190%;font-family:futura-pt,sans-serif;line-height:1.5em;text-align:center}body{background-color:#34495e;color:#ecf0f1;margin:0 auto;height:100%}::selection{color:#34495e;background-color:#ecf0f1}</style></head><body><h1>There is an error in web server !</h1></body></html>

Nginx

apt-get install nginx
nano /etc/nginx/sites-enabled/default
service nginx restart

Compile from source

wget http://nginx.org/download/nginx-1.11.1.tar.gz
tar zxf nginx-1.11.1.tar.gz
cd nginx-1.11.1
./configure
make
sudo make install

Add to path

export PATH=$PATH:/usr/local/nginx/sbin

Add nginx.service

It must be save in /lib/systemd/system

systemctl daemon-reload
<!DOCTYPE html><html><head><meta charset="utf-8"><title>Raspberry Pi</title><link href="/favicon.ico" rel="shortcut icon" type="image/x-icon"><style type="text/css">html{font-size:200%;font-family:futura-pt,sans-serif;line-height:1.5em;text-align:center}body{background-color:#34495e;color:#ecf0f1;margin:0 auto;height:100%}::selection{color:#34495e;background-color:#ecf0f1}.vertical{position:absolute;top:50%;margin-top:-100px;left:50%;margin-left:-100px}a{color:inherit;border-bottom:1px dotted #FFF;text-decoration:none;cursor:pointer}</style></head><body><h1>Hello!</h1></body></html>
server {
root /www;
index index.html index.htm;
server_tokens off;
server_name localhost;
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location / {
autoindex on;
try_files $uri $uri/ =404;
}
}
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment