泛域名PHP,php 泛域名解析

什么环境,nginx还是Apache?直接解析域名和添加配置文件就行了

一种是泛解析:以nginx示例

tree /home/wwwroot/test

/home/wwwroot

├── bbs

│   └── index.html

└── www

└── index.html

/home/wwwroot为nginx的安装目录下默认的存放源代码的路径。

bbs为论坛程序源代码路径

www为主页程序源代码路径

把相应程序放入上面的路径通过

http://www.test.com 访问的就是主页

http://bbs.test.com 访问的就是论坛

其它二级域名类推。

server {listen 80;server_name ~^(?.+).test.com$;access_log /data/wwwlogs/test.com_nginx.log combined;index index.html index.htm index.php;root /home/wwwroot/test/$subdomain/;location ~ .php$ {    fastcgi_pass unix:/dev/shm/php-cgi.sock;    fastcgi_index index.php;    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;    include fastcgi_params;    }location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|ico)$ {    expires 30d;    }location ~ .*\.(js|css)?$ {    expires 7d;    }}

还有一种就是直接上2个server

server {listen 80;server_name www.test.com;access_log /data/wwwlogs/www.test.com_nginx.log combined;index index.html index.htm index.php;root /home/wwwroot/www.test.com;}#论坛的配置server {listen 80;server_name bbs.test.com;access_log /data/wwwlogs/bbs.test.com_nginx.log combined;index index.html index.htm index.php;root /home/wwwroot/bbs.test.com;}

以上剥离了其他配置信息,仅为server段配置,你直接复制server端就可以了,

其中关于路径和域名就改成你自己的,路径随你喜欢怎么改都行,如第一种泛解析方式来命名,或者直接以bbs,www来命名,自定义。。。。当然方法也不止这两种

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值