I have two local projects using Apache and CentOS 7.
I would like to run two projects simultaneously.
How to configure apache config?
you can configure two different virtual hosts on the same port but with different server names
<VirtualHost *:80>
ServerName project1.local
DocumentRoot /var/www/project1
</VirtualHost>
<VirtualHost *:80>
ServerName project2.local
DocumentRoot /var/www/project2
</VirtualHost>
then add the following line to your /etc/hosts
127.0.0.1 project1.local project2.local
then in your browser you should be able to access the two projects on http://project1.local and http://project2.local
Related
I use Windows 10 and XAMPP for local development. I want to create project on laravel 5.5 and access it in browser by project.dev
I add next lines to httpd-vhosts.conf file
<VirtualHost project.dev:80>
DocumentRoot "C:\xampp7\htdocs\server\laravel\project_name\public"
ServerAdmin project.dev
<Directory "C:\xampp7\htdocs\server\laravel\project_name">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
and
127.0.0.1 project.dev
to hosts file. But it does not work (only for laravel),I get 400 error.
This works with all the rest my local projects except those ones on laravel.
I have no problem with access to this project by
http://localhost/server/laravel/project_name/public
What other settings do I have to make to access laravel 5.5 project like project.dev?
1- change VirtualHost project.dev:80 to VirtualHost *:80
2- change ServerAdmin project.dev to ServerName project.dev
and after these changes restart your apache service
I know I'm probably missing something simple, but I've exhausted all resources trying to get this working.
I'm running my Apache on Port:5000 and trying to direct to lsapp.dev instead of http://localhost:5000/lsapp/public/ with:
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/lsapp/public"
ServerName lsapp.dev
</VirtualHost>
I have tried VirtualHost *:5000 but still can't get it work?
you can use this on command line in your project root
php artisan serve --port=your_port_number
or do this:
edit httpd-vhosts.conf that is located in C:\xampp\apache\conf\extra\httpd-vhosts.conf and add following lines at the end of the file:
# VirtualHost for LSAPP.DEV
<VirtualHost lsapp.dev:80>
DocumentRoot "C:\xampp\htdocs\lsapp\public"
ServerAdmin lsapp.dev
<Directory "C:\xampp\htdocs\lsapp">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
our apache is listening to lsapp.dev connections, but we have to configure our hosts file that allows to redirect lsapp.dev to the localhost that is located in C:\Windows\System32\drivers\etc
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 lsapp.dev
Set your Virtual host file like this.
<VirtualHost *:80>
DocumentRoot "D:\laravel Task\laravel\blog" //here set your project storage path
ServerName localhost.test.com // set your url for your project
<Directory "D:\laravel Task\laravel\blog"> // again set your project storage path
AllowOverride All
Order allow,deny
Allow from all
Require all granted
set your hosts file like this
127.0.0.1 localhost.test.com
Now you can Run your project
localhost.test.com
//OR//
If you dont want to use virtual host, then you can run your project like this
goto your project folder=>
command line in your project root=>php artisan serve
your project will run in
http://127.0.0.1:8000/
I have two installations of laravel. One in a folder called "laravel" and the second in a folder called "learningLaravel". Both of them are siblings in the same parent folder. Before i installed "learningLaravel" i used to access the site in "laravel" through localhost/laravel/public, and everything works fine .
After i installed "learningLaravel", i decided to create a virtual host for it on my WAMP server with the name "learningLaravel.dev" . My [windows/system32/drivers/etc/hosts] file looks like this:
127.0.0.1 localhost
127.0.0.1 localhost
// I added this entry. The first two entries above was already there
127.0.0.1 learninglaravel.dev
I added the following to my Apache "httpd-vhosts.conf"::
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/learningLaravel/public"
ServerName learningLaravel.dev
</VirtualHost>
Now i can access "learningLaravel" through learningLaravel.dev. But when i want to access the site in the "laravel" folder through localhost/laravel/public, i get a message ::
Not Found
The requested URL /laravel/public was not found on this server.
I try localhost also and i get ::
Not Found
The requested URL / was not found on this server.
The problem i have now is anything that begins with localhost doesn't work, but learningLaravel.dev works.
What changes do i need to make? thanks.
Just define 2 virtual hosts:
The first catches all domains which don't have their own virtual host. In this example these are domain1.dev, domain2.dev, domain3.dev and localhost.
The second host catches the domain learninglaravel.dev
httpd-vhosts.conf
<VirtualHost *:80>
DocumentRoot "c:/wamp/www/"
ServerName localhost
ServerAlias *.localhost
</VirtualHost>
<VirtualHost learninglaravel.dev:80>
DocumentRoot "c:/wamp/www/learningLaravel/public"
ServerName learninglaravel.dev
ServerAlias *.learninglaravel.dev
</VirtualHost>
windows/system32/drivers/etc/hosts
127.0.0.1 learninglaravel.dev
# you don't need the following this is just for explanation:
127.0.0.1 domain1.dev
127.0.0.1 domain2.dev
127.0.0.1 domain3.dev
I’m having a hard time getting multiple sites working with MAMP using Virtual hosts. Below is what I have set up on my MBA. If I open up my web browser and go to "http:local.login.dev" or "http://dev.login.localhost" (after reconfigure) I get the index page that’s saved in /Users/aaron/localhost. First item listed in my Virtual hosts section Not the index page saved in the Virtual Host I want to get to. Other sites I have setup give me the same result.. "http:next.site.localhost" = displays the index page in /Users/aaron/localhost.
Does anybody have any thoughts? My final goal is to configure MAMP Virtual hosts to work and test with SSL.
Bottom line is it seems like ONLY the first Virtual host entry is read and that's whats used for every host listed. Am I missing some setting somewhere??
Environment:
- MBA with OS X, Yosemite
MAMP 3.0.7.3 using ports 80, and 3306 for http and mysql respectively
httpd.conf File:
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
127.0.0.1 localhost
127.0.0.1 local.login.dev
<VirtualHost *>
DocumentRoot "/Users/aaron/localhost"
ServerName localhost
</VirtualHost>
<VirtualHost *:80> — I tried both with and without :80
DocumentRoot "/Users/aaron/localhost/training/login/public"
ServerName local.login.dev
</VirtualHost>
Also tried configuring my hosts and httpd-vhosts.conf this way - From another post:
127.0.0.1 localhost
127.0.0.1 dev.login.localhost
<VirtualHost *>
DocumentRoot "/Users/aaron/localhost"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/aaron/localhost/training/login/public"
ServerName dev.login.localhost
ServerAlias dev.login.localhost
<Directory "/Users/aaron/localhost/training/login/public">
Allow from All
AllowOverride all
Options -Indexes +FollowSymlinks
</Directory>
</VirtualHost>
Just playing around more I commented out the first "Localhost" in my httpd-vhosts.conf file and looks like I can now navigate to my local sites correctly. Below is what I currently have configed..
httpd-vhosts.conf:
# <VirtualHost *>
# DocumentRoot "/Users/aaron/localhost/"
# ServerName localhost
# </VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/aaron/localhost/training/login/public"
ServerName dev.login.localhost
ServerAlias dev.login.localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/aaron/localhost/site1"
ServerName dev.site1.localhost
ServerAlias dev.site1.localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/Users/aaron/localhost/site2"
ServerName dev.site2.localhost
ServerAlias dev.site2.localhost
</VirtualHost>
Hosts File:
127.0.0.1 localhost
######Locahost Dev Sites
127.0.0.1 dev.login.localhost dev.site1.localhost dev.site2.localhost
Now to see if I can get SSL working.
If any of this is incorrect, please let me know... but this config is the only way I can get the Virtual hosts working, as of now, using port 80... If I have issues mixing with 443 I'll update
I have two apache web servers running on my laptop running on windows 7. One on port 80(XAMPP) and the other 81(Zend CE). I use the Zend Server one to develop sites. I want to setup my virtual hosts on the second server using port 81 and not port 80. I have tried but all am getting is a request to search on google.
<VirtualHost *:81>
DocumentRoot "C:\Program Files (x86)\Zend\Apache2\htdocs"
ServerName localhost:81
</VirtualHost>
<VirtualHost *:81>
DocumentRoot "C:/Program Files (x86)/Zend/Apache2/htdocs/folder"
ServerName folder.app
</VirtualHost>
I made the changes to the hosts file.
did you remember to edit:
NameVirtualHost *:81
in the top of your vhosts file?