linux下源码安装nginx
来源:互联网 发布:天敏网络机顶盒打不开 编辑:程序博客网 时间:2024/06/08 14:08
1. 下载 官网地址:http://nginx.org/
下载压缩包 http://nginx.org/download/nginx-1.8.0.tar.gz
2. 加载linux光盘,配置仓库
3. 安装编译工具gcc等
4. 安装zlib等支持库
5. 上传压缩包到服务器,解压
7. 编译内核
8. 编写脚本nginx放入/etc/init.d/目录下:
9. 测试
下载压缩包 http://nginx.org/download/nginx-1.8.0.tar.gz
2. 加载linux光盘,配置仓库
[root@chen ~]# ls -l /dev|grep cdromlrwxrwxrwx. 1 root root 3 1月 3 20:55 cdrom -> sr0crw-rw----. 1 root cdrom 21, 0 1月 3 20:55 sg0brw-rw----. 1 root cdrom 11, 0 1月 3 20:55 sr0[root@chen ~]# mount /dev/cdrom /mntmount: block device /dev/sr0 is write-protected, mounting read-only[root@chen ~]# cat /etc/yum.repos.d/CentOS-Media.repo [c6-media]name=CentOS-$releasever - Mediabaseurl=file:///mnt/gpgcheck=1enabled=1gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6
3. 安装编译工具gcc等
[root@chen ~]# yum --disablerepo=\* --enablerepo=c6-media -y install gcc gcc-c++ autoconf automake已加载插件:fastestmirror, security设置安装进程Loading mirror speeds from cached hostfilec6-media | 4.0 kB 00:00 ... 包 gcc-4.4.7-11.el6.i686 已安装并且是最新版本解决依赖关系--> 执行事务检查---> Package autoconf.noarch 0:2.63-5.1.el6 will be 安装---> Package automake.noarch 0:1.11.1-4.el6 will be 安装---> Package gcc-c++.i686 0:4.4.7-11.el6 will be 安装--> 处理依赖关系 libstdc++-devel = 4.4.7-11.el6,它被软件包 gcc-c++-4.4.7-11.el6.i686 需要--> 执行事务检查---> Package libstdc++-devel.i686 0:4.4.7-11.el6 will be 安装--> 完成依赖关系计算... ... ... ...已安装: autoconf.noarch 0:2.63-5.1.el6 automake.noarch 0:1.11.1-4.el6 gcc-c++.i686 0:4.4.7-11.el6 作为依赖被安装: libstdc++-devel.i686 0:4.4.7-11.el6 完毕!
4. 安装zlib等支持库
[root@chen ~]# yum --disablerepo=\* --enablerepo=c6-media -y install zlib zlib-devel openssl openss-devel pcre-devel已加载插件:fastestmirror, security设置安装进程... ... ... ...已安装: pcre-devel.i686 0:7.8-6.el6 完毕!
5. 上传压缩包到服务器,解压
[root@chen ~]# lsanaconda-ks.cfg install.log install.log.syslog nginx-1.8.0.tar.gz[root@chen ~]# tar -zxvf nginx-1.8.0.tar.gz nginx-1.8.0/nginx-1.8.0/auto/nginx-1.8.0/conf/
... ... ... ...
Configuration summary + using system PCRE library + using system OpenSSL library + md5: using OpenSSL library + sha1: using OpenSSL library + using system zlib library nginx path prefix: "/usr" nginx binary file: "/usr/sbin/nginx" nginx configuration prefix: "/etc/nginx" nginx configuration file: "/etc/nginx/nginx.conf" nginx pid file: "/var/run/nginx/nginx.pid" nginx error log file: "/var/log/nginx/error.log" nginx http access log file: "/var/log/nginx/access.log" nginx http client request body temporary files: "/var/tmp/nginx/client" nginx http proxy temporary files: "/var/tmp/nginx/proxy" nginx http fastcgi temporary files: "/var/temp/nginx/fcgi" nginx http uwsgi temporary files: "uwsgi_temp" nginx http scgi temporary files: "scgi_temp"
7. 编译内核
[root@chen nginx-1.8.0]# make && make installmake -f objs/Makefilemake[1]: Entering directory `/root/nginx-1.8.0'cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/event -I src/event/modules -I src/os/unix -I objs \-o objs/src/core/nginx.o \src/core/nginx.c... ... ... ...make[1]: Leaving directory `/root/nginx-1.8.0'
8. 编写脚本nginx放入/etc/init.d/目录下:
#!/bin/sh## nginx Startup script for nginx## chkconfig: - 85 15# processname: nginx# config: /etc/nginx/nginx.conf# config: /etc/sysconfig/nginx# pidfile: /var/run/nginx.pid# description: nginx is an HTTP and reverse proxy server#### BEGIN INIT INFO# Provides: nginx# Required-Start: $local_fs $remote_fs $network# Required-Stop: $local_fs $remote_fs $network# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: start and stop nginx### END INIT INFO# Source function library.. /etc/rc.d/init.d/functionsif [ -L $0 ]; then initscript=`/bin/readlink -f $0`else initscript=$0fisysconfig=`/bin/basename $initscript`if [ -f /etc/sysconfig/$sysconfig ]; then . /etc/sysconfig/$sysconfigfinginx=${NGINX-/usr/sbin/nginx}prog=`/bin/basename $nginx`conffile=${CONFFILE-/etc/nginx/nginx.conf}lockfile=${LOCKFILE-/var/lock/nginx.lock}pidfile=${PIDFILE-/var/run/nginx/nginx.pid}SLEEPMSEC=${SLEEPMSEC-200000}UPGRADEWAITLOOPS=${UPGRADEWAITLOOPS-5}RETVAL=0start() { echo -n $"Starting $prog: " daemon --pidfile=${pidfile} ${nginx} -c ${conffile} RETVAL=$? echo [ $RETVAL = 0 ] && touch ${lockfile} return $RETVAL}stop() { echo -n $"Stopping $prog: " killproc -p ${pidfile} ${prog} RETVAL=$? echo [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}}reload() { echo -n $"Reloading $prog: " killproc -p ${pidfile} ${prog} -HUP RETVAL=$? echo}upgrade() { oldbinpidfile=${pidfile}.oldbin configtest -q || return echo -n $"Starting new master $prog: " killproc -p ${pidfile} ${prog} -USR2 echo for i in `/usr/bin/seq $UPGRADEWAITLOOPS`; do /bin/usleep $SLEEPMSEC if [ -f ${oldbinpidfile} -a -f ${pidfile} ]; then echo -n $"Graceful shutdown of old $prog: " killproc -p ${oldbinpidfile} ${prog} -QUIT RETVAL=$? echo return fi done echo $"Upgrade failed!" RETVAL=1}configtest() { if [ "$#" -ne 0 ] ; then case "$1" in -q) FLAG=$1 ;; *) ;; esac shift fi ${nginx} -t -c ${conffile} $FLAG RETVAL=$? return $RETVAL}rh_status() { status -p ${pidfile} ${nginx}}# See how we were called.case "$1" in start) rh_status >/dev/null 2>&1 && exit 0 start ;; stop) stop ;; status) rh_status RETVAL=$? ;; restart) configtest -q || exit $RETVAL stop start ;; upgrade) rh_status >/dev/null 2>&1 || exit 0 upgrade ;; condrestart|try-restart) if rh_status >/dev/null 2>&1; then stop start fi ;; force-reload|reload) reload ;; configtest) configtest ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest}" RETVAL=2esacexit $RETVAL
9. 测试
[root@chen ~]# chkconfig --add nginx[root@chen ~]# chkconfig --list nginxnginx 0:关闭1:关闭2:启用3:启用4:启用5:启用6:关闭[root@chen ~]# service nginx start[root@chen ~]# service nginx stop停止 nginx: [确定]
0 0
- linux下 源码安装nginx
- linux下源码安装nginx
- linux下安装源码Nginx
- linux下PHP5.3.5+nginx源码安装
- Linux下源码安装Nginx的步骤
- Linux下源码安装nginx-1.9.11
- Linux下nginx源码包安装
- Linux下源码安装Nginx的步骤
- Linux下源码安装nginx-1.9.11
- Linux下nginx源码包安装
- linux下源码包安装nginx
- linux下通过源码编译安装Nginx
- Linux下源码安装Nginx服务器
- linux/centos下安装nginx(rpm安装和源码安装)
- linux源码安装nginx
- nginx--linux下安装nginx
- Linux下源码方式安装Nginx和PHP(FastCGI)
- linux下php源码安装(nginx服务器篇)
- Nginx简介
- ldr与adr的区别
- 算法洗脑系列(8篇)——第五篇 分治思想
- 华为机试——单词倒排
- Ubuntu挂载共享文件和虚拟硬盘
- linux下源码安装nginx
- 投稿时Cover Letter的重要性
- 指针的指针...
- 数据字典项 设计实现方案
- 前端面试题目搜集——理论知识
- ios 通知
- 重拾编程之路--leetcode(java)--删除(覆盖)指定数组元素,输出新长度
- ListView 如何判断ListView是否可以滑动(即ListView的Item总数是否超过可视区域)
- C Primer Plus学习笔记之第一,二章——预备知识