Add multiple virtual hosts to lamp in Ubunbu system

Source: Internet
Author: User

There is a default file in/etc/apache2/sites-available, which is roughly configured as follows:

<virtualhost *:80> ServerAdmin xujie19841206@hotmail.com ServerName localhost documentroot/home/xujie/www < Directory/> Options Indexes followsymlinks allowoverride all </Directory> <Directory/home/xujie/www/> Options Indexes followsymlinks multiviews allowoverride All order Allow,deny allow to all </Directory> Scriptalias /cgi-bin//usr/lib/cgi-bin/<directory "/usr/lib/cgi-bin" > allowoverride None Options +execcgi-multiviews + SymLinksIfOwnerMatch order Allow,deny allow from all </Directory> Errorlog/var/log/apache2/error.log # Possible VA Lues Include:debug, info, notice, warn, error, crit, # Alert, Emerg. LogLevel warn Customlog/var/log/apache2/access.log combined alias/doc/"/usr/share/doc/" <directory doc/"> Options Indexes multiviews followsymlinks allowoverride None order Deny,allow deny to all allow from 127.0.0.0 /255.0.0.0:: 1/128 </Directory> </VirtualHost>

When you enter http://localhost, the server automatically resolves to the/home/xujie/www folder. Find index.php, however if you want to add another virtual host, add it locally.

Each site has the same IP address, but with a different domain name, it is called a virtual host based on a first name or host name.

If you want to create a www.drug.com.cn directory again, then create a file in the/etc/apache2/sites-available/directory, named Drug, and then through sudo gedit drug,

Add to

<virtualhost 127.0.0.1>
ServerName www.drug.com.cn
ServerAdmin abc@abc.com
DocumentRoot "/home/xujie/www/drug"
ErrorLog "/var/log/apache2/drug_errors.log"
</VirtualHost>

Here is not done, Run command sudo a2ensite Edunuke, need to modify host file, edit/etc/hosts, and then add 127.0.0.1 www.drug.com.cn here, the server restarts, you can let www.drug.com.cn automatically parse to the local/home/xujie/www/drug directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.