suse12sp1安装nginx-1.14.0

1.下载nginx-1.14.0 http://nginx.org/en/download.html
2.上传解压

tar  -xvf   /tmp/nginx-1.14.0  -C  /usr/local/nginx/

3.先检查依赖库是否安装

rpm  -qa | grep openssl
rpm  -qa  | grep  zlib
rm  -qa  | grep pcre

4.如果openssl没有安装的话,因为我的suse12是虚拟机,挂载着镜像呢,所以可以直接grep一下看看安装包有没有,叫啥名字,然后直接zypper in 包名

zypper  pa  | grep  openssl  #看有么有相应的openssl包
i | SLES12-SP1-12.1-0 | libopenssl1_0_0                       | 1.0.1i-34.1                     | x86_64
i | SLES12-SP1 12.1-0 | libopenssl1_0_0                       | 1.0.1i-34.1                     | x86_64
i | SLES12-SP1-12.1-0 | libopenssl1_0_0-32bit                 | 1.0.1i-34.1                     | x86_64
i | SLES12-SP1 12.1-0 | libopenssl1_0_0-32bit                 | 1.0.1i-34.1                     | x86_64
  | SLES12-SP1-12.1-0 | libopenssl1_0_0-hmac                  | 1.0.1i-34.1                     | x86_64
  | SLES12-SP1 12.1-0 | libopenssl1_0_0-hmac                  | 1.0.1i-34.1                     | x86_64
  | SLES12-SP1-12.1-0 | libopenssl1_0_0-hmac-32bit            | 1.0.1i-34.1                     | x86_64
  | SLES12-SP1 12.1-0 | libopenssl1_0_0-hmac-32bit            | 1.0.1i-34.1                     | x86_64
i | SLES12-SP1-12.1-0 | openssl                               | 1.0.1i-34.1                     | x86_64
i | SLES12-SP1 12.1-0 | openssl                               | 1.0.1i-34.1                     | x86_64
  | SLES12-SP1-12.1-0 | openssl-doc                           | 1.0.1i-34.1                     | noarch
  | SLES12-SP1 12.1-0 | openssl-doc                           | 1.0.1i-34.1                     | noarch
  | SLES12-SP1-12.1-0 | openssl-ibmpkcs11                     | 1.0.0-9.2                       | x86_64
  | SLES12-SP1 12.1-0 | openssl-ibmpkcs11                     | 1.0.0-9.2                       |
zypper  in  libopenssl1_0_0-32bit

或者到https://www.openssl.org/source/,下载相应的openssl-1.1.1-pre8.tar.gz(打开比较慢,耐心等待,可以先去下载文中后面的依赖包),下载好以后上传到虚拟机/tmp下

mkdir -p /usr/local/openssl/
tar -xvf /tmp/openssl-1.1.1-pre8.tar.gz  -C  /tmp/
cd /tmp/openssl-1.1.1-pre8
./config  shared zlib --prefix=/usr/local/openssl/  && make && make  install   #在openssl-1.1.1-pre8目录下执行配置编译安装
./config  -t #执行完安装后执行这一步
make  depend
cd  /usr/local/
ln -s openssl  ssl    #建立软连接
vi  /etc/ld.so.conf 
    /usr/local/openssl/lib/   #加入这行代码
ldconfig
vi /etc/profile/
    export OPENSSL=/usr/local/openssl/bin
    export PATH=$OPENSSL:$PATH:$HOME/bin
source  /etc/profile/   #加进环境变量

5.如果zlib没有安装的话到http://www.zlib.net/ 下载

tar  -xvf   /tmp/zlib-1.2.11.tar.gz
cd  zlib-1.2.11
./configure
make
make  instal

6.如果pcre没有安装则到http://www.pcre.org/ 下载安装(最好也安装上pcre-devel),安装方法同理

tar  -xvf   pcre-8.01.tar.gz
cd  pcre-8.01
./configure
make  
make install

7.将nginx加进linux系统服务并开机启动

vi  /etc/init.d/nginx
#加进下面这些代码,本行文字可以忽略,网上其他人的脚本代码我复制进去在suse12不能用,service  nginx  start  会报错说找不到fuction,以下这段脚本代码我认为还是比较靠谱的。
#! /bin/bash
# chkconfig: 35 85 15  
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
SCRIPTNAME=/etc/init.d/$NAME
test -x $DAEMON || exit 0
d_start(){
    $DAEMON || echo -n " already running"
}
d_stop() {
    $DAEMON -s quit || echo -n " not running"
}
d_reload() {
    $DAEMON -s reload || echo -n " counld not reload"
}
case "$1" in
start)
    echo -n "Starting $DESC:$NAME"
    d_start
    echo "."
;;
stop)
    echo -n "Stopping $DESC:$NAME"
    d_stop
    echo "."
;;
reload)
    echo -n "Reloading $DESC configuration..."
    d_reload
    echo "reloaded."
;;
restart)
   echo -n "Restarting $DESC: $NAME"
    d_stop
    sleep 2
    d_start
    echo "."
;;
*)
    echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
    exit 3
;;
esac
exit 0

#然后授予可执行权限
chmod  +x  /etc/init.d/nginx
#加进开机启动项
chkconfig  --add  nginx
#开机启动
chkconfig  nginx  on

8.service nginx start
chkconfig –list nginx
9.打开虚拟机suse的桌面,再打开火狐浏览器,输入http://localhost:80即可访问

你可能感兴趣的:(nginx,nginx,suse12sp1,虚拟机)