链接: https://pan.baidu.com/s/1i5Zm5zZ 密码: adi4
1.先安装环境
解压:
tar -xf pcre-8.39.tar.gz
进入文件
cd pcre-8.39/
配置
./configure
编译make
echo $? 如果返回0就是编译成功
安装
make install
2.安装nginx
tar xf nginx-1.10.2.tar.gz
进入文件
cd nginx-1.10.2/
先创建好你要安装的目录假设 mkdir /data/server -p
配置 ./configure –prefix=/data/server/
./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
报错显示需要gzip模块,也可以不适用这个模块
所以
可以这样安装
./configure –prefix=/data/server/ –without-http_gzip_module
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ zlib library is not used
nginx path prefix: "/data/server/"
nginx binary file: "/data/server//sbin/nginx"
nginx modules path: "/data/server//modules"
nginx configuration prefix: "/data/server//conf"
nginx configuration file: "/data/server//conf/nginx.conf"
nginx pid file: "/data/server//logs/nginx.pid"
nginx error log file: "/data/server//logs/error.log"
nginx http access log file: "/data/server//logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
编译
make
echo $? 如果返回0编译成功
安装
make install
测试
cd /data/server/sbin
./nginx -t
./nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
报错没有找到libpcre.so.1
find / -name 'libpcre.so.1'
/usr/local/lib/libpcre.so.1
/data/softs/pcre-8.39/.libs/libpcre.so.1
但是可以找到文件
ldd nginx
判断命令所需动态库
linux-vdso.so.1 => (0x00007ffdec76d000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f6be7e37000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f6be7c1a000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007f6be79e1000)
libpcre.so.1 => not found
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f6be7617000)
/lib64/ld-linux-x86-64.so.2 (0x000055f025037000)
nginx命令是在/lib/x86_64-linux-gnu/目录下查找的所以可以复制或者链接文件到这个目录
ln -s /data/softs/pcre-8.39/.libs/libpcre.so.1 /lib/x86_64-linux-gnu/
再次命令查看动态库 可以找到文件了
ldd nginx
linux-vdso.so.1 => (0x00007ffc509c3000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007ff2ebe2f000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007ff2ebc12000)
libcrypt.so.1 => /lib/x86_64-linux-gnu/libcrypt.so.1 (0x00007ff2eb9d9000)
libpcre.so.1 => /lib/x86_64-linux-gnu/libpcre.so.1 (0x00007ff2eb7bb000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007ff2eb3f1000)
/lib64/ld-linux-x86-64.so.2 (0x000055efc1915000)
再次测试
./nginx -t
nginx: the configuration file /data/server//conf/nginx.conf syntax is ok
nginx: configuration file /data/server//conf/nginx.conf test is successful
成功
./nginx
启动
netstat -tnulp
查看端口是否启动,也可以网页访问
./nginx -s reload 重载
./nginx -s stop 停止