I am trying to install two independent, separate CakePHP applications using different databases and domains.
The goal is to be able to access these sites just by typing in the different domain names, i.e. instead of typing localhost/controllerName ideally would be client1/controllerName and client2/controllerName or just anything to differentiate the names and access to the apps.
I am using WAMPSERVER (it is Apache 2.2.17 + mySQL + PHP + phpMyAdmin).
I have already found some tutorials but part of them is just messy, part of them doesn't really refer to my case.
Thanks in advance!
Setup multiple virtual hosts
To do what you ask all you need to do is setup multiple virtual hosts i.e. in your apache config file:
<VirtualHost *:80>
ServerName client1.dev
DocumentRoot /my/apps/are/here/client1/webroot
</VirtualHost>
<VirtualHost *:80>
ServerName client2.dev
DocumentRoot /my/apps/are/here/client2/webroot
</VirtualHost>
You'll also need to edit your hosts file or router so that it contains:
127.0.0.1 client1.dev client2.dev
With that, http://client1.dev and http://client2.dev will both point at your local machine and each domain map to a different application.
maybe this helps:
http://www.dereuromark.de/2011/05/29/working-with-domains-locally/
I use WAMP too
Related
I have laravel setup and I am trying to create subdomain routing. Basically my route needs to accept this parameter
blog.example.dev
I have my routes set up now I just need to create virtual host. As my domain in laravel app accepts blog.example.dev . What are the steps I need to do in order to create the virtual host? Also any other changes should I make in application like htaccess.
I am using latest version of laravel
For the OS I am using Ubuntu 17.
Edit: Making virtual host is quite easy in linux but it doesn't work anything like how I imagined. The laravel serve should start the page but it doesn't and page is unreachable even if I make virtual host. Any tips would be great I have tried to create virtual host via DigitalOcean blog.
https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
source
A while back, Google purchased the .dev TLD (Top Level Domain). At that time, they announced that they had no plans for it and that they were only going to use it for internal purposes. For years, the .dev TLD was primarily used for developers and designers to use in their local development environments. It was considered general acceptable use and, as a result, developers everywhere are now running sites locally which may now be affected.
Recently Google announced that in a soon to be released update to Chrome, they will be forcing .dev to HTTPS. In short, this means that if you are running local sites using .dev AND running Google Chrome, you will find your site unreachable. Fortunately, there are a couple of options which are fairly simple to implement to get around this issue. Keep in mind that since .dev has been a standard TLD for local development for some time, this new policy by Google will affect you whether you are using DesktopServer or any other local development tool which utilizes the .dev TLD. This issue is NOT specific to DesktopServer.
Therefore you need to use any other extension other than .dev like .com, .test. In your virtual hosts file of apache add new entry as follows:-
<VirtualHost *:80>
ServerAdmin webmaster#dev.blog.com
ServerName dev.blog.com
ServerAlias dev.blog.com
DocumentRoot /var/www/blog/public
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
And add this new entry to your local machine hosts file:-
127.0.0.1 dev.blog.com
Restart the apache server to load new changes.
Note:- blog is the name of your laravel project. Change it according to what you have named.
`<VirtualHost *:80>
ServerAdmin webmaster#dummy.com
ServerName projectname.local
ServerAlias projectname.local
DocumentRoot "c:xampp/htdocs/projectname/public"
ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>`
Make virtual host using .local
127.0.0.1 projectname.local
Add this line in your host file
And restart your local server
Solved
Basically I just created the virtual host but I noticed some strange behaviour in laravel after placing subdomain on top of file it worked. I didn't knew that laravel would process suddomain routes first and if you place subdomain routes after some routes then it didn't work then you would not get desired routes.
About apache it seems that I couldn't make the subdomain work and from what I have learned in local environment how it works is that domain must come first here.
ServerAlias blog.example.dev didn't work in ServerName example.dev domain.
I created two seperate virtual host one for example.dev and another for blog.example.dev. Also thanks to parthu_panther I changed the .dev to another .local.
Also the hosts file was same
127.0.0.1 example.local
127.0.0.1 blog.example.local
Please correct me if I am wrong.
I Have a webserver running on my raspberry pi and I am using it for multiple projects. I can easily enough access the different pages with something of the from ip-addrss\project-name.php. I was looking to eliminate the ip address and found I could set up the domain names on my router. so http:/projector or projector.local redirects to the raspberry pi. The problem is it always goes to the default page. I can setup http:/ProjectA and http:/ProjectB but they both go to index.php. is there a way in php to redirect based on the url used to get there. so index.php would redirect to projectA.php or projectB.php depending on which url was used? I looked through $_SERVER and $_POST but they didn't seem to have the right information. Some research lead me to believe apache could do this but I have experience configuring apache.
You COULD do it in PHP, by checking $_SERVER['HTTP_HOST'], but that value can be manipulated by who is making the request. So I can access http://ProjectA while specifying the headers host: ProjectB or similar, and you will think that it's ProjectB.
In fact, if you look at the HTTP request, HTTP_HOST is the only way one would determine the domain name. So it doesn't matter if you do it in PHP or Apache.
In Apache, you could do it by enabling vhosts mod for apache. If you're running linux, the command line might be something like this a2enmod vhosts_alias. This will allow you to configure different hosts, determined by the host HTTP header, and IP. Each virtual host points to an individual directory. You can have 2 hosts pointing at the same directory, but you'd have to modify the directory properties, something like this:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName ProjectA
ServerAlias www.ProjectA #you can skip this line if it doesn't apply
DocumentRoot /var/www/foo
<Directory "/var/www/foo">
DirectoryIndex ProjectA.php
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
I didn't try to configure the same directory differently for 2 different hosts. My instincts say that it should work, but it may not.
Here's a guide on how to configure virtual hosts on Ubuntu. https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-14-04-lts
I have no idea how different it is on Raspberry Pi. But the apache config files should have exactly the same syntax and rules. Only paths and commands might differ.
On my CentOS Linux VPS I have full LAMP installed. I have a CakePHP website (and intend to add a few more) as a virtual host. I also have a web based bug tracker called MantisBT that is implemented in PHP. I'd like to set up my Apache configuration file (/etc/httpd/conf/httpd.conf) to index both side-by-side. My websites are not in DNS. I access them using the raw IP number.
Here's my directory structure:
/var/www/
MyCakePhPApp/
html/
mantisbt/
Here's what I have in my httpd.conf file:
# This makes my MantisBT work under http:/<my_ip>/mantisbt
DirectoryIndex index.php index.html
# This makes my CakePhP work under http:/<my_ip>
<VirtualHost *:80>
ServerAdmin webmaster#tecadmin.net
ServerName example.com
DocumentRoot /var/www/MyCakePhPApp
<Directory /var/www/MyCakePhPApp>
Allowoverride All
</Directory>
</VirtualHost>
With this my CakePhP is accessible as "http:/my_ip" but my mantisbt site is not accessible. "http:/my_ip/mantisbt" goes to CakePhP and says that controller is missing. If I comment out the entire VirtualHost, then Mantis is indeed accessible as: "http:/my_ip/mantisbt", but of course then my CakePHP site is not accessible.
Does anyone know how to get both these websites working side-by-side?
On my windows server we host dozens of websites and web apps. We use WAMP.
I am learning about Laravel and want to use it for just website. According to this guide (http://codehappy.daylerees.com/project-structure) which is talking me through the project structure, "public is the directory that you must point your web server to".
So if I host the site on wamp/www/projects/example_site
And use a vhost to rename to point www.examplesite.com to the example_site folder, can I use example_site are the public folder? And will this cause any conflicts with my other projects on the parent folders? It seems like Laravel does things to session storage and other important things and it's extremely important the other sites aren't affected since they get millions of hits.
It might be a better idea to include the project files somewhere else on the server, outside of the web directory and simply direct the webserver to the relevant public folder using the virtual host configuration:
For example, the various Laravel installations could go into folders:
C:/wamp/projects/site1
C:/wamp/projects/site2
C:/wamp/projects/site3
then simply configure the virtual hosts in apache like:
<VirtualHost *:80>
ServerName site1.com
DocumentRoot C:/wamp/projects/site1/public
</VirtualHost>
<VirtualHost *:80>
ServerName site2.com
DocumentRoot C:/wamp/projects/site2/public
</VirtualHost>
<VirtualHost *:80>
ServerName site3.com
DocumentRoot C:/wamp/projects/site3/public
</VirtualHost>
You could locate your laravel installation outside of the "projects" folder, for example at "wamp/www/laravel", and then create a symlink at "wamp/www/projects/laravel" that points to "wamp/www/laravel/public".
Symlink Reference: http://nareshkhokhani.blogspot.com/2008/05/virtual-directory-in-wamp-using.html
I am running xampp as an intranet server using 'virtualhost' for 15 'sites' inside our network and things are working fine with 3 exceptions. First problem is my biggest-my 2TB drive is full and I need to add another drive to the server to call up data - how can I do this?
Here are 2 virtual domains from the vhosts file - the 3rd example is what i need to accomplish.
<VirtualHost 172.16.106.162:80>
ServerName clubcal.iserver
ServerAlias www.clubcal.iserver
DocumentRoot "F:/xampp/htdocs/clubcal"
</VirtualHost>
<VirtualHost 172.16.106.163:80>
ServerName digiport.iserver
ServerAlias www.digiport.iserver
DocumentRoot "F:/xampp/htdocs/digiport"
</VirtualHost>
This is an example of what I need to do:
<VirtualHost 172.16.106.164:80>
ServerName tzone.iserver
ServerAlias www.tzone.iserver
DocumentRoot "G:/public_html/tzone"
</VirtualHost>
This xampp server is a separate Windows7 (64bit) system in our network with windows Active Directory resolving DNS issues inside our VLAN (I will downgrade it to 32bit this weekend).
My hosts file resolves ip#'s to domain names in the server, the NIC is assigned with multiple IP #'s so it does work everywhere on our VLAN.
Any insight will be much appreciated.
If you want to sort of "span" the drive, Windows has this handy feature (similar to linux's symlinking) called mklink which you can create a folder in the current directory that is just a symbolic link to the drive. Quick and easy way to span it. I am not sure of any downsides to do doing this, other than if the drive letter changes (if external drive).
That way you should not have to add or change any of your paths in the config etc. Not sure if that is what you were looking for, but hopefully it helps.
Also, did you try your 3rd config you pasted? Did it not work? From what I can see, as long as permissions are fine it should work that way.
Perhaps an issue with permissions in the network?
Not sure if it makes a difference, but maybe worth trying to add this to your 3d cfg:
<Directory "G:/public_html/tzone">
Options Indexes FollowSymLinks Includes ExecCGI
Order allow,deny
Allow from all
</Directory>