首页 技术 正文
技术 2022年11月15日
0 收藏 546 点赞 4,123 浏览 2148 个字

系统环境:centos7

需要软件:nginx-1.3.16.tar.gz   libevent-2.0.21-stable.tar.gz  Pcre 和 pcre-devel

nginx下载地址:http://nginx.org/download/nginx-1.3.16.tar.gz

libevent下载地址:http://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz

Project 1:安装Nginx及配置环境

Step 1:安装pcre-devel,以及建立nginx用户

# yum install pcre-devel

# groupadd -r nginx

# useradd -r -g nginx -M nginx

Step 2:解压缩nginx的源码并安装

# tar -zxvf nginx-1.3.16.tar.gz -C /usr/local/src/

# cd /usr/local/src/nginx-1.3.16/

# ./configure \

–conf-path=/etc/nginx/nginx.conf \

–error-log-path=/var/log/nginx/error.log \

–http-log-path=/var/log/nginx/access.log \

–pid-path=/var/run/nginx/nginx.pid \

–lock-path=/var/lock/nginx.lock \

–user=nginx \

–group=nginx \

–with-http_ssl_module \

–with-http_flv_module \

–with-http_stub_status_module \

–with-http_gzip_static_module \

–http-client-body-temp-path=/var/tmp/nginx/client/ \

–http-proxy-temp-path=/var/tmp/nginx/proxy/ \

–http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \

–with-pcre

# make && make install

# mkdir -p /var/tmp/nginx/client

Step 3:启动Nginx服务并在客户端做测试

# /usr/local/nginx/sbin/nginx

在浏览器上输入本机ip

Project 2:实现虚拟主机

Step 1:准备工作

# ifconfig eth0:0 192.168.111.20

建立两个站点目录

# mkdir /website1

# mkdir /website2

建立两个存放日志的目录

# mkdir /var/log/nginx/website1

# mkdir /var/log/nginx/website2

创建两个测试页

# echo “This is website1” >/website1/index.html

# echo “This is website2” >/website2/index.html

Step 2:修改配置文件,原有的配置文件中默认有一个server节点,修改一下,然后再添加一个server节点

server {

listen 192.168.111.10:80;

server_name localhost;

#charset koi8-r;

access_log /var/log/nginx/website1/access.log;

error_log /var/log/nginx/website1/error.log;

location / {

root /website1;

index index.html index.htm;

}

error_page 404 /404.html;

# redirect server error pages to the static page /50x.html

#

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

}

server {

listen 192.168.111.20:80;

server_name localhost;

#charset koi8-r;

access_log /var/log/nginx/website2/access.log;

error_log /var/log/nginx/website2/error.log;

location / {

root /website2;

index index.html index.htm;

}

error_page 404 /404.html;

# redirect server error pages to the static page /50x.html

#

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root html;

}

}

此文件在Nginx安装目录下的conf里面的nginx.conf里面修改

Step 3:s使用 ./nginx -s reload重新装在配置

在终端里面进入到nginx目录下的sbin,然后使用: ./nginx -s reload 命令进行重新装载配置

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,090
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,567
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,415
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,187
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,823
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,906