Configure Apache virtual host under Ubuntu

Source: Internet
Author: User

Server IP Address: 127.0.0.1:80

Bind two domain names my.cms.com my.test.com

Bind my.cms.com to/home/gaofei/desktop/www/my_cms

Bind My.cms.test to/home/gaofei/desktop/www/my_test

1.

Cd/etc/hosts

Add a domain name

127.0. 0.1        my.test.com127.0. 0.1       My.cms.com

2. Enter/etc/apache2/sites-enabled/; Delete the 000-default file.

3. Create two files under/etc/apache2/sites-available/named My.test.com my.cms.com

Insert the following in my.cms.com

<virtualhost *: the>ServerAdmin [email protected] ServerName my.cms.com documentroot/home/gaofei/desktop/www/My_cms<directory/>Options followsymlinks directoryindex index.php index.html index.htm allowoverride None</Directory> <Directory/home/gaofei/Desktop/www/my_cms># options Indexes followsymlinks multiviews options followsymlinks rewriteengine on Rewritecond%{request_filename}!-F Rewritecond%{request_filename}!-d rewriterule. index.php allowoverride all Order allow,deny allow from 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 ${apache_log_dir}/Error.log # Possible values Include:debug, info, notice, warn, error, crit, # Alert, Emerg. LogLevel warn Customlog ${apache_log_dir}/Access.log Combined Alias/doc/"/usr/share/doc/"<directory"/usr/share/doc/">Options Indexes multiviews followsymlinks allowoverride None Order deny,allow deny from all allow from 127.0.0.0/255.0.0.0::1/ -</Directory></VirtualHost>

Insert the following inside the my.test.com

<virtualhost *: the>ServerAdmin [email protected] ServerName my.test.com documentroot/home/gaofei/desktop/www/my_test<directory/>Options followsymlinks directoryindex index.php index.html index.htm allowoverride None</Directory> <Directory/home/gaofei/Desktop/www/my_test># options Indexes followsymlinks multiviews options followsymlinks rewriteengine on Rewritecond%{request_filename}!-F Rewritecond%{request_filename}!-d rewriterule. index.php allowoverride all Order allow,deny allow from 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 ${apache_log_dir}/Error.log # Possible values Include:debug, info, notice, warn, error, crit, # Alert, Emerg. LogLevel warn Customlog ${apache_log_dir}/Access.log Combined Alias/doc/"/usr/share/doc/"<directory"/usr/share/doc/">Options Indexes multiviews followsymlinks allowoverride None Order deny,allow deny from all allow from 127.0.0.0/255.0.0.0::1/ -</Directory></VirtualHost>

4. Create the ln link in/etc/apache2/sites_enabled/:

Ln-s   /etc/apache2/sites-available/my.test.com/etc/apache2/sites-enabled/-S   /etc/apache2/ Sites-available/my.cms.com/etc/apache2/sites-enabled/my.cms.com

5. Restart Apache2

Service Apache2 Restart

Configure Apache virtual host under Ubuntu

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.