一、ubuntu server 14 下 nginx 环境搭建

前言:本来想在mac上直接安装配置,后来想想不般很少用mac做服务器,于是改用在linux下,正好学习使用linnux;

环境:ubuntu server 14
这里我要说明一下,yum 与 apt-get,
ap-get是ubuntu下的一个软件安装方式,它是基于debain
yum是redhat、centos下的一个软件安装方式,它是基于Linux的
两者的详细说明网上有很多说明,我也是网上找的,我的是ubuntu  所以我用的是 apt-get

方式一,网络安装
=>apt-get install nginx
简单、粗暴,保持网络畅通,一个命令搞定。

方式二,编译源码安装。编译源码安装,所以要先准备编译环境和所用到程序库,
1、编译环境和程序库---------------------------
我遇到的:
=>apt-get install libpcre3 libpcre3-dev
=>apt-get install openssl libssl-dev
可能需要
=>apt-get install build-essential
=>apt-get install libtool
=>apt-get update
=>apt-get install zlib1g-dev
=>apt-get install gcc-c++
注:这些只是我在安装过程中遇到的,可能环境、版本不同会需要不同的编译和程序库,建议直接编译安装,然后根据提示,把所需要的环境的库一个个的安装上;
2、安装 ---------------------------
建议安装前添加一个用户组
=>groupadd -r nginx
=>useradd -r -g nginx -M nginx
解压nginx压缩包,
cd 到解压目录
=>./configure \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-client-body-temp-path=/var/tmp/nginx/client/ \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--with-pcre
=>make && make install
=>mkdir -p /var/tmp/nginx/client

=>nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
说明安装成功

注:我安装时遇到的错误

1、ubuntu安装nginx时提示error: the HTTP rewrite module requires the PCRE library
解决方法:
需要安装pcre包。
sudo apt-get update
sudo apt-get install libpcre3 libpcre3-dev
你可能还需要安装 
sudo apt-get install openssl libssl-dev


-------------------------------------------------------------------
若有其他凝问或文中有错误,请及时向我指出,
我好及时改正,同时也让我们一起进步。
email : [email protected]
qq     : 1035862795
敲门砖: 代码谱写人生

猜你喜欢

转载自binary-space.iteye.com/blog/2356973