Nginx - cruisechang/wiki-linux GitHub Wiki
Basic
Install sudo yum install nginx
Config directory is in /etc/nginx/
Global config file /etc/nginx/nginx.conf
Server blocks config directory is in /etc/nginx/conf.d/
Default server blocks config directory is in /etc/nginx/conf.d/default.conf
Default document root is /urs/share/nginx/html
systemctl start nginx
systemctl stop nginx
systemctl status nginx
systemctl enable nginx (Enable daemon)
Server Blocks
Make a xxxx.conf file in /etc/nginx/conf.d/ with .conf ext will be loaded.
Create and Grant Dir Permissions
sudo mkdir -p /var/www/example.com/html
Grant dir permissions
sudo chown -R $USER:$USER /var/www/example.com/html (root dir)
sudo chown -R $USER:$USER /var/www/example2.com/html (root dir)
The $USER variable will take the value of the user you are currently logged in as when you submit the command.
By doing this, our regular user now owns the public_html subdirectories where we will be storing our content.
modify our permissions a little bit to ensure that read access is permitted to the general web directory,
and all of the files and folders inside, so that pages can be served correctly:
sudo chmod -R 755 /var/www
###Include new server blocks in /etc/nginx/nginx.conf
Add these lines to the end of the http {} block:
include /etc/nginx/sites-enabled/*.conf;
server_names_hash_bucket_size 64;
##Enable Gzip Compression and Uncompression Official
Edit /etc/nginx/nginx.conf
gzip on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k;
gzip_min_length 1000;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gunzip on;