一、简介
NGINX is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server
二、安装
# centos
sudo vi /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/7/$basearch/
gpgcheck=0
enaled=1
sudo yum install nginx
sudo systemctl enable nginx
sudo systemctl start nginx
# 配置文件目录位置
/etc/nginx/conf.d
# 日志文件目录位置
/var/log/nginx
三、Sample
# Serving Static Content
# http://localhost/images/example.png --> /data/images/example.png
location /images/ {
root /data;
}
# Setting Up a Simple Proxy Server
location / {
proxy_pass http://localhost:8080;
}
# regular expression
location ~ \.(gif|jpg|png)$ {
root /data/images;
}
## reloading the configuration file ##
nginx -s reload
四、Feature
1、测试
测试配置文件的正确性:
nginx -t -c /etc/nginx/nginx.conf