Linux下安装Nginx1.9.3

操作系统:CentOS6.5 64bit

Nginx: 1.9.3

1、下载Nginx

[[email protected] softs]# wget http://nginx.org/download/nginx-1.9.3.tar.gz

2、安装依赖的库

[[email protected] softs]# yum -y install gcc automake autoconf libtool make  libxml2-devel libxslt-devel perl-devel perl-ExtUtils-Embed
[[email protected] softs]# yum install gcc gcc-c++

3、安装pcre,用于重写rewrite

[[email protected] softs]# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.gz 

  将pcre安装到 /usr/local/src

[[email protected] softs]# cd /usr/local/src/
[[email protected] src]# tar pcre-8.37.tar.gz
[[email protected] src]# cd pcre-8.37
[[email protected] pcre-8.37]# ./configure
[[email protected] pcre-8.37]# make
[[email protected] pcre-8.37]# make install

4、安装zlib,用于gzip压缩

  安装到/usr/local/src

[[email protected] src]# wget http://zlib.net/zlib-1.2.8.tar.gz
[[email protected] src]# tar -zxv zlib-1.2.8.tar.gz 
[[email protected] src]# cd zlib-1.2.8
[[email protected] zlib-1.2.8]# ./configure
[[email protected] zlib-1.2.8]# make
[[email protected] zlib-1.2.8]# make install

5、安装openssl,用于ssl

  安装到/usr/local/src

[[email protected] src]# wget http://www.openssl.org/source/openssl-1.0.2d.tar.gz
[[email protected] src]# tar -zxvf openssl-1.0.2d.tar.gz 
[[email protected] src]# cd openssl-1.0.2d

6、安装Nginx

  安装到/usr/local/nginx

[[email protected] softs]# cd /usr/local
[[email protected] local]# pwd
/usr/local
[[email protected] local]# 
[[email protected] local]# cd nginx-1.9.3
[[email protected] nginx-1.9.3]# ./configure --prefix=/usr/local/nginx
--with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.37 --with-zlib=/usr/local/src/zlib-1.2.8 --with-openssl=/usr/local/src/openssl-1.0.1d
[[email protected] nginx-1.9.3]# make
[[email protected] nginx-1.9.3]# make install

7、设置开机自启动

  在/etc/init.d/下建立nginx文件

[[email protected] init.d]# vi nginx

   写入以下内容:

#!/bin/bash
# nginx Startup script for the Nginx HTTP Server
# 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: /usr/local/nginx/logs/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 ];then
   echo "nginx already running...."
   exit 1
fi
   echo -n $"Starting $prog: "
   daemon $nginxd -c ${nginx_config}
   RETVAL=$?
   echo
   [ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
   return $RETVAL
}
# Stop nginx daemons functions.
stop() {
        echo -n $"Stopping $prog: "
        killproc $nginxd
        RETVAL=$?
        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 -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

  赋予可执行权限

[[email protected]iZ94jj63a3sZ init.d]# chmod a+x /etc/init.d/nginx

  设置开机启动

[[email protected] init.d]# chkconfig --add /etc/init.d/nginx
[[email protected] init.d]# chkconfig nginx on

  启动:

[[email protected] lib64]# service nginx start
Starting nginx:                                            [  OK  ]
[[email protected] lib64]# 

8、启动报错处理

[[email protected] init.d]# service nginx start
Starting nginx: /usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
                                                           [FAILED]

  使用ldd看nginx包含的动态函式库

[[email protected] src]# ldd $(which /usr/local/nginx/sbin/nginx)
        linux-vdso.so.1 =>  (0x00007fff89fff000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003978400000)
        libcrypt.so.1 => /lib64/libcrypt.so.1 (0x000000397b800000)
        libpcre.so.1 => not found
        libcrypto.so.10 => /usr/lib64/libcrypto.so.10 (0x00007ffd9a115000)
        libz.so.1 => /lib64/libz.so.1 (0x0000003977c00000)
        libc.so.6 => /lib64/libc.so.6 (0x0000003978000000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003977800000)
        libfreebl3.so => /lib64/libfreebl3.so (0x000000397ac00000)
        libdl.so.2 => /lib64/libdl.so.2 (0x0000003978800000)
[[email protected] src]# cd /

  可以看到  libpcre.so.1 => not found

  解决方法:

  进入/lib64目录中手动链接下

[[email protected] init.d]# cd /lib64/
[[email protected] lib64]# ln -s libpcre.so.0.0.1 libpcre.so.1

 然后再启动.

  

时间: 2024-10-21 13:38:35

Linux下安装Nginx1.9.3的相关文章

Linux下安装Nginx1.9.3-0303(本人亲手实践)

Linux下安装Nginx1.9.3 Linux操作系统 Oel 5.8 64bit 最新版Nginx: 1.9.3 最近同事让我帮忙搞 ngix,两天时间 安装.配置搞定了.继续 Nginx 1.9.3 发布下载,高性能 Web 服务器 1.下载Nginx1.9.3 下载地址: http://nginx.org/download/nginx-1.9.3.tar.gz 2.安装依赖的库 检查以下软件包是否安装 [[email protected] ~]# rpm -qa gcc gcc-4.1.

linux下安装nginx与nginx调优

linux系统为rhel5.6,nginx版本为nginx-1.1.6.tar.gz,可以到网上下载最新的安装,由于nginx是基于很多模块实现强大的功能,所以要安装并编译其他模块软件包,这里安装的模块软件包有:agentzh-encrypted-session-nginx-module-v0.02-0-gc752861.tar.gz.chunkin-nginx-module-0.23rc2.tar.gz.google-perftools-1.8.3.tar.gz.libunwind-0.99.

Nginx系列-1.Linux下安装Nginx

Nginx系列-1.Linux下安装Nginx 目录 - Nginx系列 Nginx系列-1.Linux下安装Nginx Nginx系列-2.配置LNMP(Linux.Nginx.MySQL.PHP)架构 Nginx系列-3.配置Nginx虚拟主机 Nginx系列-4.Nginx日志配置及日志切割 Nginx系列-5.配置Nginx的防盗链 Nginx系列-6.配置Nginx的HTTPS Nginx系列-7.配置Nginx使用uwsgi支持web.py框架 Nginx系列-8.配置Nginx+A

Nginx 在 Linux 下安装与搭建集群

搭建集群图例 集群搭建图如下,为了简单一点,使用一个Nginx服务器+两个Tomcat服务器,省略数据库部分: 环境说明 Linux 为 CentOS 7.2 发行版 + Java jdk 1.8 + Tomcat 1.8 + Nginx 1.15 Linux 下安装 Nginx 下载nginx的tar包 //下载tar包 wget http://nginx.org/download/nginx-1.13.7.tar.gztar -xvf nginx-1.13.7.tar.g 安装gcc依赖Ng

Linux下安装禅道管理系统7.2

提示:禅道是用PHP开发的,只要安装一个MySQL,找一个能跑PHP的web应用服务器,把禅道源代码放到里面,然后按步骤安装就可以了.不一定要用XAMPP,XAMPP只是把PHP环境和MySQL都集成了而已. 禅道简介 禅道项目管理软件(ZenTaoPMS)是一款国产的,基于ZPL协议,开源免费的项目管理软件,它集产品管理.项目管理.测试管理于一体,同时还包含了事务管理.组织管理等诸多功能,是一款功能完备的项目管理软件,完美地覆盖了项目管理的核心流程,是中小型企业项目管理的首选. 禅道项目管理软

Linux下安装搭建Memcached集群环境

Linux下安装搭建Memcached集群环境

FFmpeg在Linux下安装编译过程

转载请把头部出处链接和尾部二维码一起转载,本文出自:http://blog.csdn.net/hejjunlin/article/details/52402759 今天介绍下FFmpeg在Linux下安装编译过程,用的是CentOS, 总体过程比较顺利,就是在ffmpeg等的时间稍长点.没什么技术难点.仅当记录. 关于FFmpeg FFmpeg是一个开源免费跨平台的视频和音频流方案,属于自由软件,采用LGPL或GPL许可证(依据你选择的组件).它提供了录制.转换以及流化音视频的完整解决方案.它包

Linux下安装配置Apache服务器

Linux下安装配置Apache服务器 1. 安装Apache [[email protected] ~]# yum –y install httpd 2. 启动Apache [[email protected] ~]# systemctl start httpd 3. 查看进程 [[email protected] ~]# systemctl status httpd httpd.service - The Apache HTTP Server Loaded: loaded (/usr/lib

linux 下安装 mysql 并配置 python 开发环境

1.安装 mysql ,安装过程中将提示设置 root 用户的密码,默认可以设置为 rootadmin . $ sudo apt-get install mysql-server 2.安装 mysql 开发工具(不安装时,安装 MySQL-python 提示错误 "mysql_config not found"). $ sudo apt-get install libmysqld-dev 3.安装 python 的 mysql 库 MySQL-python (首先安装 python-d