Can't access laravel page in vhost setup - php

I have a problem with the set up of laravel using a vhost. I have a different projects using vhost and it has no problem but when I try to set up this with Laravel I can't access it in my web browser. It just redirect to google page and searching for my vhost url.
So far here's what I did.
I included my vhost entry in httpd-vhosts.conf file
<VirtualHost *:80>
ServerName dev.laravel_validation.local
ServerAlias dev.laravel_validation.local
DocumentRoot "C:/Users/Web4/Desktop/laravel/laravel_validation/public"
<Directory "C:/Users/Web4/Desktop/laravel/laravel_validation/public">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
I include the name in Windows hosts file
127.0.0.1 dev.laravel_validation.local
Then restart Wampserver. And I access the URL dev.laravel_validation.local to my browser but it doesn't display the Laravel's welcome page.
I don't know where did I go wrong. Can you help me with this?

Related

How to access web page using ip for laravel?

I am having problem to access my website using ip from a different pc. For example, the ip that I want to access is 192.168.0.150/season_pass. If I use that ip, the page could not be found but if I just enter 192.168.0.150, it can access the web page. Supposedly 192.168.0.150 should redirect to the dashboard page.
Below are the https-vhosts.conf file that I edit,
<VirtualHost *:80>
DocumentRoot "C:\xampp\htdocs\season_pass\public"
ServerAdmin admin#localhost
ServerName season_pass
<Directory "C:\xampp\htdocs\season_pass\public">
AllowOverride All
Options Indexes FollowSymLinks
Require local
Require all granted
</Directory>
</VirtualHost>
The hosts file,
127.0.0.1 season_pass
::1 season_pass
For the apache, I am using xampp and the development is on laravel framework.

Laravel5 shows index.php content

I'm new to Linux and PHP and I'm trying to access a Laravel app from another device.
Server is running a Centos and it's IP is 192.168.1.250 and my Laravel directory is /var/www/html/vls.
At first it was showing directory listing when I wen to 192.168.1.250/vls in my browser. After some search I added these lines to httpd.con:
<Directory /var/www/html/vls>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
DocumentRoot "/var/www/html/vls/public"
ServerName vls.dev
<Directory /var/www/html/vls/>
AllowOverride All
Order deny,allow
Allow from all
Require all granted
</Directory>
</VirtualHost>
Now when I go to 192.168.1.250/vls it shows index.php content as text in browser.
I even followed the solution described here:
How to stop laravel directory browsing
But then it showed directory listing of /public directory.
Any help is appreciated in advance.
EDIT:
If I make a directory and place an index.php code that includes some PHP code it works fine. But Laravel app doesn't work and shows index.php code on the browser.
Change your dir from <Directory /var/www/html/vls/> to <Directory /var/www/html/vls/public>

vhost showing default wamp page

I am using wamp to build my web application. So I had one vhost at mydomain.com but now I have changed my domain to dev.mydomain.com . For this changes to reflect I have edited etc\hosts file's entry from 127.0.0.1 mydomain.comto 127.0.0.1 dev.mydomain.com and in apache configuration file httpd-vhosts.conf -
<VirtualHost *:80>
DocumentRoot "D:/Software/Installed/wamp/www/myapp/public"
ServerName dev.mydomain.com
<Directory "D:/Software/Installed/wamp/www/myapp">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Require local
</Directory>
When I open url dev.mydomain.com, I see the default wamp config page.
I have gone through many tutorials to find out what mistakes have been done but could find none. It would be helpful if someone throws some light on that. Thanks.
Why is your Directory different than DocumentRoot ??
I think you need to match those and restart your wamp and you are good to go.
Also, you must have index file in directory to see domain running properly.

WAMP httpd.config redirect

I'm using wamp on localhost at c:\wamp\www\.
The project located under: c:\wamp\www\MyProj\public (root).
In file1.php (located in root) I have a link to some fake url (/services/.....).
I'm trying to redirect that url to other file service_router.php (in the same direction as file1.php).
I'm doing that in httpd.config:
<VirtualHost *:80>
ServerName 127.0.0.1
DocumentRoot c:\wamp\www\
<Directory "c:\wamp\www\">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
RewriteEngine on
RewriteCond %{REQUEST_URI} ^/MyProj/public/services/*
RewriteRule . /MyProj/public/service_router.php
</VirtualHost>
But my WAMP refuses to restart.
What's wrong with my configurations?
Can I make a few suggestions.
If you want to use Virtual Hosts, and I consider that a very good idea. You need first to make sure that localhost still works and secondly it is a good idea to move you actual projects out of the \wamp\ folder structure.
So this would be a good starting point for your first ( of many ) VHOSTS
First create a new folder structure somewhere on any of your drives for example
C:\websites\project1\www
Now copy your project to the www folder.
Now setup the vhosts
# must be first VHOST so the that localhost and the wamp menu page still work
# Also makes this the default site so any randon hacks on your ip address
# will come here and hopefully be rejected because it only 'Allows' access
# from this machine ( see Allow Deny )
<VirtualHost *:80>
DocumentRoot "D:/wamp/www"
ServerName localhost
ServerAlias localhost
<Directory "C:/wamp/www">
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "C:/websites/project1/www"
ServerName project1.dev
ServerAlias www.dqsc.old
Options Indexes FollowSymLinks Includes ExecCGI
<Directory "C:/websites/project1/www">
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
</VirtualHost>
Unless you actually want to make this site available to the World can I suggest that you dont use Allow from all.
Try using or the second Allow line if you want to see your site from any machine on your internal network, just use the first 3 of the 4 quartiles of your ip address and it will allow access from any ip starting with those 3 quartiles.
Order Deny,Allow
Deny from all
Allow from 127.0.0.1 localhost ::1
Allow from 192.168.0
Now you need to amend your HOSTS file so that windows knows about your new domain name.
Edit c:\windows\system32\drivers\etc\hosts and add the new site name project1.dev like so, you will have to launch your editor 'Run as Administrator' as this file is protected by windows :-
127.0.0.1 project1.dev
Now restart the "DNS Client" service to refresh the windows dns cache so it see's your new domain name. Start a command window, again "Run as Administrator".
net stop "DNS Client"
net start "DNS Client"
You should now be able to enter http://project1.dev in a browser and it will find you new site.
Finally, once you test that your site is working, put the url rewrite coding in a .htaccess file in the root of your new project.
C:\websites\www\project1\.htaccess

Django/mod_wsgi and PHP as Virtual Hosts on same Apache Server using MAMP

UPDATE: My original question is below, but the code I posted with the question has been edited to the final working solution.
I am trying to run multiple sites on my MAMP development server. Some of the sites are wordpress sites that live in the htdocs in MAMP and some of the sites are django apps that live in a folder titled djangoprojects.
I have been trying to implement the solutions from these stack questions:
multiple django sites with apache & mod_wsgi
How do I run Django and PHP together on one Apache server?
but I have not been successful. I was able to run the django site on apache with the code you see in the first VirtualHost brackets (from the daemon process line onward) but then none of the php sites could be visited.
Help is greatly appreciated. I am new with this and I can't work out the errors.
Here is the code from my httpd.conf:
UPDATE: The code below works. Both the Django App and the PHP applications exist on the localhost server. The PHP related VirtualHost stuff was copied from further up in the MAMP httpd.conf file.
<VirtualHost *:80>
ServerName localhost:80
UseCanonicalName Off
DocumentRoot "/Applications/MAMP/htdocs"
<Directory />
Options Indexes FollowSymLinks
AllowOverride None
</Directory>
<Directory "/Applications/MAMP/htdocs">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
WSGIDaemonProcess site1 display-name=%{GROUP}
WSGIProcessGroup site1
Alias /media/ /Users/sequoia/djangoprojects/dynamics/media/
<Directory /Users/sequoia/djangoprojects/dynamics/media>
Options ExecCGI
Order deny,allow
Allow from all
</Directory>
WSGIScriptAlias /dynamics /Users/sequoia/djangoprojects/dynamics/apache/django.wsgi
<Directory /Users/sequoia/djangoprojects/dynamics/apache>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
A couple of problems to start with:
ServerName is mean to specify the host name not a URL path.
You should never set DocumentRoot to be where your Django site source code is.

Categories