• Rob's side project: I recently started Gun-Forums.com and we currently have a $100 raffle - if you're into guns, join up and enter the raffle to win $100.00. Raffle Link

Is there just one 000-default.conf file

ozstar

New Member
Hi,

I am trying to set up an Apache webserver and going okay albiet it very slow, but every now and then get confused with instructions.

I have several sites in their own (www/html/site1) folders but need to know do I need the 000-default and site enabled files etc in each folder or is they just the one set with all the dom address in them?

In the sites I have seen, they all only show one set of address in them.

Thanks,

oz
 


captain-sensible

Well-Known Member
one approach which I use with apache(for dev) is to use virtual domains.

the physical bit is at /var/www/htdocs i have folders :

slim fuel CI


i just use separate Ip address to distinguish one from the other.

<VirtualHost 127.0.0.4:80 >
<Directory /var/www/htdocs/slim>
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
</Directory>
ServerName slim
DocumentRoot /var/www/htdocs/slim/public/
</VirtualHost>


so to see landing page of a slim php fraemwrk , i just put 127.0.0.4 in browser. Apache set up and tweaking depends on waht os you are using and where the file are. if you go down the route of virtual hosts first you enable it in main apache in my case

/etc/httpd/httpd.conf

then add entries to


/etc/httpd/extra/httpd-vhosts.conf
 

CptCharis

Well-Known Member
Hello @ozstar, I agree with @captain-sensible, Apache is using the concept of a Virtual Host but I have to add that you can have a single server with one IP and serve different sites.
To set this up, you have to create a separate configuration file for each of them and store them in Apache configuration directory. Each file should include an identifier such as a name that differentiates one from the other.
In ubuntu-server configuration files for each site should be stored like this:
Code:
/etc/apache2/sites-available/yoursitename.com.conf
and the command that you should use to enable it, is this one:
Code:
sudo a2ensite yoursitename.com.conf
sudo systemctl reload apache2
As far as I know this two are Ubuntu dedicate command and I can't help you if you are using some other distro.

The contents of /var/www/html are served by the default virtual host if you make no changes to Apache's configuration.

000-default.conf is the file that controls the default Apache sample website and is enough for the case that we need our Apache to serve a single site.

With servers with a single IP you can use 000-default.conf and make your own 000-virtual-hosts.conf and stored it in the
Code:
/etc/apache2/sites-available
directory.

Contents should be something like this:
Code:
<VirtualHost *:80>
ServerName mysitename.com
DocumentRoot /var/www/mysitename
</VirtualHost>

<VirtualHost *:80>
ServerName mysitename2.com
DocumentRoot /var/www/mysitename2
</VirtualHost>
Another good idea is to modify the part of
Code:
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
that you will find inside the 000-default.conf when you make your new 000-virtual-host.conf into something like this:
Code:
ErrorLog ${APACHE_LOG_DIR}/mysitename.com-error.log
CustomLog ${APACHE_LOG_DIR}/mysitename.com-access.log combined

Good luck.
 


Members online

No members online now.

Top