PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, September 21, 2022

[FIXED] how to setup multiple vhost in one file

 September 21, 2022     apache, ubuntu, virtualhost     No comments   

Issue

i moved from fedora to ubuntu 16.04.

in fedora i could list endless vhost in one file. where as in ubuntu i must create a new file for each vhost. i already have my list with all vhosts in it. is the re any way to do this in ubuntu?

# Virtual Hosts
#
# Required modules: mod_log_config

# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.4/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
    ServerAdmin admin@apecenergy
    DocumentRoot /var/www/html/apecenergy.co.uk/public_html
    ServerName www.apecenergy.co.uk
    ServerAlias apecenergy.co.uk 
    ErrorLog "/var/log/httpd/apecenergy-error_log"
    CustomLog "/var/log/httpd/apecenergy-access_log" common
</VirtualHost>

<VirtualHost *:80>
    ServerAdmin admin@apecenergy
    DocumentRoot /var/www/html/plumbing_sites/crouchendplumber.co.uk/public_html
    ServerName www.crouchendplumber.co.uk
    ServerAlias crouchendplumber.co.uk 
</VirtualHost>

Solution

That's just ubuntu's shortcut organization for apache. It will work the same way. You can save that one long file with multiple vhosts to your sites_available folder under filename.conf then enable them all at once.

sudo a2ensite filename

Although this is convenient at first, you will be better off in the long run if you take the time to split them apart.



Answered By - Jeff Puckett
Answer Checked By - Gilberto Lyons (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

1,206,402

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © 2025 PHPFixing