20年营销型网站设计公司 提高你的知名度 提高业绩量

山东网站优化云服务器编译安装Nginx1.0.15,并建立vhost。

发布时间:2023-05-30 09:37:01



沧州佳恩网络科技有限公司专注河北网站制作,网站优化,河北站长工具,河北网站推广等企业互联网业务,根据用户的实际情况,充分考虑各种网络资源的特点。




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

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

上一篇:山东网站优化服务器如何编译安装Mysql5.5.4

下一篇:山东网站优化服务器如何编译安装Apache2.2.29

返回列表
中小企业网站建设
我们做具性价比的服务
 

更多 +联系我们

咨询电话:0317-3741708

业务QQ:  44963430E-mail:yflabc@163.com

客服0317-3741708

渠道合作QQ44963430

我们的经营

沧州佳恩网络科技有限公司,是一家专业从事网站建设、 品牌设计、产品拍摄的企业。公司汇集了网站建设,品牌设计,电商设计,为企业提供一站式的服务, 公司各类专业人才,均在各自领域工作5年以上,有着丰富的经验!
有这样一群人,
他们愿意把自己的全部能量挥洒在这里,愿意把对事业的美好憧憬寄托在这里,
愿意忘记时间的流转并把对生活的热情融入这里。这里没有沉闷的交流,没有超越忍耐的合作,
没有失去自由的畅想,没有无法逾越的隔阂;
有的是心照不宣,轻松和谐;有的是放纵思绪,丰富且自得。