没有域名的Apache虚拟主机 [英] Apache virtual host without domain name

查看:112
本文介绍了没有域名的Apache虚拟主机的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个安装了apache2的VPS,我想访问一些不带IP地址但没有域名的PHP项目.例如:

I have a VPS with apache2 installed and I would like to access some PHP projects without a domain name just with the IP address. For example:

http://162.243.93.216/projecta/index.php
http://162.243.93.216/projectb/index.php

在目录/var/www/

I have other projects with domain like example.com, in my directory /var/www/

/html/
   info.php
/projecta/
/projectb/
/example/

我去

http://162.243.93.216/info.php then /var/www/html/info.php is opened. 

我的文件 000-default.conf

<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
     </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

推荐答案

" http://162.243.93.216/info.php then /var/www/html/info.php is opened "

我假设这已经起作用(如果没有,请取消注释下面conf中显示的ServerAlias行)

I am assuming this already works (If not, uncomment the ServerAlias line shown in the conf below)

您现在要映射

http://162.243.93.216/projecta//var/www/projecta
http://162.243.93.216/projectb//var/www/projectb

为此,您需要使用Apache Alias 指令.

For this you need to use the Apache Alias directive.

<VirtualHost *:80>
    # ServerAlias 162.243.93.216
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/html

    Alias /projecta /var/www/projecta
    Alias /projectb /var/www/projectb

    <Directory /var/www/>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
     </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

这篇关于没有域名的Apache虚拟主机的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆