1、安装nginx
检查机器上是否安装nginx
ps -ef| grep nginx
如果有旧版,先删除nginx
yum remove nginx
安装下载安装nginx
yum install nginx
测试
nginx
报错
nginx: [emerg] socket() [::]:80 failed (97: Address family not supported by protocol)
解决
查找nginx安装地址
whereis nginx
vi /etc/nginx/conf.d/default.conf
将:
listen 80 default_server;
listen [::]:80 default_server;
改为:
listen 80;
#listen [::]:80 default_server;
启动nginx就行了。。
(首次启动需:/usr/local/nginx/sbin/nginx -c/usr/local/nginx/conf/nginx.conf)
/usr/local/nginx/sbin/nginx -s reload
检查nginx是否正常启动
ps -ef| grep nginx
从浏览器访问服务器地址
=========================================
如果从别的服务器上copy过来一个nginx,假设存放路径/usr/local/nginx/
启动nginx
/usr/local/nginx/sbin/nginx
出现错误提示:
[root@localhost lib]# error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
ldd $(which /var/www/nginx/sbin/nginx)
查看是否有not found:
linux-vdso.so.1 => (0x00007fff773ff000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003903a00000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x0000003906a00000)
libpcre.so.3 => not found
libssl.so.1.0.0 => not found
libcrypto.so.1.0.0 => not found
libz.so.1 => /lib64/libz.so.1 (0x0000003903200000)
libc.so.6 => /lib64/libc.so.6 (0x0000003903600000)
/lib64/ld-linux-x86-64.so.2 (0x0000003902e00000)
libfreebl3.so => /lib64/libfreebl3.so (0x0000003906e00000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003903e00000)
根据对应的not found 去安装依赖环境 创建链接等
ln -s /usr/local/lib/libpcre.so.1 /lib64/