linux系统安装nginx

 

centos平台编译环境使用如下指令

  安装make:

yum -y install gcc automake autoconf libtool make

  安装g++:

yum install gcc gcc-c++

 

一、选定安装文件目录

cd /usr/local/src

  

二、安装PCRE库

cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz 
tar -zxvf pcre-8.37.tar.gz
cd pcre-8.34
./configure
make
make install

三、安装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

四、安装openssl(某些vps默认没装ssl)

cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
tar -zxvf openssl-1.0.1t.tar.gz

五、安装nginx

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

六、加载nginx.conf报错

./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

ln -s /usr/local/lib/libpcre.so.1 /lib64

七、加载nginx.conf配置

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

如果报错

nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error.log" failed (2: No such file or directory)
2019/05/24 17:55:48 [emerg] 22236#0: open() "/usr/local/nginx/logs/access.log" failed (2: No such file or directory)

1.在nginx下创建logs目录

2.在logs目录下创建access.log文件和error.log文件

再执行下加载nginx.conf的命令

 

八、启动nginx(sbin目录)

./nginx -s reload

安装完成

posted @ 2019-05-24 10:22  封海龙  阅读(161)  评论(0编辑  收藏  举报