1.安装前环境准备
安装make:
# yum -y install gcc automake autoconf libtool make
安装g++:
# yum install gcc gcc-c++

2.一般都需要先装pcre, zlib,前者为了重写rewrite,后者为了gzip压缩

安装pcre
下载地址: http://www.pcre.org/
# tar -xvf pcre-8.36.tar.gz
# cd pcre-8.36
# ./configure --prefix=/usr/local/pcre
# make
# make install

安装zlib
下载地址: http://www.zlib.net/
# cd /usr/local/src
# tar -xvf zlib-1.2.8.tar.gz
# cd zlib-1.2.8
# ./configure --prefix=/usr/local/zlib
# make
# make install

安装ssl(某些vps默认没装ssl)
# cd /usr/local/src
# wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
# tar -zxvf openssl-1.0.1c.tar.gz

3.安装Nginx
# groupadd vc_php_grp
# useradd -g vc_php_grp vc_php_usr -s /bin/nologin

./configure --prefix=/usr/local/nginx \
--with-http_stub_status_module \
--user=vc_php_usr \
--group=vc_php_grp \
--with-http_gzip_static_module \
--with-zlib=/usr/local/src/zlib-1.2.8 \
--with-pcre=/usr/local/src/pcre-8.36 \
--with-openssl=/usr/local/src/openssl-1.0.1c

Configuration summary+ using PCRE library: /usr/local/src/pcre-8.36+ using OpenSSL library: /usr/local/src/openssl-1.0.1c+ using builtin md5 code+ sha1 library is not found+ using zlib library: /usr/local/src/zlib-1.2.8nginx path prefix: "/usr/local/nginx"nginx binary file: "/usr/local/nginx/sbin/nginx"nginx configuration prefix: "/usr/local/nginx/conf"nginx configuration file: "/usr/local/nginx/conf/nginx.conf"nginx pid file: "/usr/local/nginx/logs/nginx.pid"nginx error log file: "/usr/local/nginx/logs/error.log"nginx http access log file: "/usr/local/nginx/logs/access.log"nginx http client request body temporary files: "client_body_temp"nginx http proxy temporary files: "proxy_temp"nginx http fastcgi temporary files: "fastcgi_temp"nginx http uwsgi temporary files: "uwsgi_temp"nginx http scgi temporary files: "scgi_temp"

注意:
--with-openssl=/usr/local/src/openssl-1.0.1c
--with-zlib=/usr/local/src/zlib-1.2.8
--with-pcre=/usr/local/src/pcre-8.36
指向的是源码包解压的路径,而不是安装的路径,否则会报错

4.启动nginx

/usr/local/nginx/sbin/nginx

5.设置开机重启

vi /etc/init.d/nginx  (输入下面的代码)
#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# it is v.0.0.2 version.
# chkconfig: - 85 15
# description: Nginx is a high-performance web and proxy server.
#              It has a lot of features, but it's not for everyone.
# processname: nginx
# pidfile: /var/run/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/usr/local/nginx/logs/nginx.pid
RETVAL=0
prog="nginx"
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
[ -x $nginxd ] || exit 0
# Start nginx daemons functions.
start() {
if [ -e $nginx_pid ];thenecho "nginx already running...."exit 1
fiecho -n $"Starting $prog: "daemon $nginxd -c ${nginx_config}RETVAL=$?echo[ $RETVAL = 0 ] && touch /var/lock/subsys/nginxreturn $RETVAL
}
# Stop nginx daemons functions.
stop() {echo -n $"Stopping $prog: "killproc $nginxdRETVAL=$?echo[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx /var/run/nginx.pid
}
# reload nginx service functions.
reload() {echo -n $"Reloading $prog: "#kill -HUP `cat ${nginx_pid}`killproc $nginxd -HUPRETVAL=$?echo
}
# See how we were called.
case "$1" in
start)start;;
stop)stop;;
reload)reload;;
restart)stopstart;;
status)status $progRETVAL=$?;;
*)echo $"Usage: $prog {start|stop|restart|reload|status|help}"exit 1
esac
exit $RETVAL 

# chmod 775 /etc/init.d/nginx #赋予文件执行权限
# chkconfig nginx on #设置开机启动
# /etc/init.d/nginx restart #重启

在浏览器中打开服务器IP地址,测试Nginx安装是否成功。

如果你需要处理php脚本的话,还需要安装php-fpm

linux 源码安装 Nginx相关推荐

  1. linux源码安装nginx

    任务目标:源码安装nginx,作为web服务修改配置文件,让配置生效,验证配置 首先要去官网nginx.org下载一个tar包: tar xvf 解包 进入到解包出来的目录,对configure进行配 ...

  2. linux access源码,从零开始学习Linux:Day04 源码安装Nginx 。acess/status/referer

    从零开始学习Linux:Day04 源码安装Nginx .acess/status/referer 常见web服务器有IIS,apche,nginx,tomcat,tengine等等,现在nginx使 ...

  3. mysql安装 张宴_Linux_centos5 源码安装Nginx + mysql + apache + php的方法,主要依照的是张宴的一篇博文 - phpStudy...

    centos5 源码安装Nginx + mysql + apache + php的方法 主要依照的是张宴的一篇博文<http://blog.s135.com/post/366/>,安装的软 ...

  4. Linux源码安装步骤

    Linux上几乎所有的软件都经过了GPL授权,因此几乎所有的软件都会提供源码.  而一个软件要在Linux上执行,必须是二进制文件,因此当我们拿到软件源码后,需要将它编译成二进制文件才能在Linux上 ...

  5. Linux源码安装mysql 5.6.12(cmake编译)

    转载链接:http://www.2cto.com/database/201307/229260.html Linux源码安装mysql 5.6.12(cmake编译) 1.安装make编译器(默认系统 ...

  6. 源码安装nginx以及平滑升级

    源码安装nginx以及平滑升级 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 欢迎加入:高级运维工程师之路 598432640 这个博客不方便上传软件包,我给大家把软件包放到百度云 ...

  7. Linux源码安装软件

    Linux源码安装软件 源码安装:最原始最有效的安装方式 三部曲 (1)-./configure xxx 生成makefile文件,随后需要的安装信息都是从这一步中获取 (2)make 根据makef ...

  8. linux怎么用源码安装mysql,Linux源码安装mysql步骤

    创建文件夹: mkdir  /usr/local/webserver 安装必要依赖包 yum -y install gcc gcc-c++ make ncurses-devel 安装cmake包: t ...

  9. linux 源码安装 zip/unzip

    linux 源码安装 zip/unzip 场景说明 Linux服务器,没有root权限 需要使用zip/unzip,但遗憾的是服务器没有安装 解决办法 自己用源码编译 步骤 下载zip/unzip的源 ...

最新文章

  1. MYSQL 部分事务
  2. Jquery源码分析之匿名函数的自执行
  3. python类的继承--------类的基础(四)
  4. AngularJS 服务(Service)
  5. python如何在官网下载1005无标题,如何安装python cairo?
  6. 使用Freemarker实现网页静态化
  7. linux内核丢弃udp报文,UDP内核丢弃UDP数据包
  8. 如何选择HR人事管理软件?HR人事管理系统软件有哪些
  9. 色彩缤纷的python(改变字体颜色及样式)不是我写的
  10. 微信小程序头像上传(一)
  11. P1293 班级聚会
  12. SVM分类,一对多;
  13. 用net user新建用户并设置管理员
  14. 中粮粮油化工厂人员定位解决方案,解决目前化化工厂普遍问题-新导智能
  15. 云台控制协议总结(VISCA/PELCOD/PELCOP)
  16. SPDK RBD bdev性能调优
  17. MapInfo点符号的制作方法
  18. Python量化交易04——基于机器学习的交易策略
  19. 鼓励大学生创业的英文翻译,大学生创业计划书用英语怎么说
  20. Python计算两日期之间排除节假日与非上班时间的工作时间

热门文章

  1. 提高开发效率,eclipse的常用快捷键、旁门左道、系统错误小贴士
  2. JavaScript 作用域不完全指北
  3. .NET中常见的内存泄露问题——GC、委托事件和弱引用
  4. logstash 收集windows日志--解决日志不能重命名问题
  5. 无core文件根据系统日志查找 程序core信息
  6. C++根据.h文件批量生成需要的函数框架
  7. solaris10上修改最大文件句柄数
  8. mysql 取消密码警告
  9. 短视频直播一对一源码“皇冠”花落谁家
  10. 7-38 数列求和-加强版(20 分)