ITPub博客

首页 > 应用开发 > IT综合 > 源码安装Nginx

源码安装Nginx

IT综合 作者:dbasdk 时间:2014-09-29 15:31:46 0 删除 编辑
在15所工作的时候,用Apache反向代理几个Tomcat就觉得很高大上了。
今天同事说这玩意早过时了。
还好Apache我其实也不熟,一切从头来吧。

源码下载地址:
http://nginx.org/en/download.html
http://nginx.org/download/nginx-1.6.2.tar.gz

创建一个nginx用户,解压源码
[root@slaveOne ~]# useradd -m nginx
[root@slaveOne ~]# cp nginx-1.6.2.tar.gz /home/nginx/
[root@slaveOne ~]# cd /home/nginx/
[root@slaveOne nginx]# tar -zxvf nginx-1.6.2.tar.gz 
nginx-1.6.2/
nginx-1.6.2/auto/
nginx-1.6.2/conf/
......

安装依赖包
yum -y install gcc automake autoconf libtool make gcc-c++ pcre* zlib openssl openssl-devel


重命名源码目录(因为我想让编译后的目录为nginx-1.6.2)
[root@slaveOne nginx]# ls
nginx-1.6.2  nginx-1.6.2.tar.gz
[root@slaveOne nginx]# mv nginx-1.6.2 nginx

进入源码目录
[root@slaveOne nginx]# cd nginx
[root@slaveOne nginx]# ls
auto  CHANGES  CHANGES.ru  conf  configure  contrib  html  LICENSE  man  README  src

以root帐号执行如下命令
./configure \
--prefix=/home/nginx/nginx-1.6.2 \
--sbin-path=/home/nginx/nginx-1.6.2/nginx \
--conf-path=/home/nginx/nginx-1.6.2/nginx.conf \
--pid-path=/home/nginx/nginx-1.6.2/nginx.pid \
--with-http_ssl_module 

多线程编译,安装
make -j `cat /proc/cpuinfo | grep processor| wc -l` && make install

安装完成,查看目标文件


修改nginx.conf配置文件
user  nginx;


查看进程
[root@slaveOne nginx-1.6.2]# ps -ef | grep nginx
root      8792     1  0 15:45 ?        00:00:00 nginx: master process ./nginx
nginx     8793  8792  0 15:45 ?        00:00:00 nginx: worker process


参考:
http://www.nginx.cn/install

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29734436/viewspace-1284876/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-07-02

  • 博文量
    490
  • 访问量
    1388125