Linux环境中Nginx安装与简单配置

下载Nginx
http://nginx.org/en/download.html
Linux环境中Nginx安装与简单配置

上传安装包nginx-1.15.7.tar.gz至/usr/local目录下
解压
tar -zxvf nginx-1.15.7.tar.gz

编译
cd nginx-1.7.6
./configure

缺少依赖

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre= option.

安装依赖包
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel

再编译

./configure
make
make install
Linux环境中Nginx安装与简单配置

主要配置

server {
        listen       80;
        server_name  123.96.103.92;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html/;
            index  index.html;
        }

         location /api {
                 proxy_pass http://127.0.0.1:8181/;
         }

启动
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf