首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 软件管理 > 软件架构设计 >

ubuntu停源码方式安装nginx

2013-03-26 
ubuntu下源码方式安装nginx?????? 即将新官上任,有很多环境要自己搭建,现将自己搭建的每一个过程都记录下

ubuntu下源码方式安装nginx

?????? 即将新官上任,有很多环境要自己搭建,现将自己搭建的每一个过程都记录下来,希望给自己做个保存,也想给有同样需要的朋友提供参考,减少不必要的时间

?????? 我用的是ubuntu11.04版本,绝对是全新的环境,参照的ngxin官网的英文步骤操作的

?

nginx官网安装步骤

http://nginx.org/en/docs/install.html

?

一、准备工作

?????? a. 到ngxin官网下载nginx-1.3.14.tar.gz文件

?????? b.下载所需的库,以下在各官网都能下到,pcre、openssl、zlib,这些都是ngxin安装过程中所必须的,必须先编译安装好,或者直接用apt-get install,本人想试一下源码安装,另外以后是负责网站环境,所以还是自己安装的好

?

二、开始安装

????? 解压zlib、openssl、pcre库,供下面nginx安装使用

cd /usr/srctar zxvf zlib-1.2.7.tar.gztar zxvf openssl-1.0.1e.tar.gztar zxvf   pcre-8.21.tar.gz

?? 安装nginx

cd /usr/srctar nginx-1.3.14.tar.gz cd nginx-1.3.14./configure   --prefix=/usr/local/nginx   --with-openssl=../openssl-1.0.1e   --with-pcre=../pcre-8.21   --with-zlib=../zlib-1.2.7#这里的参数可以参考官网说明,每一项都很简单makemake install

?? 至此nginx已经安装完成,在/usr/local/nginx目录下

?? 但是ngxin还没有启动,此时先手动启动nginx

/usr/local/nginx/sbin/nginxps -e | grep nginx如果能看到nginx进程说明已经启动成功wget http://localhost进行访问已经可以访问,或者直接用浏览器访问ip地址也可以看到nginx的欢迎页面

?

?

三、将ngxin添加到服务,并且设为开机启动

cd /etc/init.dvi 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.confnginxd=/usr/local/nginx/sbin/nginxnginx_config=/usr/local/nginx/conf/nginx.confnginx_pid=/var/run/nginx.pidRETVAL=0prog="nginx"# Check that networking is up.[[ ${NETWORKING} = "no" ]] && exit 0[ -x $nginxd ] || exit 0# Start nginx daemons functions.start() {if [ -e $nginx_pid ];then   echo "nginx already running...."   exit 1fi   echo -n $"Starting $prog: "   $nginxd -c ${nginx_config}   RETVAL=$?   echo   [ $RETVAL = 0 ]   return $RETVAL}# Stop nginx daemons functions.stop() {        echo -n $"Stopping $prog: "        $nginxd -s stop        RETVAL=$?        echo        [ $RETVAL = 0 ]}# reload nginx service functions.reload() {      echo -n $"Reloading $prog: "      pkill -HUP `cat ${nginx_pid}`      #killproc $nginxd -HUP      RETVAL=$?      echo  }  # See how we were called.  case "$1" in  start)          start          ;;  stop)          stop          ;;  reload)          reload          ;;  restart)          stop          start          ;;  status)          status $prog          RETVAL=$?          ;;  *)          echo $"Usage: $prog {start|stop|restart|reload|status|help}"          exit 1  esac  exit $RETVAL保存退出chmod u+x nginx此时服务nginx已经添加,以下命令就可以了service nginx startservice nginx stopservice nginx restartservice nginx reloadservice nginx statusservice nginx help最后把nginx设为开机启动update-rc.d -f nginx defaults这样下次重启机器的时候,nginx就会自动启动了

?

?

?

热点排行