首页 理论教育 Nginx安装与调试:实践分享

Nginx安装与调试:实践分享

时间:2023-11-02 理论教育 版权反馈
【摘要】:安装Nginx时报错错误提示:./configure:error:the HTTP rewrite module requires the PCRE library.安装pcre-devel解决问题#yum-y install pcre-devel错误提示:./configure:error:the HTTP cache module requires md5 functions from OpenSSL library.You can either disable the module by using--without-http-cache option,or install the OpenSSL library into the system,or build the OpenSSL library statically from the source with nginx by using--with-http_ssl_module--with-openssl=<path>options.解决办法:#yum-y install openssl openssl-devel或者一并安装:#yum-y install pcre-devel openssl openssl-devel?安装成功查看nginx进程# ps aux|grep nginx测试页面,直接输入服务器ip其实nginx默认的web工作目录在/usr/local/nginx/html可以修改nginx的配置文件nginx.conf改变到其他路径?

Nginx安装与调试:实践分享

linux版本:64位CentOS 6.4

Nginx版本:Nginx1.8.0

1.编译安装Nginx

官网:http://wiki.nginx.org/Install

下载:http://nginx.org/en/download.html

# wget http://nginx.org/download/nginx-1.8.0.tar.gz

# tar-zvxf nginx-1.8.0.tar.gz

# cd./nginx-1.8.0

# ./configure--prefix=/usr/local/nginx

# make &&?make install?

安装Nginx时报错

错误提示:./configure:error:the HTTP rewrite module requires the PCRE library.

安装pcre-devel解决问题

# yum-y install pcre-devel

错误提示:./configure:error:the HTTP cache module requires md5 functions from OpenSSL library.You can either disable the module by using

--without-http-cache option,or install the OpenSSL library into the system,or build the OpenSSL library statically from the source with nginx by using

--with-http_ssl_module--with-openssl=<path>options.

解决办法:

# yum-y install openssl openssl-devel

或者一并安装:

# yum-y install pcre-devel openssl openssl-devel?

启动nginx

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

安装成功查看nginx进程

# ps aux|grep nginx

测试页面,直接输入服务器ip

其实nginx默认的web工作目录在/usr/local/nginx/html

可以修改nginx的配置文件nginx.conf改变到其他路径?

2.防火墙配置

注意如果你希望在本地机器例如xp访问虚拟机的网页,如果是centos6需要修改防火墙启动80端口

# cd/etc/sysconfig

修改iptables文件,或者直接用vim编辑

# vim/etc/sysconfig/iptables

添加下面一行,打开防火墙80端口:

-A INPUT-m state--state NEW-m tcp-p tcp--dport 80-j ACCEPT(www.xing528.com)

重启防火墙

# /etc/init.d/iptables restart

查看CentOS防火墙信息:/etc/init.d/iptables status

关闭CentOS防火墙服务:/etc/init.d/iptables stop?

停止nginx

查询nginx主进程号

# ps-ef|grep nginx

从容停止Nginx:

kill-QUIT主进程号

快速停止Nginx:

kill-TERM主进程号

强制停止Nginx:

pkill-9 nginx

开启目录自动显示

nginx的配置文件nginx.conf在

# cd/usr/local/nginx/conf

有时候需要开启目录自动显示功能

[cpp]view plain copy

print?

http{

include mime.types;

default_type application/octet-stream;

# 自动显示目录

autoindex on;

http{

include mime.types;

default_type application/octet-stream;

# 自动显示目录

autoindex on;

重启nginx

# /usr/local/nginx/sbin/nginx-s reload

获取安装信息

如果需要重新安装nginx,需要知道之前的安装信息

# /usr/local/nginx/sbin/nginx-V

免责声明:以上内容源自网络,版权归原作者所有,如有侵犯您的原创版权请告知,我们将尽快删除相关内容。

我要反馈