Heim  >  Artikel  >  Backend-Entwicklung  >  注册了域名之后,多个php项目可以用多个域名分别绑定吗

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

WBOY
WBOYOriginal
2016-10-22 00:14:241026Durchsuche

我注册了好几个域名,服务器中部署的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>

配置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>

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

Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn