现在的位置: 首页 > 综合 > 正文

linux下nginx安装详解及常见问题解决方法

2014年09月05日 ⁄ 综合 ⁄ 共 1896字 ⁄ 字号 评论关闭
来源:xiaobin_HLJ80的专栏(资源不在同一论坛,为方便自己查阅,复制写在自己博客上)  

可以通过sudo apt-get
install nginx安装的,因为自己下载tar.gz文件安装的话,还需要解决包依赖关系。

自己下载安装如下:

nginx源码安装
 
       安装环境:
 
                     操作系统:Ubuntu 12.04
 
                     Nginx:     V1.4.2
 
                     PCRE:    V8.33
 
                     zlib:         V1.2.8
 
       下载上述源包到当前用户主目录(本机:/home/tdtc100)。
 
       1. 安装zlib
 
           (1)解压缩
 
[plain] 
tdtc100@ubuntu:~$ tar zxvf zlib-1.2.8.tar.gz  
           (2)安装
 
[plain] 
tdtc100@ubuntu:~$ cd zlib-1.2.8  
tdtc100@ubuntu:~/zlib-1.2.8$ ./configure  
tdtc100@ubuntu:~/zlib-1.2.8$ make  
tdtc100@ubuntu:~/zlib-1.2.8$ sudo make install  
       2. 安装PCRE
 
           (1) 安装依赖包
 
             c++
 
[plain] 
sudo apt-get install build-essential  
            注:如果不安装,在进行(3)时,会出现:
 
[plain] 
configure: error: You need a C++ compiler for C++ support.  
          (2)解压缩
 
[plain] 
tdtc100@ubuntu:~$ tar zxvf pcre-8.33.tar.gz  
           (3)安装
 
[plain] 
tdtc100@ubuntu:~$ cd pcre-8.33  
tdtc100@ubuntu:~/pcre-8.33$ ./configure  
tdtc100@ubuntu:~/pcre-8.33$ make  
tdtc100@ubuntu:~/pcre-8.33$ sudo make install  
        3. 安装nginx
 
          (1)安装依赖包
 
            open-ssl library
 
[plain] 
sudo apt-get install libcurl4-openssl-dev  
            注:如果不安装,在进行(3)时,会出现:
 
[plain] 
./configure: error: SSL modules require the OpenSSL library.  
You can either do not enable the modules, or install the OpenSSL library  
into the system, or build the OpenSSL library statically from the source  
with nginx by using --with-openssl=<path> option.  
          (2)解压缩
 
[plain] 
tdtc100@ubuntu:~$ tar zxvf nginx-1.4.2.tar.gz  
          (3)安装
                   参考官方文档
[plain] 
tdtc100@ubuntu:~$ cd nginx-1.4.2  
tdtc100@ubuntu:~/nginx-1.4.2$ ./configure \  
> --sbin-path=/usr/local/nginx/nginx \  
> --conf-path=/usr/local/nginx/nginx.conf \  
> --pid-path=/usr/local/nginx/nginx.pid \  
> --with-http_ssl_module \  
> --with-pcre=../pcre-8.33 \  
> --with-zlib=../zlib-1.1.3  
tdtc100@ubuntu:~/nginx-1.4.2$ make  
tdtc100@ubuntu:~/nginx-1.4.2$ sudo make install  
 
 
-------------------------安装完毕-----------------------xiaobin_hlj80-------------------------------------------
 
 
 
运行:
 
[plain] 
tdtc100@ubuntu:/usr/local/nginx/sbin$ sudo ./nginx  
 
运行效果:
 

抱歉!评论已关闭.