注册了域名之后,多个php项目可以用多个域名分别绑定吗

WBOY
Lepaskan: 2016-10-22 00:14:24
asal
1027 orang telah melayarinya

我注册了好几个域名,服务器中部署的apache上运行的多个php项目,可以用多个域名分别绑定吗?怎么绑定啊

回复内容:

我注册了好几个域名,服务器中部署的apache上运行的多个php项目,可以用多个域名分别绑定吗?怎么绑定啊

可以的。使用virtualhost即可。
你的域名先使用A记录全部解析到服务器的IP
编辑http-vhost.conf配置

<code><virtualhost>
    DocumentRoot "D:/UPUPW_AP5.5/vhosts/hospital.com/web"
    ServerName hospital.com:80
    ServerAlias
    ServerAdmin webmaster@hospital.com
    DirectoryIndex index.html index.htm index.php default.php app.php u.php
    ErrorLog logs/hospital.com-error.log
    CustomLog logs/hospital.com-access_%Y%m%d.log comonvhost
<directory>
    Options FollowSymLinks
    AllowOverride All
    Require all granted
</directory>
<locationmatch>
    Require all denied
</locationmatch>
<locationmatch>
    Require all denied
</locationmatch>
</virtualhost>
//D:/UPUPW_AP5.5/vhosts/hospital.com/web    WEB目录
//ServerName hospital.com:80 绑定的域名</code>
Salin selepas log masuk

配置apacheVirtualHost,以我的项目为例:
找到服务器的httpd.conf,然后配置下面内容:

<code class="html"><virtualhost>
     ServerName admin.example.com
     ProxyPass / http://localhost:8080/
     ProxyPassReverse / http://localhost:8080/
     ErrorLog logs/admin.example.com-error_log
     CustomLog logs/admin.example.com-access_log common
 </virtualhost>

<virtualhost>
     ServerName www.demo.com
     ProxyPass / http://localhost:8081/
     ProxyPassReverse / http://localhost:8081/
     ErrorLog logs/demo.com-error_log
     CustomLog logs/demo.com-access_log common
 </virtualhost></code>
Salin selepas log masuk

上面的配置,是让apache监听80端口,也就是默认的端口,然后当用户访问admin.example.com的时候,就把请求分发到8080端口的应用。当用户访问www.demo.com的时候,就把请求分发到8081端口。当然,你又多少程序,就要配置多少个VirtualHost。如果还不明白,可以搜apache端口转发,很多教程哦。

Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan
Tentang kita Penafian Sitemap
Laman web PHP Cina:Latihan PHP dalam talian kebajikan awam,Bantu pelajar PHP berkembang dengan cepat!