Laravel 5 localhost installation not working - php

I just installed Laravel 5 in my local environment on Mac Yosemite. I've set up Laravel in a directory and then created an Apache Virtual Host to point to that directory.
The root of the project can now successfully be accessed by visiting http://myproject.localhost.com. However, I don't see the Laravel welcome screen. Instead, I just see a blank white page, and I can't figure out why.
Chrome is showing a 500 Internal Server error when it tries to load the domain. The same thing happens if I try to access the index.php file directly: http://myproject.localhost.com/index.php.
I wanted to look in the Laravel error log to see what the issue is, but that left me even more confused because the store/logs directory is empty.
I know the virtual host setup is correct because when I point the virtual host to another project, that does not use Laravel, it works correctly. Also, I was previously receiving permission errors from the vendor directory, which I resolved. I thought that was the last issue that needed to be fixed before the welcome page would load correctly, but to my surprise, I only see a blank screen.
Has anyone experienced this before? Is there any more information I can provide to help solve this?
Here is my virtual host configuration:
<VirtualHost *:80>
ServerAdmin webmaster#slopes.localhost.com
DocumentRoot "/Users/myusername/dev/slopes/public"
ServerName slopes.localhost.com
ErrorLog "/private/var/log/apache2/slopes.localhost.com-error_log"
CustomLog "/private/var/log/apache2/slopes.localhost.com-access_log" common
<Directory "/Users/myusername/dev/slopes/public">
Require all granted
AllowOverride All
</Directory>
</VirtualHost>
When I try to access index.php in the browser, I see the request in /private/var/log/apache2/slopes.localhost.com-access_log, and it shows a 500 response. It produces no entries in /private/var/log/apache2/slopes.localhost.com-error_log.

I just did the same thing (also Yosemite) and here's the solution to my issue, maybe it is yours too.
Edit the public/.htaccess, comment the following lines:
<IfModule mod_negotiation.c>
Options -MultiViews
</IfModule>
to
#<IfModule mod_negotiation.c>
# Options -MultiViews
#</IfModule>
Check if it works.
Edit: Check your httpd-vhosts.conf file, does it looks something like this?
<VirtualHost *:80>
ServerAdmin you
ServerName www.myproject.localhost.com
ServerAlias myproject.localhost.com
DocumentRoot "/path/to/webfolder/laravel/public"
ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
</VirtualHost>
Check your ErrorLog, if you don't have it, add it, something must be there since the 500 is being throwed by Apache. Also, double check you're pointing the root to the public/ folder
EDIT: After chatting (https://chat.stackoverflow.com/rooms/73694), #Kyslik figured out it was the lack of the mcrypt extension, guided a new php and mcrypt install through brew. Then permission to storage/ and it worked.

Related

Development mode on Symfony2 virtual hosts

I was boring about my large url http://localhost:8888/site/web/app_dev.php, so, I created apache virtual hosts. When I write http://site.dev in my browser, everything is working, my website appears.
The problem is that my Symfony2 website seems to be in dev / prod mode whereas I point to app_dev.php (in the .htaccess).
I have the debug bottom toolbar (it shows me "dev environment"), I can do dumps, but when I modify a file (JS, Twig, and so on), I have to execute, each time, php app/console assetic:dump (I hadn't before).
My virtual host :
<VirtualHost *:80>
ServerName site.dev
ServerAlias www.site.dev
DocumentRoot /Applications/MAMP/htdocs/bo/web
<Directory /Applications/MAMP/htdocs/bo/web>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
</VirtualHost>
EDIT : I noticed that the website is so much faster like that (site.dev) than before (with the localhost URL). Don't know why, and still don't know how to fix the php app/console assetic:dump problem...
You need add this line DirectoryIndex app.php
<VirtualHost *:80>
ServerName site.dev
ServerAlias www.site.dev
DocumentRoot /Applications/MAMP/htdocs/bo/web
DirectoryIndex app.php
<Directory /Applications/MAMP/htdocs/bo/web>
AllowOverride All
Order Allow,Deny
Allow from All
</Directory>
</VirtualHost>
Don't you have any other problems but worrying about the lengths of the URL? :)
But seriously, try starting the internal PHP/Symfony server with the following command:
$ app/console server:start
The development version of your app will be at http://localhost:8000. Nice and short.
Based on your comment, it turns out that the actual problem you have is hardcoding URLs in your JS. The solution for that is https://github.com/FriendsOfSymfony/FOSJsRoutingBundle.
Basically, that bundle lets you expose routes to your JS so that you avoid hardcoding URLs there.

Getting 404 error when accessing php page in apache in a simple php application?

I have created a simple php file sample.php under /var/www/project/dummy/test/sample.php
Here is the httpd.conf
Listen 8080
<VirtualHost *:8080>
ServerName example.com
DocumentRoot "/var/www/projects/dummy/test"
<Directory "/var/www/projects/dummy/test">
AllowOverride All
Allow from all
</Directory>
</VirtualHost>
Here is the sample.php (just checking if memcache is enabled)
<? php
if(class_exists('Memcache')){
echo "found";
}
?>
when I access localhost:8080/sample.php or localhost:8080/test/sample.php, I get 404 error. I am unable to figure out what is going wrong.
I am concerned why localhost if failing.
To add to that, even www.example.com/sample.php is failing.
Thanks for help
P.S: I have mapped ip address in /etc/hosts as follows:
127.0.0.1 example.com www.example.com localhost
why is localhost failing?
The document root in httpd.conf is /var/www/projects/dummy/test, however you said the files were located at /var/www/project/dummy/test/sample.php. Note "project" is singular in one and plural in the other. This would cause 404's.
The Apache logs are also a good place to start when debugging 404's. I'm not sure which OS you're running, but on Ubuntu they can be found at /var/log/apache2/error.log.

Centos Apache server doesnt seem to redirect

I am trying to set up my apache server. So far I have the following apache config:
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host.example.com
DocumentRoot /var/www/system_learningbank/
ServerName www.learningbypower.dk
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
(You can try it out by going to www.learnbypower.dk)
The login screen works fine. However, when I log in it seems as if it's redirecting to another folder where my old system was.
Can anyone tell me what I can do to stop this from happening?
This is an error in your application configuration. The application is failing. Check the logs. Likely its caused by a syntax error or, maybe missing libraries like GD, etc.
Look at the log file:
logs/dummy-host.example.com-error_log

VIrtualHost Options returns an index of the site folder

I am not sure why this is happening as I am not very knowledgeable when it comes to Apache. Below is a copy of my VirtualHost.
If this gives any extra help as to how to get it to work, I am trying to run a CakePHP site. I know the site itself has no issues as I have another location I manage the code from and can get it running locally through Apache there.
<virtualhost *:80>
DocumentRoot "C:/sites/sitename"
ServerName dev.sitename.com
ErrorLog "logs/sitename.com-error.log"
CustomLog "logs/sitename.com-access.log" common
<directory "C:/sites/sitename">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order Allow,Deny
Allow from all
</directory>
</virtualhost>
I am running this on Apache 2.0 and Win7sp1
UPDATE
I never found the real solution using the route I was on. I downloaded a fresh copy of WAMP and was soon able to get everything up and running, no problem.
In order to prevent apache from showing the directory listing, you need to disable indexes. Also, it's best to disable MultiViews as that will enable content-negotiating, which may produce unwanted side-effects
Change the options to;
Options -Indexes FollowSymLinks
Then, check that the .htaccess file is present inside your webroot (C:/Sites/Sitename), as that file is used to enable mod_rewrite
Additional pointers/hints
First of all, make sure that the DocumentRoot is pointing to the right directory of your application;
The standard directory structure of CakePHP looks like this;
app
/Config
/Controllers
/Views
......
/webroot
lib
/Cale
plugins
The DocumentRoot should point to your `app/webroot' directory, which contains all 'public' files.
Change the paths/directories in your virtual host to that directory and restart Apache.
If you're still getting a 403 error, change the URL you're visiting in your browser to this;
http://mywebsite.com/index.php
If this does work, check if the .htaccess file is present in that directory and mod_rewrite is installed in your Apache.
According to the answer from "thaJetzah" (sorry, can't comment yet:) )
403 Forbidden is better than having the index of the folder, because now you can see the logs/sitename.com-error.log log and hopefully it tells you, why it gives 403.
Just to make sure: The index.php is in the folder "C:/sites/sitename"?
If you can't isolate the error like this, it would be great to post here the output of the error.log when you try to access the page and it gives you 403.
Check this If you are running Ubuntu.

Why does my virtual host XAMPP not be able to display the php file?

I am trying to set up a virtual host so that I can run my .php file from Eclipse as a web page.
I follow the instructions from this discussion:
Make XAMPP/Apache serve file outside of htdocs
Scroll down to virtual hosts and the instruction is basically
<VirtualHost *:80>
ServerAdmin webmaster#dummy-host2.example.com
DocumentRoot "/Users/Oky/Documents/eclipse/firstEclipseProject/"
ServerName firstEclipseProject.localhost
ErrorLog "/Users/Oky/Documents/eclipse/firstEclipseProject/logs/error_log"
<Directory /Users/Oky/Documents/eclipse/firstEclipseProject/>
Order allow,deny
Allow from all
</Directory>
CustomLog "logs/dummy-host2.example.com-access_log" common
</VirtualHost>
The document is at /Application/XAMPP/etc/extra/httpd-vhosts.conf
Then I change the hosts file at /private/etc/hosts and at the bottom, I added
127.0.0.1 firstEclipseProject.localhost #firstEclipseProject
So, I think I am doing it right up to this point because when I fire my browser and point to firsteclipseproject.localhost, it redirects me to
firsteclipseproject.localhost/XAMPP/
which is the main XAMPP web page. It does not return an object/page not found which means the redirecting is somewhat working.
So, in /Users/Oky/Documents/eclipse/firstEclipseProject/
I created a php file called HelloWorld.php but when I point to firsteclipseproject.localhost/HelloWorld.php, it says object not found! I also tried firsteclipseproject.localhost/XAMPP/HelloWorld.php and it fails.
Any help is appreciated! Thanks!!!
I would suggest you leave the root directory the way it is and instead setup an Alias to your eclipse directory.
Did you restart apache after making config changes?

Categories