特殊:Badtitle/NS100:LocalhostSubdomain:修订间差异
小无编辑摘要 |
小无编辑摘要 |
||
第1行: | 第1行: | ||
{{From|https://help.ubuntu.com/community/LocalhostSubdomain}} | {{From|https://help.ubuntu.com/community/LocalhostSubdomain}} | ||
{{Languages|UbuntuHelp:LocalhostSubdomain}} | {{Languages|UbuntuHelp:LocalhostSubdomain}} | ||
Seting up Virtual Hosts on [[ApacheMySQLPHP|Apache]] with subdomains of localhost allows you to access your local files as if you had different subdomains, eg site1.localhost/ and site2.localhost/ | Seting up Virtual Hosts on [[UbuntuHelp:ApacheMySQLPHP|Apache]] with subdomains of localhost allows you to access your local files as if you had different subdomains, eg site1.localhost/ and site2.localhost/ | ||
This is particularly useful if you're working on and testing several different websites on your system, and each one requires top-level folders for things such as [[UbuntuHelp:ServerSideIncludes|ServerSideIncludes]] files and stylesheets. | This is particularly useful if you're working on and testing several different websites on your system, and each one requires top-level folders for things such as [[UbuntuHelp:ServerSideIncludes|ServerSideIncludes]] files and stylesheets. | ||
=== Hosts === | === Hosts === |
2008年10月19日 (日) 16:05的版本
文章出处: |
{{#if: | {{{2}}} | https://help.ubuntu.com/community/LocalhostSubdomain }} |
点击翻译: |
English {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/af | • {{#if: UbuntuHelp:LocalhostSubdomain|Afrikaans| [[::LocalhostSubdomain/af|Afrikaans]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/ar | • {{#if: UbuntuHelp:LocalhostSubdomain|العربية| [[::LocalhostSubdomain/ar|العربية]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/az | • {{#if: UbuntuHelp:LocalhostSubdomain|azərbaycanca| [[::LocalhostSubdomain/az|azərbaycanca]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/bcc | • {{#if: UbuntuHelp:LocalhostSubdomain|جهلسری بلوچی| [[::LocalhostSubdomain/bcc|جهلسری بلوچی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/bg | • {{#if: UbuntuHelp:LocalhostSubdomain|български| [[::LocalhostSubdomain/bg|български]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/br | • {{#if: UbuntuHelp:LocalhostSubdomain|brezhoneg| [[::LocalhostSubdomain/br|brezhoneg]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/ca | • {{#if: UbuntuHelp:LocalhostSubdomain|català| [[::LocalhostSubdomain/ca|català]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/cs | • {{#if: UbuntuHelp:LocalhostSubdomain|čeština| [[::LocalhostSubdomain/cs|čeština]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/de | • {{#if: UbuntuHelp:LocalhostSubdomain|Deutsch| [[::LocalhostSubdomain/de|Deutsch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/el | • {{#if: UbuntuHelp:LocalhostSubdomain|Ελληνικά| [[::LocalhostSubdomain/el|Ελληνικά]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/es | • {{#if: UbuntuHelp:LocalhostSubdomain|español| [[::LocalhostSubdomain/es|español]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/fa | • {{#if: UbuntuHelp:LocalhostSubdomain|فارسی| [[::LocalhostSubdomain/fa|فارسی]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/fi | • {{#if: UbuntuHelp:LocalhostSubdomain|suomi| [[::LocalhostSubdomain/fi|suomi]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/fr | • {{#if: UbuntuHelp:LocalhostSubdomain|français| [[::LocalhostSubdomain/fr|français]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/gu | • {{#if: UbuntuHelp:LocalhostSubdomain|ગુજરાતી| [[::LocalhostSubdomain/gu|ગુજરાતી]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/he | • {{#if: UbuntuHelp:LocalhostSubdomain|עברית| [[::LocalhostSubdomain/he|עברית]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/hu | • {{#if: UbuntuHelp:LocalhostSubdomain|magyar| [[::LocalhostSubdomain/hu|magyar]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/id | • {{#if: UbuntuHelp:LocalhostSubdomain|Bahasa Indonesia| [[::LocalhostSubdomain/id|Bahasa Indonesia]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/it | • {{#if: UbuntuHelp:LocalhostSubdomain|italiano| [[::LocalhostSubdomain/it|italiano]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/ja | • {{#if: UbuntuHelp:LocalhostSubdomain|日本語| [[::LocalhostSubdomain/ja|日本語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/ko | • {{#if: UbuntuHelp:LocalhostSubdomain|한국어| [[::LocalhostSubdomain/ko|한국어]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/ksh | • {{#if: UbuntuHelp:LocalhostSubdomain|Ripoarisch| [[::LocalhostSubdomain/ksh|Ripoarisch]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/mr | • {{#if: UbuntuHelp:LocalhostSubdomain|मराठी| [[::LocalhostSubdomain/mr|मराठी]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/ms | • {{#if: UbuntuHelp:LocalhostSubdomain|Bahasa Melayu| [[::LocalhostSubdomain/ms|Bahasa Melayu]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/nl | • {{#if: UbuntuHelp:LocalhostSubdomain|Nederlands| [[::LocalhostSubdomain/nl|Nederlands]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/no | • {{#if: UbuntuHelp:LocalhostSubdomain|norsk| [[::LocalhostSubdomain/no|norsk]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/oc | • {{#if: UbuntuHelp:LocalhostSubdomain|occitan| [[::LocalhostSubdomain/oc|occitan]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/pl | • {{#if: UbuntuHelp:LocalhostSubdomain|polski| [[::LocalhostSubdomain/pl|polski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/pt | • {{#if: UbuntuHelp:LocalhostSubdomain|português| [[::LocalhostSubdomain/pt|português]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/ro | • {{#if: UbuntuHelp:LocalhostSubdomain|română| [[::LocalhostSubdomain/ro|română]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/ru | • {{#if: UbuntuHelp:LocalhostSubdomain|русский| [[::LocalhostSubdomain/ru|русский]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/si | • {{#if: UbuntuHelp:LocalhostSubdomain|සිංහල| [[::LocalhostSubdomain/si|සිංහල]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/sq | • {{#if: UbuntuHelp:LocalhostSubdomain|shqip| [[::LocalhostSubdomain/sq|shqip]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/sr | • {{#if: UbuntuHelp:LocalhostSubdomain|српски / srpski| [[::LocalhostSubdomain/sr|српски / srpski]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/sv | • {{#if: UbuntuHelp:LocalhostSubdomain|svenska| [[::LocalhostSubdomain/sv|svenska]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/th | • {{#if: UbuntuHelp:LocalhostSubdomain|ไทย| [[::LocalhostSubdomain/th|ไทย]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/tr | • {{#if: UbuntuHelp:LocalhostSubdomain|Türkçe| [[::LocalhostSubdomain/tr|Türkçe]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/vi | • {{#if: UbuntuHelp:LocalhostSubdomain|Tiếng Việt| [[::LocalhostSubdomain/vi|Tiếng Việt]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/yue | • {{#if: UbuntuHelp:LocalhostSubdomain|粵語| [[::LocalhostSubdomain/yue|粵語]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/zh | • {{#if: UbuntuHelp:LocalhostSubdomain|中文| [[::LocalhostSubdomain/zh|中文]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/zh-hans | • {{#if: UbuntuHelp:LocalhostSubdomain|中文(简体)| [[::LocalhostSubdomain/zh-hans|中文(简体)]]}}|}} {{#ifexist: {{#if: UbuntuHelp:LocalhostSubdomain | UbuntuHelp:LocalhostSubdomain | {{#if: | :}}LocalhostSubdomain}}/zh-hant | • {{#if: UbuntuHelp:LocalhostSubdomain|中文(繁體)| [[::LocalhostSubdomain/zh-hant|中文(繁體)]]}}|}} |
{{#ifeq:UbuntuHelp:LocalhostSubdomain|:LocalhostSubdomain|请不要直接编辑翻译本页,本页将定期与来源同步。}} |
{{#ifexist: :LocalhostSubdomain/zh | | {{#ifexist: LocalhostSubdomain/zh | | {{#ifeq: {{#titleparts:LocalhostSubdomain|1|-1|}} | zh | | }} }} }} {{#ifeq: {{#titleparts:LocalhostSubdomain|1|-1|}} | zh | | }}
Seting up Virtual Hosts on Apache with subdomains of localhost allows you to access your local files as if you had different subdomains, eg site1.localhost/ and site2.localhost/ This is particularly useful if you're working on and testing several different websites on your system, and each one requires top-level folders for things such as ServerSideIncludes files and stylesheets.
Hosts
In the Network Configuration Applet, go to the 'Hosts' tab and edit the entry for 127.0.0.1:
- IP address: 127.0.0.1
- Aliases: add 'site2.localhost'
Alternatively, you can edit /etc/hosts directly, adding a line such as:
127.0.0.1 site2.localhost
Apache
Assuming you're using apache2, the cleanest thing to do is create a new configuration file in /etc/apache2/sites-available, and then enable the new site with the command a2ensite
(which is similar to create a SymbolicLink to the site in /etc/apache2/sites-enabled).
This leaves the default configuration untouched. To revert, simply use the command a2dissite
(or delete the symbolic link in /etc/apache2/sites-enabled).
gksudo gedit /etc/apache2/sites-available/myconfig
The text in your new file should be something like this...
<VirtualHost *> DocumentRoot /home/username/mysite/ ServerName site2.localhost <Directory /home/username/mysite/> Options Indexes FollowSymLinks MultiViews +Includes AllowOverride None Order allow,deny allow from all </Directory> </VirtualHost>
Then do:
sudo a2ensite myconfig
Finally, restart Apache to apply changes:
sudo /etc/init.d/apache2 restart