艾编程教程:Linux 环境下 Nginx 安装

#安装说明:Nginx 安装前需要提前安装相关命令和工具包:
make 命令、gcc g++、pcre、zlib、openssl

1、安装 gcc g++

#ubuntu 环境下安装
apt-get install build-essential
apt-get install libtool
#centos 环境下安装
安装 make:
yum -y install gcc automake autoconf libtool make
安装 g++:
yum install gcc gcc-c++
安装 wget
yum -y install wget

2、安装 PCRE

cd /usr/local/src
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
tar -zxvf pcre-8.43.tar.gz
cd pcre-8.43
./configure
make
make install 
 

3、安装 zlib

cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make
make install

4、安装 openssl

cd /usr/local/src
wget http://www.openssl.org/source/old/1.0.2/openssl-1.0.2e.tar.gz
tar -zxvf openssl-1.0.2e.tar.gz
cd openssl-1.0.2e
./config
make
make install

5、安装 nginx

cd /usr/local/src
wget http://nginx.org/download/nginx-1.9.9.tar.gz
tar -zxvf nginx-1.9.9.tar.gz
cd nginx-1.9.9
./configure
make
make install

 

6、Nginx 安装完成后进行初始化配置

 

1)进入解压后 Nginx 的 conf 目录对配置文件进行初始化
vi nginx.conf
在文件的头部配置 Nginx 打开进程数
 

7、启动 Nginx 命令

进入 Nginx 的 sbin 目录
启动:./nginx
重启:./nginx -s reload
停止:./nginx -s stop
测试:./nginx -t
启动出现问题 1:
nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid”
解决命令 1:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
启动出现问题 2:
./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared
object file: No such file or directory
解决命令 2:(系统多少位验证:uname -a)
ln -s /usr/local/lib/libpcre.so.1 /lib64 ###64bit 系统命令
ln -s /usr/local/lib/libpcre.so.1 /lib ###32bit 系统命令
启动出现问题 3:
nginx: [error] open() "/usr/local/nginx/logs/nginx.pid" failed (2: No such file or
directory)
解决命令 3:
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
 
 
posted @ 2020-04-08 15:16  艾编程前端技术  阅读(164)  评论(0编辑  收藏  举报
友情链接: arry老师博客 艾编程教育 艾编程教育 关于我们 web前端学习路线 vscode视频教程全集