Having problems in running lumen on xampp virtual host - php

I am having trouble running a lumen site(website2) in xampp on Ubuntu through virtual host.
This what my hosts file look like.
127.0.0.1 localhost
127.0.0.1 website1.local
127.0.0.1 website2.local
And here is my what my httpd-vhosts.conf looks like
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "/opt/lampp/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin support#website2.com
DocumentRoot "/opt/lampp/htdocs/website2/public/"
ServerName website2.local
</VirtualHost>
<VirtualHost *:80>
ServerAdmin support#website1.com
DocumentRoot "/opt/lampp/htdocs/website1/"
ServerName website1.local
</VirtualHost>
The website1 works fine, but when I access website2 which is a lumen project gets this error in chrome.
ERR_NAME_NOT_RESOLVED
Have tried adding this in httpd-vhosts.conf but doesnt work.
<Directory "/opt/lampp/htdocs/website2/public/">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
When I run the lumen project by terminal using
php -S localhost:8000 -t public
It runs perfect. What could be the problem?.
Thanks.

Related

Virtual host not working on XAMPP, something very strange happenning

Hi I have browsed all the resources, but still seems can't find the solution.
I have XAMPP Control Panel v 3.2.4 (compiled Jun 5th 2019) installed on my computer, it is installed in d:\xampp. I want to create a Virtual host, so that I can correctly use various global PATH variables.
I followed instructions closely.
This is from my D:\xampp\apache\conf\extra\httpd-vhosts.conf:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "D:\xampp\htdocs"
<Directory "D:\xampp\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName ikeen.localhost
DocumentRoot "D:\xampp\htdocs\ikeen"
SetEnv APPLICATION_ENV "development"
<Directory "D:\xampp\htdocs\ikeen">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
I have added following lines to the end of httpd.conf:
<Directory />
AllowOverride none
Require all granted
</Directory>
I have the following line in my hosts file in windows:
127.0.0.1 ikeen.localhost
This is the structure of my site directory
In order to avoid cache I open URL in the incognito mode and from different browsers. I always get redirect to dashboard - https://ikeen.localhost/dashboard/, it opens the standard "Welcome to XAMPP for Windows 7.4.3"
I have heard that it has something to do with https, as I'm always transferred to https URL even if I try to use http. I've looked at httpd-ssl.conf, but I don't know what to do there. Any ideas?
Finally! For everyone who is looking for the solution do the following:
My desired site is located at D:\xampp\htdocs\ikeen.
1) Add this to your httpd-vhosts.conf:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "D:\xampp\htdocs"
<Directory "D:\xampp\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName ikeen.localhost
DocumentRoot "D:\xampp\htdocs\ikeen"
SetEnv APPLICATION_ENV "development"
<Directory "D:\xampp\htdocs\ikeen">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
2) Add this to the end of httpd.conf:
<Directory />
AllowOverride none
Require all granted
</Directory>
3) Add this line to your hosts file in Windows directory
127.0.0.1 ikeen.localhost
4) Finally, this is the step that is missing from all the solutions. Add this to your httpd-ssl.conf, after the same section for your localhost (usually www.example.com), change example.com to your local settings for localhost, so that the whole section looks smth like this
<VirtualHost _default_:443>
# General setup for the virtual host
DocumentRoot "D:/xampp/htdocs"
#ServerName www.example.com:443
ServerName localhost
ServerAdmin admin#example.com
ErrorLog "D:/xampp/apache/logs/error.log"
TransferLog "D:/xampp/apache/logs/access.log"
# General setup for the ikeen host
DocumentRoot "D:/xampp/htdocs/ikeen"
#ServerName www.example.com:443
ServerName ikeen.localhost
ServerAdmin admin#example.com
ErrorLog "D:/xampp/apache/logs/error.log"
TransferLog "D:/xampp/apache/logs/access.log"
I had the same issue. Problem was solved by removing the standard virtual host entry and i wasn't redirected to the root directory.
Just remove these lines of code:
<VirtualHost *:80>
ServerName localhost
DocumentRoot "D:\xampp\htdocs"
<Directory "D:\xampp\htdocs">
DirectoryIndex index.php
</Directory>
</VirtualHost>
If the case does not work, maybe change httpd-ssl.conf
My 3 sites worked, localhost, test1.com, test2.com
#
<VirtualHost _default_:443>
DocumentRoot "c:/xampp/htdocs"
ServerName localhost
ServerAdmin admin#example.com
ErrorLog "c:/xampp/apache/logs/error.log"
TransferLog "c:/xampp/apache/logs/access.log"
...
</VirtualHost>
#test1
<VirtualHost _default_:443>
DocumentRoot "c:/xampp/htdocs/test1"
ServerName test1.com
ServerAdmin admin#example.com
ErrorLog "c:/xampp/apache/logs/error.log"
TransferLog "c:/xampp/apache/logs/access.log"
...
</VirtualHost>
#test2
<VirtualHost _default_:443>
DocumentRoot "c:/xampp/htdocs/test2"
ServerName test1.com
ServerAdmin admin#example.com
ErrorLog "c:/xampp/apache/logs/error.log"
TransferLog "c:/xampp/apache/logs/access.log"
...
</VirtualHost>

WAMP You don't have permission to access / on this server

You don't have permission to access / on this server.
I created a new virtual host for my project. And now I cant access all locally stored projects that I could access earlier. But project on virtual host works.
http-vhosts.conf:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot "c:/Apache24/docs/dummy-host.example.com"
ServerName dummy-host.example.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error.log"
CustomLog "logs/dummy-host.example.com-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#my_poject.com
DocumentRoot "c:\wampF\www\my_project\web"
ServerName my_poject.com
ErrorLog "logs/my_poject.com-error.log"
CustomLog "logs/my_poject.com-access.log" common
</VirtualHost>
hosts:
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 localhost
127.0.0.1 my_poject.com
I think you are using Apache 2.4.
Use
Require all granted
instead of all
Order allow,deny
Allow from all
from your all .conf files
for eg-:http.conf, httpd-vhosts.conf, httpd-autoindex.conf like that.
Then restart your system.
Regds

Apache Server Hosting Multiple Sites Using Different Directories (CentOS)

Please help me setup correct configuration on apache server. I don't know what it is called but I want to setup multiple sites on my server (Amazon EC2 (CentOS) server). It doesn't have a domain name yet.
I have installed the required software including php (checked with phpinfo.php). It is working fine.
Now, I want to host two different php based sites on my machine.
Assume, my IP address is x.y.z.a
Directories :
/var/www/html/crm
/var/www/html/crmpanel
/var/www/html/mysite
In my httpd.conf, I have :
NameVirtualHost *:80
ServerName x.y.z.a
DocumentRoot "/var/www/html"
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName x.y.z.a
ServerAlias x.y.z.a
DocumentRoot "/var/www/html/crm"
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName x.y.z.a
ServerAlias x.y.z.a
DocumentRoot "/var/www/html/crmpanel"
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName x.y.z.a
ServerAlias x.y.z.a
DocumentRoot "/var/www/html/mysite"
ErrorLog /var/log/httpd/error_log
CustomLog /var/log/httpd/access_log combined
</VirtualHost>
If I run "httpd -S", it returns 'Syntax OK'. Apache server starts without any errors.
Please help me understand what is wrong in my configuration.
You need to set the ServerName and ServerAlias (Domain names instead of the ip) for corresponding virtual host entry and also the correct DocumentRoot .
The ServerAlias is optional .
ServerName : xyz.com
ServerAlias : www.xyz.com
please refer this blog post for detailed explanation .

Server name on virtual host not working

please i need your help. I am working on a zend framework 2 project, the project's name in Wamp/www folder is pizza.
i tried to configure a virtual host on hosts file,httpd.conf and httpd-vhosts.conf to work with this project url: pizza.local/
instead of this: localhost:8080/pizza/public/
but something is not ght with my configuration.
note that I am using localhost:8080 not localhost.
Please help me to find what I did wrong. Here's my files:
httpd.conf:
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
httpd-vhosts.conf:
<VirtualHost *:8080>
ServerAdmin webmaster#localhost.com
DocumentRoot "c:/wamp/www"
ServerName localhost
ServerAlias www.localhost
ErrorLog "logs/localhost-error.log"
CustomLog "logs/localhost-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "c:/Apache24/docs/dummy-host2.example.com"
ServerName dummy-host2.example.com
ErrorLog "logs/dummy-host2.example.com-error.log"
CustomLog "logs/dummy-host2.example.com-access.log" common
</VirtualHost>
<VirtualHost *:8080>
DocumentRoot "c:/wamp/www/pizza/public"
ServerName pizza.local
<Directory "c:/wamp/www/pizza/public">
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
hosts file:
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
127.0.0.1 localhost
127.0.0.1 pizza.local
127.0.0.1 localhost
As you are using this VHOST on port 8080. You need to mention in URL as below.
http://pizza.local:8080/

virtual host on Apache in windows7

As i tried to configure my virtual host on apache(xampp) in windows7 - x64.
I put something like this,
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/projects/mysite/public"
ServerName www.mysite.com
ErrorLog "logs/www.mysite.com-error.log"
CustomLog "logs/www.mysite.com-access.log" common
</VirtualHost>
And in my hosts file (C:\Windows\System32\drivers\etc\hosts) i put something like this,
127.0.0.1 localhost
127.0.0.1 mysite.com
And i run it on the browser,
http://www.mysite.com -
Server not found
Firefox can't find the server at www.mysite.com.
Do i missed something to configure? Any ideas..
Your hosts file needs to be
127.0.0.1 localhost
127.0.0.1 mysite.com
127.0.0.1 www.mysite.com
Because mysite.com and www.mysite.com are not the same. I recommend add ServerAlias into your vhost.conf and change ServerName
NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot "C:/xampp/htdocs/projects/mysite/public"
ServerName mysite.com
ServerAlias www.mysite.com
ErrorLog "logs/www.mysite.com-error.log"
CustomLog "logs/www.mysite.com-access.log" common
</VirtualHost>
Try this..
NameVirtualHost *:80
<VirtualHost *:80>
ServerName mysite.com
ServerAlias www.mysite.com
DocumentRoot "C:/xampp/htdocs/projects/mysite/public" #Make sure that your httpd.conf file has DocumentRoot set to your htdocs folder or the folder in which your site is in.
CustomLog logs/site.com.access.log combined
ErrorLog logs/site.com.error.log
</VirtualHost>

Categories