龙空技术网

基础教程:Linux 环境下 Nginx 安装

艾编程 193

前言:

此刻看官们对“linux在线安装nginx”可能比较关注,看官们都需要了解一些“linux在线安装nginx”的相关文章。那么小编也在网络上收集了一些有关“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

tar -zxvf pcre-8.43.tar.gz

cd pcre-8.43

./configure

make

make install

3、安装 zlib

cd /usr/local/src

wget

tar -zxvf zlib-1.2.11.tar.gz

cd zlib-1.2.11

./configure

make

make install

4、安装 openssl

cd /usr/local/src

wget

tar -zxvf openssl-1.0.2e.tar.gz

cd openssl-1.0.2e

./config

make

make install

5、安装 nginx

cd /usr/local/src

wget

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

标签: #linux在线安装nginx