我用的阿里云上的镜像,make的时候总是出错,后来说是gcc安装不完整,要重新用下面命令安装 下:

yum install gcc gcc-c++ gcc-g77

接下来下载nginx用到的一些库

wget https://www.openssl.org/source/openssl-1.1.1b.tar.gz
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.43.tar.gz
wget http://zlib.net/zlib-1.2.11.tar.gz
wget http://nginx.org/download/nginx-1.14.2.tar.gz

   安装


1.安装pcre库

# tar xvf pcre-8.43.tar.gz -C /usr/local
# cd /usr/local/pcre-8.43
# ./configure
# make && make install

2.安装zlib库

# tar xvf zlib-1.2..tar.gz -C /usr/local
# cd /usr/local/zlib-1.2.
# ./configure
# make && make install

3.安装ssl

# tar xvf openssl-1.1.1b.tar.gz -C /usr/local
# cd /usr/local/zlib-1.2.11
# ./config
# make && make install

4.安装nginx

# tar xvf nginx-1.14.2.tar.gz -C /usr/local
# cd /usr/local/nginx-1.14.2
# ./configure --prefix=/usr/local/nginx --with-pcre=../pcre-8.43 #使用下方ssl的
# make && make install

5.加入到service

vi /etc/init.d/nginx

加入以下内容:

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: -
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid # Source function library.
. /etc/rc.d/init.d/functions # Source networking configuration.
. /etc/sysconfig/network # Check that networking is up.
[ "$NETWORKING" = "no" ] && exit

#这个地址换成自己安装的
nginx="/usr/local/nginx/sbin/nginx"
prog=$(basename $nginx)

#nginx的配置文件,也换成自己的
NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx make_dirs() {
# make required directories
user=`nginx -V >& | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
options=`$nginx -V >& | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f `
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
} start() {
[ -x $nginx ] || exit
[ -f $NGINX_CONF_FILE ] || exit
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq ] && touch $lockfile
return $retval
} stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq ] && rm -f $lockfile
return $retval
} restart() {
configtest || return $?
stop
sleep
start
} reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
} force_reload() {
restart
} configtest() {
$nginx -t -c $NGINX_CONF_FILE
} rh_status() {
status $prog
} rh_status_q() {
rh_status >/dev/null >&
} case "$1" in
start)
rh_status_q && exit
$
;;
stop)
rh_status_q || exit
$
;;
restart|configtest)
$
;;
reload)
rh_status_q || exit
$
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit
esac

7.赋于执行权限

[root@i***Z nginx]# sudo /sbin/chkconfig nginx on
[root@i***Z nginx]# sudo /sbin/chkconfig --list nginx
nginx              0:关闭    1:关闭    2:启用    3:启用    4:启用    5:启用    6:关闭
[root@i***Z nginx]# service nginx status
nginx is stopped

到此就安装完成了.


安装ssl

证书是用的阿里云免费版的,配置也是按照阿里云的配置来的,但是安装时遇到两个错误

1 .安装时未指定pcre ,ssl

未指定时出现如下错误:

while loading shared libraries: libpcre.so.: cannot open shared object file: No such file or d

所以我重新安装了一下:

./configure --prefix=/usr/local/nginx --with-pcre=../pcre-8.43 --with-openssl=../openssl-1.1.1b --with-zlib=../zlib-1.2. --with-http_ssl_module

2.证书放在哪里

刚开始是放在nginx目录下的,报的如下错误,应该放在conf文件夹下.

Starting nginx: nginx: [emerg] BIO_new_file("/usr/local/nginx/conf/cert/cert.pem") failed (SSL: error::system library:fopen:No such file or directory:fopen('/usr/local/nginx/conf/cert/cert.pem','r') error:2006D080:BIO routines:BIO_new_file:no such file)

nginx.conf文件里的ssl配置如下(阿里云文档里的):

    server {
listen ;
server_name localhost;
ssl on;
root html;
index index.html index.htm;
ssl_certificate cert/a.pem;
ssl_certificate_key cert/a.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1. TLSv1.;
ssl_prefer_server_ciphers on;
location / {
root html;
index index.html index.htm;
}
}

最后启动ok了;

[root@i***Z nginx]# service nginx start
Starting nginx: [ OK ]

centos6.8下安装nginx的更多相关文章

  1. centos6.6 下 安装 nginx

    1.安装nginx需要pcre的依赖,请安装好pcre.假设安装目录如下: /usr/local/pcre-8.38 源码目录如下: /usr/src/pcre-8.38 2.下载nginx安装压缩包 ...

  2. nginx学习之——CentOS6.0下安装nginx

    1.下载对应nginx版本 #注:下载地址:http://nginx.org/download/ wget -c http://nginx.org/download/nginx-1.10.3.tar. ...

  3. centos6.5下安装Nginx

    链接: https://www.jb51.net/article/118595.htm

  4. CentOS6.5下安装apache2.2和PHP 5.5.28

    CentOS6.5下安装apache2.2 1. 准备程序 :httpd-2.2.27.tar.gz 下载地址:http://httpd.apache.org/download.cgi#apache2 ...

  5. CentOS6.5下安装JDK1.7+MYSQL5.5+TOMCAT7+nginx1.7.5环境安装文档

    ----------------CentOS6.5下安装JDK1.7+MYSQL5.5+TOMCAT7+nginx1.7.5环境安装文档----------------------- [JDK1.7安 ...

  6. windows下安装nginx

    说起开发,自己感到非常惭愧,由于公司让我给<绿电侠>项目写整体架构解决方案,才开始接触nginx这个东东,突然觉得它是一把非常好的利器. 本文主要记录在windows下安装nginx,另参 ...

  7. 【转载】CentOS6.5_X64下安装配置MongoDB数据库

    [转载]CentOS6.5_X64下安装配置MongoDB数据库 2014-05-16 10:07:09|  分类: 默认分类|举报|字号 订阅      下载LOFTER客户端 本文转载自zhm&l ...

  8. CentOS6.5下安装配置MySQL

    CentOS6.5下安装配置MySQL,配置方法如下: 安装mysql数据库:# yum install -y mysql-server mysql mysql-deve 查看mysql-server ...

  9. linux/centos下安装nginx(rpm安装和源码安装)详细步骤

    Centos下安装nginx rpm包                                                                                 ...

随机推荐

  1. Visual Studio Code-使用Chrome Debugging for VS Code调试JS

    准备工作 安装 Debugger for Chrome 插件 按 F5(或选择菜单栏的 Debug->Start Debuging),然后选择 Chrome,就会自动创建默认的配置文件 &quo ...

  2. Delphi 二维码生成

    Delphi 二维码生成 http://download.csdn.net/detail/warrially/7370171

  3. 第一次工作->笔记:在phpstrom2019上搭建phpunit单元测试环境,php环境使用docker

    前言:公司大佬让我开发一个工具,并合并到他的工具包中,使用的是github 说明:这里的php环境使用的是laradock.感兴趣的道友自行查找. 工具:php.phpstrom.phpunit.do ...

  4. 记录XorDDos木马清理步骤

    1.检查 查看定时任务文件发现有两个异常定时任务 [root@manage ~]# cat /etc/crontab # * * * * * user-name command to be execu ...

  5. 解读vue filter

    1.全局filter, 全局的过滤一般在main.js里面使用 <div id="app"> <div> {{testVal | filVal(10,30) ...

  6. bfs(火星撞地球)

    Meteor Shower 链接:https://ac.nowcoder.com/acm/contest/997/I来源:牛客网 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 327 ...

  7. [HDU 3625]Examining the Rooms (第一类斯特林数)

    [HDU 3625]Examining the Rooms (第一类斯特林数) 题面 有n个房间,每个房间有一个钥匙,钥匙等概率的出现在n个房间内,每个房间中只会出现且仅出现一个钥匙.你能炸开门k次, ...

  8. Python : Polymorphism

    class Animal: def __init__(self, name): # Constructor of the class self.name = name def talk(self): ...

  9. Codeforces 375D D. Tree and Queries

    传送门 题意: 给一棵树,每个节点有一个颜色,询问x为根的子树,出现次数大于等于k的颜色个数. 输入格式: 第一行 2 个数 n,m 表示节点数和询问数. 接下来一行 n 个数,第 i 个数 ci ​ ...

  10. 贪心策略---买卖股票的最大收益 II

    买卖股票的最大收益 II 122. Best Time to Buy and Sell Stock II (Easy) 题目描述:   可以进行多次交易,多次交易之间不能交叉进行,可以进行多次交易. ...