Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a Virtual Host In PHP

I am trying to set up symfony on my Ubuntu system. Now as going through the installation tutorial of symfony I found to Create a virtual host for my (to be created) application. I did the same steps as bellow.

httpd.conf

NameVirtualHost 127.0.0.1:9090
Listen 127.0.0.1:9090
<VirtualHost 127.0.0.1:9090>
ServerName www.symfony.jobeet.lcl
DocumentRoot "/home/sfprojects/jobeet/web"
DirectoryIndex index.php
<Directory "/home/sfprojects/jobeet/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf /home/sfprojects/jobeet/lib/vendor/symfony/data/web/sf
<Directory "/home/sfprojects/jobeet/lib/vendor/symfony/data/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>

And Here is My /etc/hosts file

127.0.0.1   www.symfony.jobeet.lcl

Now I restarts my lampp server and entered www.symfony.jobeet.lcl in my browser it takes me to http://www.symfony.jobeet.lcl/xampp/ this Url. If I try without using virtual host, It works fine. also when I try www.symfony.jobeet.lcl:9090 It works. I expect it should work without giving the port number. Am I doing something wrong ?

like image 397
ScoRpion Avatar asked Nov 29 '25 00:11

ScoRpion


2 Answers

I have created the simple bash script to simplify the process of new hosts creation. So that you don't have to do anything with config files, etc. Check if you are interested here.

Creating new host is as simple as running a command from terminal $ sudo ./newhost.sh. Then you will be asked to enter desired host name.

like image 71
dfsq Avatar answered Nov 30 '25 16:11

dfsq


Change this lines

NameVirtualHost 127.0.0.1:9090
Listen 127.0.0.1:9090
<VirtualHost 127.0.0.1:9090>

to

NameVirtualHost 127.0.0.1:80
Listen 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
like image 37
xmarcos Avatar answered Nov 30 '25 15:11

xmarcos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!