Creating a virtual host for laravel project - php

I am using localhost:8080. Does this make any difference while virtual hosting? when I enter lsapp.test in browser, it says page cannot be reached.

Try to change your port to 8080 in httpd-vhosts file
<VirtualHost *:8080>
...
...
...
# Other directives here
</VirtualHost>
then restart your apache server and access like this lsapp.test:8080.

Related

Start laravel app on apache2.4 on windows 10

I have a laravel app, which I test with php artisan serve.
I discovered that this is a bad practise, because it is not used on production.
I have installed apache2.4, it worked, when I open localhost I see 'It Works'.
Now I try to start my laravel app through apache on my PC.
For this I have done the following steps:
Edited the httpd.conf in Apache\conf, I uncommented this line:
LoadModule rewrite_module modules/mod_rewrite.so
Edited the httpd-vhosts.conf in Apache\conf\extra, I added:
<VirtualHost *:80>
DocumentRoot "Y:/PHP-Projects"
ServerName localhost
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "Y:/PHP-Projects/Project-Admin-PHP/public"
ServerName localhost.eu
</VirtualHost>
Edited the hosts file in Windows\System32\drivers\etc, I added:
127.0.0.1 www.localhost.eu localhost.eu
After every step I restarted the Apache2.4 service, but I still cant access my laravel application. The only thing, what changed is that I now get 'It Works' also on this domain: localhost.eu
What have I missed?
Currently I am starting my laravel app through php artisan serve. I can then access the app at localhost:8000.
Also I know I could set up homestead. But I discovered it too late. I have already configured and installed everything myself, and besides this one issue, everything works.
I'd like to understand how I would connect my laravel app to the apache server correctly myself.
Probably you forgot include file httpd-vhosts.conf file in httpd.conf. Sometimes this line commented by default and you should uncomment this line. After then you should restart apache2 service.
Add server alias on your file config
<VirtualHost *:80>
DocumentRoot "Y:/PHP-Projects/Project-Admin-PHP/public"
ServerName localhost.eu
ServerAlias www.localcost.eu
</VirtualHost>

Apache's virtual host won't work using MAMP because of Pow.cx

I've been struggling with this problem for a while and don't know why I can't acces my virtual host, these are the steps I took:
httpd.conf:
# Virtual hosts
Include /Applications/MAMP/conf/apache/extra/httpd-vhosts.conf
/etc/host:
'127.0.0.1 mysite-dev.com'.
http-vhosts.conf:
<VirtualHost *:80>
DocumentRoot /Volumes/Miguel/Documents/Workspace/htdocs
ServerName mysite-dev.com
</VirtualHost>
Restart MAMP
Access the url through Chrome, the site isn't loaded and I get the error 'connection refused'
Seems like Pow.cx is taking control over port 80 and that's the reason why I can't access my virtual Host... guess I'll try ton config Pow in a way I can use both without any problem.
If anyone else has this same problem you can follow through this guide:
http://nikhgupta.com/code/serving-legacy-php-applications-using-apache-alongside-pow/

Virtual hosts with two servers on localhost

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?

Creating a Virtual Host for Apache MAMP

I'm trying to create a virtual host on my MAMP setup so I can access http://api.localhost for a PHP API I'm trying to build with Slim. Here's the code I've appended to my httpd.conf file:
Name VirtualHost 127.0.0.1
<VirtualHost 127.0.0.1>
DocumentRoot "/Applications/MAMP/htdocs/slim"
ServerName api.localhost
</VirtualHost>
When I restart the server and try to start it up again with this new configuration, it simply won't load. I commented out the new code and it loads fine. Any ideas?
try to use this line
<VirtualHost *:80>
instead of yours
and I think you can remove the first line too...

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>

Categories