nginx 安装配置

前言

简要描述,在linux下,安装nginx服务的步骤。

安装环境

centos7-64bit

安装步骤

一,安装依赖包
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel

二,安装pcre【支持 Rewrite 功能】
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz
tar -zxvf pcre-8.35.tar.gz
cd pcre-8.35/
./configure
make & make install
pcre-config --version

三,安装nginx
wget http://nginx.org/download/nginx-1.6.2.tar.gz
tar -zxvf nginx-1.6.2.tar.gz
cd nginx-1.6.2/
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/usr/local/pcre-8.35
make
make install

四,删除nginx-1.6.2目录
rm -rf nginx-1.6.2

五,相关命令介绍
./nginx -t 用于检测配置文件nginx.conf格式是否正确
./nginx -s reload 重新加载配置平滑重启
./nginx 启动nginx服务

nginx.conf配置

server {
listen 80;
server_name www.pandan.xyz;

location / {
root /home/lipanpan.github.io;
index index.html index.htm;
}
}