Let user XXX read error.log in Apache2 Debian - php

I have a VPS with last Debian installed.
I've apache2 and I use this vps to practicing with some friends.
By the way, I'm the only one with root ssh access, they have their own folders and accounts(ftp only), in /var/www/html/xxxxx/
The problem is: while they try new things and learn programming something, they need to see error.log of apache2, but they can't, and I need to check it for them and copy paste the errors.
Is there a way to let them see the error.log?
I tried these
Link the error.log to their folder (and obviously didn't worked)
Make a script that would copy the error.log to folders on file change. (But i'm not that skilled, and totally don't understand how to use something like: inotifywait).
PHP script that copy error.log and paste in a file in the folder (access denied.. and it is the expected behavior!!)
I'm pretty sure there is an easy solution I didn't thought of (like a php code to echo the error 500 content, this solution doesn't involve me directly, but I didn't find how to do)
Sorry for my english and if this question is stupid or already answered, I searched a lot.
Thanks

Apache is storing error logs in ${APACHE_LOG_DIR}/error.log (usually /var/log/apache2/error.log) which is accessible only by root user.
You can specify custom error log location per website in your vhost config
or .htaccess.
You should think about displaying errors instead of logging them at development stage.

Related

Symfony error 404 toolbar not found and subdirectories

After searching on Stackoverflow about this question, I read about different possible solutions and different references to different links. I am not a pro at working with Symfony, in fact, I am a total beginner and I am not really well aware of which file saves what kind of data etc. So to ask my question:
What should I do in order for my Symfony application to work fine?
I used Vagrant to SSH into my virtual Ubuntu system and this is an error log I found that actually keeps an error, however it is from january, meaning that this log does not log the error I am still experiencing. Does anyone know which error log I should look for so I can share it here and help you out identifying my problem by doing so?
[01:39 PM]-[vagrant#local]-[/var/log/nginx] B
B$ dir
_.access.log _.error.log.1 nxv_6hujsloyp5ug.error.log
access.log error.log.1 nxv_6hujsloyp5ug.error.log.1
_.access.log.1 nxv_6hujsloyp5ug.access.log project_access.log
_.error.log nxv_6hujsloyp5ug.access.log.1 project_access.log.1
error.log nxv_6hujsloyp5ug.access.log.2.gz project_error.log
[01:40 PM]-[vagrant#local]-[/var/log/nginx] B
B$ tail -1 nxv_6hujsloyp5ug.error.log.1
2016/01/29 13:58:06 [error] 16933#0: *40 rewrite or internal redirection cycle while internally redirecting to "/index.php", client: 192.168.56.1, server: barry.dev, request: "GET /my_project_name/web/app_dev.php/ HTTP/1.1", host: "www.awesome.dev"
[01:40 PM]-[vagrant#local]-[/var/log/nginx] B
B$
I also read that a possible solution is editing the .htacces file, however I have no clue which one that should be then. I have seen one in the web directory, edited it and nothing happened, same goes for src directory and app directory.
Another possible solution is to set AcceptPathInfo "On". But then again I do not know where to find such, should be the virtual host accodring to one of the answers on this page.
And for those wondering, as you can see in the error log, I am using Nginx.
my_project_name/web/app_dev.php returns the toolbar error.
my_project_name/web/app_dev.php/controllername returns 404.
Edit: By making a new virtual machine and repeating the whole Symfony installation process and using Apache instead of Nginx somehow fixed the problem for me.
You will need to edit the .htaccess file in the web directory. All files that are accessible through a browser are stored in the web directory. The other .htaccess files are merely a 'defence in depth' strategy that prevents directories being accidentally exposed.
This page covers the basic setup for Symfony2 with Apache2:
http://symfony.com/doc/current/cookbook/configuration/web_server_configuration.html

phpBB 500 Internal Server Error and no log outputs

Good morning. I'm having a major issue with my phpBB installation.
I've transfered it to my computer to develop some plugins, so i'm running it on localhost, but, i've created a vHost with the exact same domain he is running online, so, i don't need to change the cookies configuration, and the database connection information is correct already.
Regard all of that, i'm getting a 500 internal server error, which displays no error on the screen nor the logs from apache and php.
I have error reporting on php as E_ALL also. What could be possible causing this, and what the solution might be?
Thanks in advance, Jorge Ferrari.
If you're getting nothing in the Apache / PHP error logs, then it's more likely to be a server configuration issue. I would suspect the problem is in a file called .htaccess in the phpBB folder. It can be used to customize the configuration in various ways, including things like setting up redirects and URL rewriting.
If the htaccess file tries to use an Apache feature which isn't available on the server, then it can generate a 500 error. You can test this by temporarily removing the file, and seeing if the website works at all (albeit possibly with some glitches).
If you've confirmed that it's the source of the problem, then ideally you'll need to enable the missing feature in the server's configuration (or possibly update the Apache installation). Alternatively, you can delete or comment-out the problematic bits of the htaccess file.
Either way, it sounds more like a webserver admin issue than programming. You might have more luck asking on the phpBB forums, or on a different Stack Exchange Q&A site (possibly Server Fault?).
Check whether you have Rewrite module enabled?(most of the this will be the reason)
In httpd.conf and uncomment
LoadModule rewrite_module modules/mod_rewrite.so
If you try to use module which is not loaded you will get 500 internal server error.
Check your modules used in .htaccess file and check httpd.conf whether used modules are loaded

Trying to Include Files outside of Document Root (Plesk 10)

Okay, I've tried everything, this is by far the best place it seems, I want to make Document Root here httpdocs/[folder]/html and I have php include files that I want to go above the root (require '../[folder]/file.php'] but not be able to access further than /var/www/vhosts/example.com/httpdocs. I know I'm being limited by open_basedir because the value is still httpdocs/[folder]/html in phpinfo() but for the life of me I can't change that local value!
This is what I've tried so far:
I've seen this - How to include file outside document root? - and created a 'vhost.conf' that is stil sitting in the conf directory, reconfigured the file, restarted apache...nothing. It's a good post but it seems a little out of date.
I edited php.ini itself to open_basedir = '/var/www/vhosts/example.com/httpdocs, uploaded it back up to where it was, reconfigured, restarted - nothing
I pulled out 'httpd.conf' edited it by adding the same lines from the other conf file,(vhost.conf), put it back in - nothing, I then tried to do what godaddy says here - http://help.godaddy.com/article/1616 and added the line php_admin_value open_basedir none' to 'httpd.conf - with no luck either.
It is now 0435 and I can barely keep my eyes open - this site is suppose to launch tomorrow at 2000! Thanks in advance to anyone who is willing/able to read and/or help.
Update: Thanks for a quick response, here are the best answers I can give you:
Does it give you an error?
Yes, I get a server error and through my server error log, specifically:
PHP Warning: require() [function.require]: open_basedir restriction in effect. File(/var/www/vhosts/[example.com]/httpdocs/[folder]/[folder where secure php files exist]/[file.php]) is not within the allowed path(s):
So I'm 99.99% sure its because of the open_basedir restriction.
Are you sure that your webserver is set as the owner of vhosts/ ?
I'm pretty sure, I'm kinda new to controlling servers and I don't really know what that means exactly but I have a virtual dedicated server through Godaddy, running Parallels Plesk v10.3.1, I did the above file moving going through Shell SSH.
In Plesk, I can change the 'Document root' to anything below /var/www/vhosts/example.com and Plesk will change the 'open_basedir' to anything I set. For example, If I set the document root to 'httpdocs' in Plesk then 'open_basedir' is changed to the same folder and everything works fine. The problem is I don't want public access to everything in /httpdocs/[folder]
My goal is I want to change 'document root' to /httpdocs/[folder]/html and 'open_basedir to /httpdocs but I can't change that local value in open_basedir for some reason. I want to do this for security purposes so people can only directly access the non important php files, but php itself I want to give more access to folders.
Are you trying to include using relative or absolute paths?
My paths in the php file that I'm trying to include/require to files above 'document root' looks exactly like this format:
require '../[folder where secure php files exist]/file.php';
If I'm understanding you correctly, I'm not using the entire path of the server.
ANSWER: (This was changed to the answer):
Apparently, in Plesk 10, Plesk's program sets whatever the 'document root' path will be, to the 'open_basedir' BUT there is no user friendly way to change 'open_basedir' in Plesk 10!!!
So instead it is a little bit of a hack, you have to first go here:
/usr/local/psa/admin/conf/templates/default/service/php.php
Then change both of these lines in the file, (line 11 and 29):
echo "php_admin_value open_basedir {$OPT['dir']}/:/tmp/\n";
to this:
echo "php_admin_value open_basedir /var/www/vhosts/[your.domain]/httpdocs/:/tmp/\n";
or to wherever you want the restriction to stop.
Then make sure your run these lines is SSH:
/usr/local/psa/admin/sbin/httpdmng --reconfigure-all
/etc/init.d/httpd stop
/etc/init.d/httpd start
But I'm having a new problem now. The 'document root' is pointing to the correct folder:
/var/www/vhosts/[my.domain]/httpdocs/[folder]/html
without any error however when the server gets to a:
require '../[folder]/[file.php]';
It skips through it like its not even there! Not giving me an error msg or anything. It's also skipping all my embedded css files, js files, images, videos...its not going to any of the directories! I have a feeling it's a 'php.ini' setting or something weird that Plesk is doing.
Solved: The last issue was because I never worked with accessing files above the root. PHP is allowed to go above the root but you can't do this:
src="../img/imagefile.jpg"
in HTML.
So after restructuring all my site files my website is now up and running! Thanks to all that helped, hopefully someone won't have to do that again. Also, I saw a post where Plesk is updating this because it is a big issue. Someone who works for Parallels said, http://forum.parallels.com/showthread.php?t=113236 this will be an option in the next version, so until then it's hack time!!

Apache doesn't execute my copied PHP files, but testing.php works

I've just installed LAMP on my Ubuntu 9.10 machine, and everything works fine except when I copy my PHP files from another computer.
The LAMP guides I've followed also made me create a phpinfo() test file, which works, but when I try to type in e.g. index.php absolutely nothing happens - just a blank page in FireFox. :(
The files are in the exact same directory.
I'm thinking it's probably something with permissions and so on, but since I'm new to both PHP and Ubuntu, I'm kind of lost. It's like I can't create a PHP file with my file browser, but only by using the terminal - like when I created the testing.php from the LAMP guide.
Whaddayaknow... I made an error, tried to:
echo "Hello" world
which, even though I'm a PHP noob, I clearly know is wrong.
I think I'll have to figure out how to enable some sort of error reporting, a blank page is clearly not good enough.
You mean you have a index.php (copied from another computer) and a test.php (edited by hand, with a call to phpinfo()) in the same apache directory, the second works from your browser and the first doesnt ?
That can be a permission issue, or some compilation error in your php.
About permissions, for files should be readable from the apache server (more precisely, form the user that runs the apache server). You can type chmod a+r index.php.
YOu can also check your apache error logs (location dependent on installation). In any case it's vital to know where the error logs are if your are developing a web site.

IN Wordpress, .php files within the theme folder do not run, but return 404 error

I'm on a VPS environment so I have root access, btw.
So take a look at these issues:
http://www.sonikastudios.com/wp-content/themes/sonikas/scripts/timthumb.php?src=/wp-content/uploads/tedleescreenshot1.jpg&w=100&h=100&zc=1&q=100
That returns a 404 error.
However when I move timthumb.php to the root of the site, it works.
I verified file/folder permissions, it's not the issue. Also, another PHP generated image that i use for Captcha, is doing the same thing...
So essentially it boils down to no .php files running from within folders. However this is not an issue otherwise because PHP scripts I have under /admin/ on other sites work fine.
So... what could cause this? Most forum articles I read lean towards a mod_security problem, but I don't even know where to start, as I'm not an apache expert.
As you have root access, try looking for what is happening in Apache logs. To follow latest request you can use tail.
Which version of Apache you are running? In my configuration of Apache 2.2 you can follow error log in terminal by invoking:
tail -f /var/log/httpd/error_log
It seems that default configuration of Apache 2.2 has error log in /usr/local/apache2/logs/error_log, so my configuration is not default.
If you do not have success with error log, try also looking for information in access log, default location at /usr/local/apache2/logs/access_log.
Same error can occur when the file it self is also writable. Make sure the file is 644 and NOT 666 !
Wordpress is probably using some mod_rewrite rules to send every request to its index.php. And there it’s analyzing the request and returning a 404 status code if one of its internals was requested.
This is a problem with your .htaccess file generated by WordPress. It redirects all requests for your site that aren't wp-admin/ or in your uploads directory to the index.php file for WordPress (the request handler that queries for posts, etc.)
In my case, the following PERMISSION changes solved the (Timthumb.php) issue:
The PHP script must be "644".
All of the parent directories must be "755"; Neither "775" nor "777".

Categories