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>
Related
I am using XAMPP in Windows.I want to set vhost for my symfony project so I have set the vhost in apache through (httpd-vhosts.conf) file as :
# Be sure to only have this line once in your configuration
NameVirtualHost 127.0.0.1:80
# This is the configuration for drberg.com
Listen 127.0.0.1:80
<VirtualHost 127.0.0.1:80>
ServerName drberg.com.local
DocumentRoot "D:/xampp/htdocs/DrBerg.com/web"
DirectoryIndex index.php
<Directory "D:/xampp/htdocs/DrBerg.com/web">
AllowOverride All
Allow from All
</Directory>
Alias /sf "D:/xampp/htdocs/DrBerg.com/web/sf"
<Directory "D:/xampp/htdocs/DrBerg.com/web/sf">
AllowOverride All
Allow from All
</Directory>
</VirtualHost>
So I can't access it it's not opening anything also when I access my symfony project through manual link so it redirects me to my localhost as :
http://localhost/DrBerg.com/web/
So it redirects me to :
http://localhost/xampp/
Set in your hosts (in WINDOWS/system32/drivers/etc/) your ServerName:
127.0.0.1 drberg.com.local
(it works immediately after save this file)
and point to:
http://drberg.com.local
(use http:// because sometimes chrome send the address to google.com instead go there)
and don't use localhost in the ServerName because XAMPP filter this word (local can be).
I installed genymotion emulator on my PC and I want to access my WAMP local server to it and I ran ipconfig on my cmd so I got this IP_address 192.168.56.1 but the problem is that I always get this error
403 Forbidden
You don't have permission to access / on this server
I tried all the answers given in this question yet none solved my problem.
I am running
Mysql 5.5.8,
PHP 5.3.5 and
Apache 2.2.17
Please do anyone know how I can fix this error?
#KANAYOAUSTINKANE. This is my code or the Subdomain
<Virtualhost *:80>
DocumentRoot "C:/wamp/www/mobile"
ServerName localhost
ServerAlias m.local host
</Virtualhost>
Please help me out, I have been so disturbed
Okay, here is a solution.
First step
Change the location of your virtual host and add a / at the end like this
DocumentRoot "C:/wamp/www/mobile/"
Second step
Go to your httpd.conf file located at C:/camp/bin/apache/Apache2.2.17/conf/httpd.conf the go to the line that has Listen 80 and change it to Listen *:80 this will make it to listen to any IP address
Finally
You go to the end of your httpd.conf file and add this
# Tells Apache to identify which site by name
NameVirtualHost *:80
# Tells Apache to serve the default WAMP Server page to "localhost"
<VirtualHost 127.0.0.1>
ServerName localhost
DocumentRoot "C:/wamp/www"
</VirtualHost>
# Tells Apache to serve your mobile pages to "m.localhost"
<VirtualHost 127.0.0.1>
# The name to respond to ServerName m.localhost
# Folder where the file is located which in your case is
DocumentRoot "C:/wamp/www/mobile/"
<Directory "C:/wamp/www/mobile/">
Allow from all
Order Allow,Deny
AllowOverride All
</Directory>
# Apache will look for these files, in this order, if no file is specified in the URL, but you can add more files apart from the two I listed depending on what you are having
DirectoryIndex index.html index.php
</VirtualHost>
#Here you duplicate the code for your mobile site to also accept your IP address which is 192.168.56.1
<VirtualHost 192.168.56.1>
# The name to respond to ServerName m.localhost
# Folder where the file is located which in your case is
DocumentRoot "C:/wamp/www/mobile/"
<Directory "C:/wamp/www/mobile/">
Allow from all
Order Allow,Deny
AllowOverride All
</Directory>
# Apache will look for these files, in this order, if no file is specified in the URL, but you can add more files apart from the two I listed depending on what you are having
DirectoryIndex index.html index.php
</VirtualHost>
Tested and working. Please don't forget to mark the answer
This problem has been bugging me for days and I really need an answer.
I have a previous WAMP server in which I have configured properly so I can set up virtual hosts for applications that I build. It served me well for months.
Recently, there's this software, in which I think is a Malware, that run in my pc. The software was removed and I scanned the pc and there were no viruses.
I re-installed WAMP server and configured it again. It went well but the virtual hosts are not behaving properly.
These are what I have declared:
In httpd-vhost:
<VirtualHost *:80>
ServerAdmin #removed
DocumentRoot "c:/wamp/www/Thesis"
ServerName pixtcha.dev
<Directory "c:/wamp/www/Thesis">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin #removed
DocumentRoot "c:/wamp/www/mvc-pe-system/web"
ServerName copers.com
<Directory "c:/wamp/www/mvc-pe-system/web">
Options Indexes FollowSymLinks
AllowOverride all
Order Deny,Allow
</Directory>
</VirtualHost>
In my hosts file:
127.0.0.1 pixtcha.dev
127.0.0.1 copers.com
The thing is, I am able to access the pixtcha.dev properly and there were no problems, while the copers.com is inaccessible, when I type it, it redirects me to some website from the web. I just don't understand why this happens. I even tried flushing the dns if there were corrupted local files but I just can't figure it out.
Also, I have tried using the server names from my previous virtual host and they are all inaccessible too. They are giving me:
http://copers.edu.ph is not available
So I resorted to using new server names, but I don't understand why can't I use the previous server names from my previous WAMP configuration. :(
What do you think are the problems? And how to solve them?
Please help. Thanks in advance.
Ok a couple of things that might help here.
As Apache 2.4 is IPV4 and IPV6 aware you need to change your HOSTS file like this so if the browser decides to use IPV6 it knows where to find your domains. I wish I knew what controls the broswers decision, but I dont.
127.0.0.1 localhost
127.0.0.1 pixtcha.dev
127.0.0.1 copers.com
::1 localhost
::1 pixtcha.dev
::1 copers.com
Dont forget to restart the dnscache or reboot after changing this file.
From a command windows, started using the 'Run as Administrator' option, do these 2 commands to restart the dnscache.
net stop dnscache
net start dnscache
Also when you create Virtual Hosts the default host, as defined in httpd.conf, is ignored, so you need to add a VHOST definition for localhost.
Also you are using old Apache 2.2 syntax in your VHOST definitions, incorrectly as well as it happens, and this should be changed to Apache 2.4 syntax
Also it is better to stick to lower case for directory names, Windows does not care but if you ever move code to a Unix live server it may cause confusion.
# Should be the first VHOST definition so that it is the default virtual host
# Also access rights should remain restricted to the local PC and the local network
# So that any random ip address attack will recieve an error code and not gain access
<VirtualHost *:80>
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "c:/wamp/www">
AllowOverride All
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin #removed
DocumentRoot "c:/wamp/www/thesis"
ServerName pixtcha.dev
<Directory "c:/wamp/www/thesis">
Options Indexes FollowSymLinks
AllowOverride all
Require local
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin #removed
DocumentRoot "c:/wamp/www/mvc-pe-system/web"
ServerName copers.com
<Directory "c:/wamp/www/mvc-pe-system/web">
Options Indexes FollowSymLinks
AllowOverride all
Require local
</Directory>
</VirtualHost>
Check and make sure that your scripts (PHP?) in your copers.com root (index.php?) are not redirecting to these outside URLs, or to URLs further inside your local site that would redirect outside as well.
Also in Chrome, you can open the Network tab of Developer Tools to see what actual web requests are being made, and in what order.
Do I need to update my host file and apache httpd.conf files manually whenever I create a new zf project using command.
For ex: if my new project is zendi.
in host file:
127.0.0.1 localhost zendi
in httpd.conf:
NameVirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "C:\wamp\www"
ServerName localhost
</VirtualHost>
<VirtualHost 127.0.0.1>
DocumentRoot "C:\wamp\www\zendi\public"
ServerName zendi
ErrorLog "C:\wamp\logs\apache_error.log"
<Directory "C:\wamp\www\zendi\public" >
Options Indexes FollowSymLinks
AllowOverride all
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
If you are using PHP 5.4, then you can use the built-in web server, and you don't even need Apache.
http://php.net/manual/en/features.commandline.webserver.php
If you need to use virtual host for your newly created zf application then the answer is YES you need to configure it manually command line project creation doesn't configure it for you. But if you don't need to have virtual server for every application you create then you can skip the process and go with direct url:
localhost/zendi/public
(But it is often considered good practice to have virtual hosts configured for the projects that you'll be working for a while)
I'm new to using XAMPP so this may be simple to some people.
I have a few php projects that I would like to be able to debug locally and view in the browser (not concurrently, but without having to change config files/copy project folders each time I want to work on a different project).
On IIS, you could set up multiple sites to serve from your machine, and I'm looking for something similar in XAMPP. When using IIS, I added multiple records to the Windows hosts file so I could access the locally hosted sites by typing friendly web-style addresses (like http://myproject1.dev)
Thanks.
Greg, you're almost there--you need (like Moses said) to setup virtual hosts.
So if your Windows hosts file has
127.0.0.1 localhost
127.0.0.1 mysite-dev.com
127.0.0.1 anothersite-dev.com
Your virtual hosts file (httpd-vhosts.conf) might look like:
<VirtualHost *:80>
DocumentRoot C:/xampp/htdocs/
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
ServerName mysite-dev.com
DocumentRoot "C:/sites/mysite-dev"
<Directory "C:/sites/mysite-dev">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName anothersite-dev.com
DocumentRoot "C:/sites/anothersite-dev"
<Directory "C:/sites/anothersite-dev">
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Don't forget to restart the web server after you make any changes.
I would like to make an additional in terms of up to date information.
XAMMP uses port 80 by default and we are able to publish 1 website. I also use IIS for .Net projects. In this respect, I set the port to XAMMP except the 80 port. So I avoid a conflict.
When we want to publish more than one website, we should do the following operations to httpd.conf (this is the current name).
1. Setting the ports
Find the #Listen expression in the httpd.conf file.
Change Listen 80 to Listen 8000 (or whatever else you want)
Listen 8000
If you need 3 different websites, type the others, including 1 definition on each line, as follows.
Listen 8001
Listen 8002
Listen 8003
2. Define the file paths of sites accessed through ports
Again, find in the httpd.conf file.
Identify the folders of each website as follows.
As you would see, I've created 3 directories called 8000, 8001, 8002 and 8003 under the htdocs directory within the XAMMP directory.
<VirtualHost *:8000>
DocumentRoot "C:\XAMPP\htdocs\8000"
ServerName localhost:8000
<\ VirtualHost>
<VirtualHost *:8001>
DocumentRoot "C:\XAMPP\htdocs\8001"
ServerName localhost:8001
<\ VirtualHost>
<VirtualHost *:8002>
DocumentRoot "C:\XAMPP\htdocs\8002"
ServerName localhost:8002
<\ VirtualHost>
<VirtualHost *:8003>
DocumentRoot "C:\XAMPP\htdocs\8003"
ServerName localhost:8003
<\ VirtualHost>
Restart your Apahche server on XAMMP.
You can now view your 3rd site, such as http://localhost:8003 or http://192.168.1.1:8003/.
Hope to be useful.
This question was asked almost ten years ago, and the answers above are a bit dated. Note that XAMPP has a "How-To" for virtual hosts avilable off the dashboard, when you install it.
From the "Welcome to XAMPP for Windows" page (localhost/dashboard, the default when you first load localhost) click on the "HOW-TO" Guides in the top menu bar. From there, look for the link "Configure Virtual Hosts" which will lead you to the localhost page "http://localhost/dashboard/docs/configure-vhosts.html"
In a nutshell, the process involves editing the "httpd-vhosts.conf" file (typically in C:\XAMPP\apache\conf\extra) and replacing the contents of that file with something like this:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/"
ServerName localhost
</VirtualHost>
# vhosts - note sample entry from XAMPP how-to throws an error, so try this:
<VirtualHost *:80>
DocumentRoot "C:/Users/jdoe/Documents/dev.mysite.com/htdocs"
ServerName mysite.local
<Directory "C:/Users/jdoe/Documents/dev.mysite.com/htdocs">
Require all granted
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Additional vhosts (including SSL hosts) can be had by cloning the entry, and modifying DocumentRoot and ServerName directives and port numbers (e.g. 443 for TLS (SSL)). You can find tutorials on the web for creating and signing your own certificate, if you want to go that route.
The final step is to get your Windows machine to point your browser to the Apache host for your virtual domain (e.g. above, http://mysite.local). Using a text editor (Notebook will do) as administrator append the following entry onto your hosts file, which lives here:
C:\Windows\System32\drivers\etc\hosts
Append this entry to the hosts file:
127.0.0.1 mysite.local
IMPORTANT - you must restart your Windows machine or the new host will not respond. Some documentations will tell you just to restart the browser and Apache server, but I've found that's not sufficient.
IME, the hosts system and Apache directives can be particular, so be patient. You may need to rebuild configs, restart Apache, and restart your machine more than once.