Laravel5 shows index.php content - php

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>

Related

Website outside the htdocs

I am configuring website outside the htdocs and I did all changes what are describe here Virtual Host.
But partially it done but routes are not working. Only Home page showing. rest of page showing Object not found!.
like
<VirtualHost *:81>
DocumentRoot "C:\DevlopmentApps\VirtualMarket"
ServerName sjb.localhost
<Directory C:\DevlopmentApps\VirtualMarket>
Options Indexes
AllowOverride none
Require all granted
</Directory>
Now
http://sjb.localhost:81/sjb is working
http://sjb.localhost:81/sjb/find/ not working
Now i figure out some thing that other should be aware with.
If want to configure outside the htdocs the need to do following steps in the follwong link
Virtual host
Here is some thing Deprecated. https://stackoverflow.com/questions/9110179/adding-virtualhost-fails-access-forbidden-error-403-xampp-windows-7?answertab=votes#tab-top
<Directory ..........>
# AllowOverride All # Deprecated
# Order Allow,Deny # Deprecated
# Allow from all # Deprecated
# --New way of doing it
Require all granted
</Directory>
Now one thing which fixed my issue is
Options All
AllowOverride All
Require all granted

Using Python (Flask) and PHP on apache2

I am running a page based on Flask and Apache2/MOD_Wsgi and am wanting to also deploy a page using PHP (a IDE called Codiad). Flask as my main page ( enjay.work ) and I want Codiad to run on enjay.work/codiad
Unfortunately I have the most basic understanding of Apache config and don't know at all how to find what I need.
Here is what I have so far:
<virtualhost *:80>
ServerName enjay.work
DocumentRoot /home/nathan/www/enjay
WSGIDaemonProcess enjay user=nathan group=www-data threads=5 home=/home/nathan/www
WSGIScriptAlias / /home/nathan/www/enjay/enjay.wsgi
<Directory /Codiad>
Options indexes FollowSymlinks MultiViews
AllowOverride All
Require all granted
Allow from all
</Directory>
<Directory />
WSGIProcessGroup enjay
WSGIApplicationGroup %{GLOBAL}
WSGIScriptReloading On
Require all granted
</Directory>
</virtualhost>
now when I navigate to enjay.work/Codiad I get a 404 page. for the php project I am adding to my site I followed these directions (loosly)
I can get just the python to work, or just the PHP to work, when I combine the two Config files I get the Python page but the path that should return the PHP gives me a 404
Change the configuration for your PHP page to point directly at the project (in this case /home/nathan/www/enjay/Codiad) then above that configuration add an alias for the web address you want
Alias /Codiad "/home/nathan/www/enjay/Codiad"
<Directory /home/nathan/www/enjay/Codiad>
**Existing Config**
</Directory>
I think it should be like this.
<Directory /home/nathan/www/enjay>
Options indexes FollowSymlinks MultiViews
AllowOverride All
Require all granted
Allow from all
</Directory>

XAMPP access forbidden issues

Having issues with XAMPP and access forbidden problems.
Started using laravel, complete noob to anything MVC but thought I'd give it a go.
Started having issues with page routing, index page works fine, yet non of my routes work, all come up with a 404 error.
Have a little search around the internet, find out it could be due to my xampp/Apache config.
Had a play with the
Allow from all
and
Require all granted
options, but no dice.
This is my vhosts entry:
<VirtualHost *:80>
DocumentRoot "C:\Users\xxx\Desktop\Projects\xxx\Website-3.0\Website\public"
ServerName gw3.dev
<Directory "C:\Users\xxx\Desktop\Projects\xxx\Website-3.0\Website\public">
Allow from all
Require all granted
Options Indexes
</Directory>
</VirtualHost>
and this is what I edited in the httpd.conf file.
<Directory />
Require all granted
Options FollowSymLinks
AllowOverride All
Allow from all
</Directory>
Made sure that the root directory is not read only.
Yet all I get are 403 - forbidden access errors.
Running Windows 10, fyi.
Not really sure where I'm going wrong here. Is there something I'm missing?
This section
<Directory />
Require all granted
Options FollowSymLinks
AllowOverride All
Allow from all
</Directory>
Provides the basic security for the disk that Apache is installed on. Basic practice is deny access to everything and then allow access to only those directories that Apache should have access to. Also you are using Pache 2.2. and 2.4 syntax together, bad.
So change that back to :-
<Directory />
AllowOverride none
Require all denied
</Directory>
In the definition of the virtual host you are using both Apache 2.2 and 2.4 syntax. Thats not a good idea it can cause Apache to get confused. Also you are using the DOS back slash and that should be the unix forward slash.
So try this
<VirtualHost *:80>
DocumentRoot "C:/Users/xxx/Desktop/Projects/xxx/Website-3.0/Website/public"
ServerName gw3.dev
<Directory "C:/Users/xxx/Desktop/Projects/xxx/Website-3.0/Website/public">
AllowOverride All
Options Indexes FollowSymLinks
Require all granted
</Directory>
</VirtualHost>
If you dont actually intend to allow anybody in the universe to access this site then you can use
Require local
Or if you want to access the site from another device in your local network you could try
Require ip 192.168.1
Note use of only 3 of the 4 quartiles of the IPV4 ip address. This allows access from any ip in that subnet.
Also make sure that you have added gw3.dev to your HOSTS file for both IPV4 and IPV6 addresses
127.0.0.1 gw3.dev
::1 gw3.dev
Retart Apache and try that.
You need
AllowOverride All
too in vhost
also dont forget to reboot the server

Can't access laravel page in vhost setup

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?

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