沧州佳恩网络科技有限公司专注
河北网站制作,网站优化,河北站长工具,
河北网站推广等企业互联网业务,根据用户的实际情况,充分考虑各种网络资源的特点。
1)下载 nginx 源码包http://nginx.org/en/download.html
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浏览器测试
接下来进行源码安装PHP,请参考下面教程:http://bbs.qcloud.com/forum.php?mod=viewthread&tid=4346&extra=page%3D1Nginx与php整合# 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.confserver {
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;
}
}
# vi web02.confserver {
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;
}
}
创建两个站点的 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浏览器测试成功:
注:此方法不限于腾讯云服务器,百度云服开放云务器,阿里云服务器,传统服务器也适用!
北京佳恩网络科技有限公司(简称佳恩网络)由多名前阿里云资深技术专家创立,核心员工来自阿里巴巴、腾讯等,做为一家综合性方案商,佳恩网络向各行业用户提供基于公有云,私有云,混合云等基于云计算的各种解决方案。
为什么选择我们:
沧州佳恩网络科技有限公司核心员工来自阿里巴巴、腾讯等,作为阿里云,腾讯云百度云,金山云,华为云重要的合作伙伴,专注于为企业用户提供云计算及云计算的解决方案。总部设在沧州。做为一家综合性方案商,沧州佳恩网络向各行业用户提供基于云计算的各种解决方案。为用户获得服务的同时,秉承专业规划、周到服务的服务理念,根据用户的实际情况,充分考虑各种网络资源的特点及功效,为用户量身定做一套适合于其实际应用需求的网络应用方案。帮助用户利用互联网的力量展开新的营销方式,并大大缩短了项目实施周期。