首页 > 云知识库 > 正文

青县网站制作云服务器编译安装Nginx1.0.15,并建立vhost。
2023-05-29 21:46:15   来源:   评论:0 点击:

1)下载 nginx源码包http: nginx org en download html2)源码安装nginx tar zxvf nginx-1 0 15 tar gz cd nginx-1 0 15 conf




1)下载 nginx 源码包
http://nginx.org/en/download.html

1.png 

2)源码安装nginx
# tar zxvf nginx-1.0.15.tar.gz
# cd nginx-1.0.15
# ./configure --user=www --group=www --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --pid-path=/usr/local/nginx/run/nginx.pid --lock-path=/usr/local/nginx/lock/nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module
yum install pcre-devel perl-devel perl-ExtUtils-Embed -y
# make clean
# ./configure --user=www --group=www --prefix=/usr/local/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --pid-path=/usr/local/nginx/run/nginx.pid --lock-path=/usr/local/nginx/lock/nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_perl_module --with-mail --with-mail_ssl_module


# make
# make install
# /usr/local/apache/bin/apachectl stop
# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf     启动nginx

浏览器测试
2.png 


接下来进行源码安装PHP,请参考下面教程:
http://bbs.qcloud.com/forum.php?mod=viewthread&tid=4346&extra=page%3D1

Nginxphp整合
# vi /usr/local/nginx/conf/nginx.conf
:set nu
将第 35行到79 行注释掉
:35,79 s/^/#/g

在配置文件倒数第二行添加内容:
include /usr/local/nginx/conf/conf.d/*.conf;

创建 vhost配置文件所在的目录
# mkdir /usr/local/nginx/conf/conf.d/
# vi web01.conf
server {
      listen       80;
      server_name www.aaa.com;
      location / {
          root   /var/web01;
          index  index.php index.html index.htm;
      }
      error_page   500 502 503 504  /50x.html;
      location = /50x.html {
          root   /var/web01;
      }
      location ~ .php$ {
          root           /var/web01;
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          fastcgi_param  SCRIPT_FILENAME  /var/web01$fastcgi_script_name;
          include        fastcgi_params;
      }
}

3.png 

# vi web02.conf
server {
      listen       80;
      server_name www.bbb.com;
      location / {
          root   /var/web02;
          index  index.php index.html index.htm;
      }
      error_page   500 502 503 504  /50x.html;
      location = /50x.html {
          root   /var/web02;
      }
      location ~ .php$ {
          root           /var/web02;
          fastcgi_pass   127.0.0.1:9000;
          fastcgi_index  index.php;
          fastcgi_param  SCRIPT_FILENAME  /var/web01$fastcgi_script_name;
          include        fastcgi_params;
      }
}


4.png 

创建两个站点的 web目录
# mkdir /var/web01
# mkdir /var/web02


创建测试页面
# echo “web01”  > /var/web01/test01.php
# echo “web02”  > /var/web02/test02.php

本地 host文件设置[url=]www.aaa.com,  www.bbb.com[/url]指向服务器 IP

重启php和nginx
# service php-fpm restart
# ps -ef|grep nginx|awk '{print $2}'|xargs kill -9
# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

浏览器测试成功:
5.png

注:此方法不限于腾讯云服务器,百度云服开放云务器,阿里云服务器,传统服务器也适用!   北京沧州佳恩网络科技有限公司(简称沧州佳恩网络)由多名前阿里云资深技术专家创立,核心员工来自阿里巴巴、腾讯等,做为一家综合性方案商,沧州佳恩网络向各行业用户提供基于公有云,私有云,混合云等基于云计算的各种解决方案。
为什么选择我们:沧州佳恩网络科技有限公司由多名核心员工来自阿里巴巴、腾讯等,作为阿里云,腾讯云百度云,金山云,华为云重要的合作伙伴,专注于为企业用户提供云计算及云计算的解决方案。总部设在沧州。做为一家综合性方案商,沧州佳恩网络向各行业用户提供基于云计算的各种解决方案。为用户获得服务的同时,秉承专业规划、周到服务的服务理念,根据用户的实际情况,充分考虑各种网络资源的特点及功效,为用户量身定做一套适合于其实际应用需求的网络应用方案。帮助用户利用互联网的力量展开新的营销方式,并大大缩短了项目实施周期。

相关热词搜索:

上一篇:河间网站推广什么是SSD硬盘及优缺点
下一篇:青县网站制作服务器如何编译安装Mysql5.5.4

分享到: 收藏
评论排行