I have 2 websites i want to host on a Linux machine using Apache server. Since at this point i am unable to acquire a domain name, i access the server through IP, since I'm not required to have one yet.
The first site is comprised of a few HTML pages and is located in /var/hostroot/lifeonearth/{all files here}
and the other is comprised of several PHP pages located in /var/hostroot/webDarts/{all files here}
.
By default when i go to my IP address, it takes me to the default "Your Apache server is working" page. So from here on, how do i make it so that i can access each site through some sort of subdomain like lifeonearth.(my IP)
or webDarts.(my IP)
or, am I supposed to access them throug different ports. If it's the latter, how do I go about it?
Asked
Active
Viewed 736 times
0

IneptusMechanicus
- 468
- 4
- 23
-
Before giving you the answer let me clarify my doubts. You are going to host 2 websites in a single Linux machine right ? Both should be accessible at a time . Is that correct ? – Ramkee Apr 09 '16 at 13:47
-
Is that live server ? – Ramkee Apr 09 '16 at 14:14
-
I don't think so, come to think of it, it's not really necessary for both sites to work simultaneously, i just want to be able to access either of them separately via IP address – IneptusMechanicus Apr 09 '16 at 14:17
-
Please have a look at my answer and let me know is that what you required – Ramkee Apr 09 '16 at 14:45
1 Answers
0
We have 2 website names.
1. example1.test.local (/var/www/example1)
2. example2.test.local (/var/www/example2)
Now Lets create two files called example1
and example2
in /etc/apache2/sites-available
.
example1
file looks like as follows
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/example1
ServerName example1.test.local
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/example1>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
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 /var/log/apache2/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog /var/log/apache2/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/128
</Directory>
as the same way create another file called example2
and modify the following lines
DocumentRoot /var/www/example2
ServerName example2.test.local
and
<Directory /var/www/example2>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
rest of the file will same as example1.
Then enable those two sites
a2ensite example1
a2ensite example2
Then do apache service restart.
Now we have to do DNS pointing
If your Linux machine is LOCAL then go to your Windows machine where you want to access these websites and open the following file C:\Windows\System32\drivers\etc\hosts
and mention your ip and website name
192.168.249.101 example1.test.local
192.168.249.101 example2.test.local
Thats it! If you found any difficulties please let me know.
I have replicated this scenario at my end and it works for me. Hope it will work for you!

Ramkee
- 900
- 1
- 10
- 27
-
think it works. How do i access them outside a local network, or did I misread something – IneptusMechanicus Apr 09 '16 at 14:47
-
-
-
Please have a look at on this link http://stackoverflow.com/questions/9454503/apache-how-can-i-access-my-webpage-from-a-computer-outside-my-network – Ramkee Apr 09 '16 at 15:08