linux-安装nginx

1、下载安装pcre库
  pcre是一个正则表达式库,nginx的rewrite模块需要依赖该库。
  下载地址:http://www.pcre.org/

wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz
tar -zxvf pcre-8.40.tar.gz
cd pcre-8.40
./configure 
make
make install

2、下载安装nginx
   下载地址:http://nginx.org/

wget http://nginx.org/download/nginx-1.8.1.tar.gz
tar -zxvf nginx-1.8.1.tar.gz
cd nginx-1.8.1
./configure
make    
make install

3、验证安装是否成功

   默认安装路径:/usr/local/nginx

      建立软链接(配置启动命令,不管在哪级目录,都可以采用nginx直接操作命令):

ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/nginx(操作命令名称)

     执行nginx命令验证是否安装成功:

nginx -t

     安装成功:

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

注:本随笔来自https://segmentfault.com/a/1190000013065982

相关推荐