今天是: 收藏本站 设为主页
网站首页 >  技术专栏  >  linux  > 

Ubuntu编译Nginx

日期:2013-07-19  点击率:775


之前在一台VPS编译了Nginx环境,1G内存,Ubuntu 12.04 Server版64位。

首先安装基础编译环境:

1 ##g++在CentOS服务器叫做gcc-c++
2 sudo apt-get install gcc g++ automake make

Wget最新版的Nginx源码,切换到文件夹开始编译,在不添加编译参数的情况下会以此出现下属三个错误:

错误一: 缺少 pcre library
./configure: error: the HTTP rewrite module requires the PCRElibrary.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.

错误二: 缺少 openssl 库
./configure: error: the HTTP cache module requires md5 functions from OpenSSL library. You can either disable the module by using --without-http-cache option, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-http_ssl_module --with-openssl= options.

错误三: 缺少 zlib 库
./configure: error: the HTTP gzip module requires the zlib library. You can either disable the module by using --without-http_gzip_module option, or install the zlib library into the  system, or build the zlib library statically from the source with nginx by using --with-zlib= option.

则按照错误依次编译三个缺少的库,其他报错类推:

1 sudo apt-get install libpcre3-dev libssl-dev openssl

安装 chkconfig :

1 sudo apt-get install chkconfig ##自启动

最后编译Nginx即可:

01 ## 均采用默认配置,也可以按启用添加自己的扩展
02 sudo ./configure –prefix=/usr/local/nginx
03 sudo make && make install
04     
05 ## 显示下列则编译成功
06 Configuration summary
07   + using system PCRE library
08   + OpenSSL library is not used
09   + md5: using system crypto library
10   + sha1: using system crypto library
11   + using system zlib library
12     
13   nginx path prefix: "/usr/local/nginx"
14   nginx binary file"/usr/local/nginx/sbin/nginx"
15   nginx configuration prefix: "/usr/local/nginx/conf"
16   nginx configuration file"/usr/local/nginx/conf/nginx.conf"
17   nginx pid file"/usr/local/nginx/logs/nginx.pid"
18   nginx error log file"/usr/local/nginx/logs/error.log"
19   nginx http access log file"/usr/local/nginx/logs/access.log"
20   nginx http client request body temporary files: "client_body_temp"
21   nginx http proxy temporary files: "proxy_temp"
22   nginx http fastcgi temporary files: "fastcgi_temp"
23   nginx http uwsgi temporary files: "uwsgi_temp"
24   nginx http scgi temporary files: "scgi_temp"

建立软链接并启动Nginx(可选):

1 ##建立软链接
2 sudo ln -s /usr/local/nginx/sbin/nginx /etc/init.d/
3 ##启动nginx
4 /etc/init.d/nginx

Job Done!





下一篇:HTML 网页背景图片根据屏幕大小CSS自动缩放   上一篇:简化开发任务的20个JavaScript类库