nginx部署http服务(一)

来源:互联网 发布:力宇刻字机端口设置 编辑:程序博客网 时间:2024/06/05 14:44

1、安装nginx
a): 安装pcre模块–为了支持http重写模块,需要PCRElib的支持
(http://ncu.dl.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz下载一个稳定的pcre版本编译安装即可)

b): 安装nginx模块
(Nginx的下载地址:http://nginx.org/en/download.html)

c): 步骤:
pcre: ./configure –> make && make install
nginx: ./configure –prefix=/home/tmp/nginx –>make && make install
nginx安装完成后,/home/tmp/nginx目录下游conf/html/logs/sbin这几个目录

d): 配置环境变量: vim /etc/profile –> export PATH=/home/tmp/nginx/sbin:$PATH –> source /etc/profile

2、 配置http路径

//vim ../conf/nginx.confserver {    listen 80;    server_name 10.0.0.0 host-0-0;    charset utf-8;    location / {        root /home/file/; //一定要以/结尾        autoindex on;    }}

3、 安装验证和启动命令
nginx: 直接命令, 就可以启动nginx–>ps -ef | grep nginx(验证命令){如果端口配置80, 那么就需要关闭服务器上的httpd程序,否则端口被占用}

nginx -t : 检查配置文件是否正确, 这个命令可以检查nginx.conf配置文件格式、语法是否正确。如果配置文件存在错误, 则会出现相应提示。配置正确也会出现提示

nginx -s reload : 重加载/重启nginx —以新的nginx.conf配置文件中的定义

nginx -s stop : 停止nginx

参考路径