这里是一个与我的开发服务器configuration相关的问题(已安装LAMP的Ubuntu服务器)
我有一个指向我的服务器像http://sudomain.domain.com的子域。
现在我需要在服务器的每个域上创build一些子域,以指向服务器上的单独文件夹/ var / www / proj1应该通过访问http://proj1.subdomain.domain.com,http:// proj2加载。 subdomain.domain.com
任何人都可以帮助我解决这个问题? 任何帮助将不胜感激。
你需要的是Apache VirtualHost指令。 请参阅Apache文档和一些示例 。
基本上你想在Ubuntu中做的是确保你想要使用的端口(通常是80)在/etc/apache2/ports.conf中是这样启用的:
NameVirtualHost *:80 Listen 80
接下来,你将不得不在/ etc / apache2 / sites-available中创build一个新的conf-file。 我build议将其命名为proj1.conf或proj1.mydomain.conf。
在那里你可以configurationVirtualHost如下:
<VirtualHost *:80> ServerName proj1.subdomain.domain.com DocumentRoot /var/www/proj1 ServerAdmin [email protected] # Write a seperate log per Virtualhost CustomLog /var/log/apache2/proj1.subdomain.access_log combined ErrorLog /var/log/apache2/proj1.subdomain.error_log # Maybe you want to put some restrictions on the directory <Directory /var/www/proj1> Options -Indexes +FollowSymLinks + Includes AllowOverride All # Restrict Access to certain IP's Order Deny,Allow Deny from All Allow from 127.0.0.1 IP IP IP Satisfy ALL </Directory> </VirtualHost>
请参阅Apache手册以了解您可以对指令做些什么。
要启用此网站,请将其链接到/ etc / apache2 / sites-enabled
ln -s /etc/apache2/sites-available/proj1.conf /etc/apache2/sites-enabled/proj1
现在你所要做的就是确保你的configuration是有效的,然后重新启动Apache:
apache2ctl configtest && /etc/init.d/apache2 restart
当然,你将不得不在你的DNS中设置一个指向这个服务器的子域。