安装及简单部署nginx服务
1.安装Nginx所需的pcre库。
Pcre全称(Perl Compatiable Regular Expressions),中文perl兼容正则表达式,官方站点为https://www.pcre.org/,
安装pcre库是为了使Nginx支持HTTP Rewrite模块。安装过程如下。
#下载编译安装。
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.zip
unzip pcre-8.41.zip
cd pcre-8.41
./configure
make && make install
echo $?
2.安装nginx
nginx的官方站点是nginx.org。
wget http://nginx.org/download/nginx-1.2.9.tar.gz
tar xf nginx-1.2.9.tar.gz
cd nginx-1.2.9
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.2.3 --with-http_stub_status_module --with-http_ssl_module
make
make install
echo $?
#建立软连接
[root@backup application]# ln -s /application/nginx-1.2.3 /application/nginx
3.启动并检查安装成果。
yum install -y openssl openssl-devel
cd /home/zxin10/tools/
wget -q http://nginx.org/download/nginx-1.6.3.tar.gz
tar xf nginx-1.6.3.tar.gz
cd nginx-1.6.3
useradd nginx -s /sbin/nologin -M
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.6.3/ --with-http_stub_status_module --with-http_ssl_module
make&&make install
ln -s /application/nginx-1.6.3 /application/nginx
/application/nginx/sbin/nginx -t
/application/nginx/sbin/nginx
lsof -i:80
#安装结果
[root@backup nginx-1.6.3]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 14664 root 6u IPv4 35434 0t0 TCP *:http (LISTEN)
nginx 14665 nginx 6u IPv4 35434 0t0 TCP *:http (LISTEN)
#用浏览器访问站点地址:http://192.168.0.251/
Welcome to nginx! 。。。
4.部署一个简单web站点。
nginx默认的站点是 /application/nginx/html下,删除掉nginx默认的首页index.html,然后新建立一个index.html,
加入如下网页内容然后保存:
[root@backup html]# cd /application/nginx/html/
[root@backup html]# cp index.html index.html.bak
[root@backup html]# vi index.html
[root@backup html]# cat index.html
HI,I am BaiZuo,I am studying nginx!
1.安装Nginx所需的pcre库。
Pcre全称(Perl Compatiable Regular Expressions),中文perl兼容正则表达式,官方站点为https://www.pcre.org/,
安装pcre库是为了使Nginx支持HTTP Rewrite模块。安装过程如下。
#下载编译安装。
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.zip
unzip pcre-8.41.zip
cd pcre-8.41
./configure
make && make install
echo $?
2.安装nginx
nginx的官方站点是nginx.org。
wget http://nginx.org/download/nginx-1.2.9.tar.gz
tar xf nginx-1.2.9.tar.gz
cd nginx-1.2.9
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.2.3 --with-http_stub_status_module --with-http_ssl_module
make
make install
echo $?
#建立软连接
[root@backup application]# ln -s /application/nginx-1.2.3 /application/nginx
3.启动并检查安装成果。
yum install -y openssl openssl-devel
cd /home/zxin10/tools/
wget -q http://nginx.org/download/nginx-1.6.3.tar.gz
tar xf nginx-1.6.3.tar.gz
cd nginx-1.6.3
useradd nginx -s /sbin/nologin -M
./configure --user=nginx --group=nginx --prefix=/application/nginx-1.6.3/ --with-http_stub_status_module --with-http_ssl_module
make&&make install
ln -s /application/nginx-1.6.3 /application/nginx
/application/nginx/sbin/nginx -t
/application/nginx/sbin/nginx
lsof -i:80
#安装结果
[root@backup nginx-1.6.3]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 14664 root 6u IPv4 35434 0t0 TCP *:http (LISTEN)
nginx 14665 nginx 6u IPv4 35434 0t0 TCP *:http (LISTEN)
#用浏览器访问站点地址:http://192.168.0.251/
Welcome to nginx! 。。。
4.部署一个简单web站点。
nginx默认的站点是 /application/nginx/html下,删除掉nginx默认的首页index.html,然后新建立一个index.html,
加入如下网页内容然后保存:
[root@backup html]# cd /application/nginx/html/
[root@backup html]# cp index.html index.html.bak
[root@backup html]# vi index.html
[root@backup html]# cat index.html
HI,I am BaiZuo,I am studying nginx!