Cant see or access Laravel's public folder - php

On Fedora 20 I created a folder named test then installed Laravel via composer create-project laravel/laravel into it. It ran successfully and now I try to view it in FireFox in the following URL:
http://localhost/~username/test/laravel/public/
But it throws the following error:
Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at root#localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
If I go to the parent folder, I can see that everything is there except the public folder. However if I ls in the terminal I can see that the folder is right over there. There is no problem with other PHP scripts only with this project. I tried to play with folder permission but no success. Why can't I see the folder in the browser and why does it throws an Error 500 when I try to access it?

Debugging
After I looked at /var/log/httpd/error_log I saw the following in the last line:
[Tue May 20 09:37:21.874443 2014] [core:alert] [pid 2897] [client ::1:55498]
/home/username/public_html/test/laravel/public/.htaccess:
Options not allowed here, referer: http://localhost/~username/test/
Make things work
So in my public folder I renamed the .htaccess file to .htaccess2 and now it works. Of course now I need to write index.php after public/ in the URL but at least it works. This also solved the invisible folder error, so if I go to the project root (the parent folder of public) in the browser it lists the public folder too.
Try to fix it
According to this answer configurations in the httpd.conf file can be overwritten by other extra files. You should search these files for a line containing AllowOverride like AllowOverride AuthConfig FileInfo and replace it with AllowOverride All.

Related

Apache Windows 10 ,404 Not Found Error (Wamp)

I've installed php, mysql, apache with WAMP for windows 10. When I go to http://localhost there is not any problem, the appropriate page is shown. The server is up and running, but when I try to open http://localhost/test.php it gives me 404 not found error. By the way I've put the index.html and test.php into wamp64/bin/apache/apache2.4.46/htdocs. The server can access neither index.html in that directory nor test.php. Your help is welcome.
Like #Selim Achour said I looked to the error logs and I found that apache server wasp/ searching the test.php in a folder called wamp/www/test.php. When I move the test.php from htdocs/test.php to www/test.php it works perfectly. I was following instructions from a book that I'd been reading. In that book's instructions, it is clearly stated that you should move test.php into htdocs. That was what got me confused. Thank you all for your effort.
The error: Sat Sep 26 13:14:03.134587 2020] [php7:error] [pid 8220:tid 1204] [client ::1:6466] script 'C:/wamp64/www/test.php' not found or unable to stat
WAMPServer's DocumentRoot folder is C:\wamp64\www BUT You should NEVER place your scripts into that folder!!!
Make a subfolder and use that i.e. C:\wamp\www\test1 put your test.php in there and run using locahost/test1/test.php
Better still create a Virtual Host for all your test areas and development site folders. See THE NEED for VIRTUAL HOSTS and then WAMPServer 3 Create a Virtual Host, the easy way

PHP can't write to error log - permission denied

In my first PHP script in many years, I'm trying to log an error:
error_log("my error message", 3, $error_log);
I'm getting an error in the general Apache error log:
PHP Warning: error_log(/var/log/apache2/my_php_errors.log): failed to open stream: Permission denied in /var/www/html/blahblah/my_script.php on line 88
This is what I've checked and tried:
Created $error_log with the same ownership (root.adm) and permissions (640) as the Apache error log.
Changed the owner to www-data, which is the user PHP is running as.
log_errors is On.
open_basedir is not set.
Using PHP 5.5.x, so safe mode does not exist.
What am I missing?
Edit: It's able to write to the general Apache error log. The mystery is why it can't write to another file in the same directory with the same ownership and permissions.
Edit 2: Another developer told me that this works on his WAMP, so it's something specific to my LAMP stack or config.
I had the same problem.
https://serverfault.com/questions/831444/php-error-log-per-vhost/831666#831666
touch /path/to/php_error.log
chown www-data:www-data php_error.log
chmod 755 php_error.log
thanks for leading me to the answer!
TL;DR: check that all the ancestor directories allow reads/lists by the web server.
On my system, my equivalent of /var/log/apache2/my_php_errors.log was giving this same error. I eventually did an ls -ld at every level of the path (/, /var/, /var/log/, /var/log/apache2/, /var/log/apache2/my_php_errors.log).
Four of those had permissions that made them readable by the web server. One of them, /var/log/apache2/ did not. When I moved my file out of the apache2 directory, everything started working. E.g. /var/log/php/ and set appropriate permissions/ownership (e.g. 750 by www-data.adm) on the new directory.
prompt> ls -ld /var/log/php/
drwxr-x--- 2 www-data adm 4096 Nov 1 13:31 /var/log/php/
You could also change the permissions on /var/log/apache2/, but that seems like a security/privacy issue. It's safer to make a new directory and leave the existing structure as is.
The reason why the permissions have to change is that it is no longer using some version of syslog to publish to the log files. The syslog variants run as root and accept messages from non-root. But in my case, I was specifying the file from the web server, which made the permissions wrong.
There is a fix that uses syslog so that it could keep the same ownership. I did not try to make that work, as this is for a test server.
This may not have been the problem that you were having, but I'm pretty sure that I was using the default permissions for /var/log/apache2/. So it's quite possible that it was the problem. And even if it wasn't, this is one of the places I was searching for troubleshooting advice. So next time something like this happens to me, I'll have a reminder of what to check.

Forbidden Error in Apache after extracting files

My dedicated server has Debian wheezy installed along with Apache2 php and mysql. ISPConfig3 is installed as the control panel.
After creating a site under ISPConfig and a shell user account with it I uploaded the tar file into the web directory and extracted the files.
The default ispconfig index.html file would display how ever after the extraction the index.php is not getting picked up and after deleting the default index.php i get the error message
Forbidden
You don't have permission to access / on this server.
Additionally, a 403 Forbidden error was encountered while trying to use an ErrorDocument to handle the request.
I tried going directly to www.domain.com/index.php and that doesnt work too.
Do I have to modify anything in apache? Any help would be appreciated.
That error is telling you the server can't read the file (or files) specified in your DirectoryIndex directive, and is trying to display a 403 (security) error document instead, which is doesn't have permission to read either.
You need to check what user your httpd daemon is running as, and make sure that user had at least read permissions to all the files in your DocumentRoot. The best way to do this is to ensure that user is the owner of the files.
On a Redhat/CentOS system, httpd runs as the user "apache"
chown -R apache:apache /var/www/html

Laravel from localhost to server error

My laravel 4 project was created on localhost. Now i am trying to put it on the server (shared hosting) but i am running in to an error. First let me explain how i uploaded my laravel project.
mydomain.nl
mydomain.nl--public_html
mydomain.nl--public_html--dev
mydomain.nl--public_html--packages
mydomain.nl--public_html--index.php
mydomain.nl--public_html--.htacces
mydomain.nl--public_html--all other contents form public laravel folders
mydomain.nl--project
mydomain.nl--project--bootstrap
mydomain.nl--project--vendor
mydomain.nl--project--app
mydomain.nl--project--all other folders and files wich were not in laravel public folder
Then i changed my mydomain.nl/project/bootstrap/paths.php to:
'public' => __DIR__.'/../../public_html',
And my mydomain.nl/public_html/index.php to
require __DIR__.'/../project/bootstrap/autoload.php';
$app = require_once __DIR__.'/../project/bootstrap/start.php';
If i go to my domain i get the following error
Error in exception handler: The stream or file "/hostingvariables/project/app/storage/logs/laravel.log" could not be opened: fopen(/hostingvariables/project/app/storage/logs/laravel.log) [function.fopen]: failed to open stream: Permission denied in /hostingvariables/project/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:77
I tryd everyting i could imagine but i can not solve this error, if someone could help me solve this error that would be great?
The error tells you that you dont have write access to
/hostingvariables/project/app/storage/logs/laravel.log
it says
Permission denied
So if you can chmod it to 775, or contact your host if it a shared solution where they control write access
I like this method best. Instead of changing folder permissions, set Apache to run as you.
In terminal type id to get uid=123(Myname).
Open /etc/apache2/httpd.conf and edit it to use your username.
<IfModule unixd_module>
User Myname
Group staff
</IfModule>
Back to terminal: sudo apachectl restart

When creating virtual-host, apache would work only with /var/www/html/ directory

I just moved from WAMP to LAMP, and can't figure out this problem that I am facing.
Whenever I create new vhost which is not in this directory /var/www/html/ i get a 403 forbidden message. (Permission are the same and there is an index file)
It seems to me that somewhere in Linux you specify a list of directories and apache works explicitly with those ones.
I use Apache 2.4.6.
I appreciate your help,
After checking the error log(vhost), I found this error message "search permissions are missing on a component of the path".
Meaning that one of the parent directories from where the vhost was located didn't not have search (+x) permission for the apache user.

Categories