简体   繁体   中英

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 ?

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.

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>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM