MRatWork Forum by Mustafa Ramadhan

Sawo Project - Kloxo-MR Discussions => Kloxo-MR Technical Helps => Topic started by: nmpribeiro on 2014-07-02, 13:52:46

Title: Testing Kloxo-mr 6.5.1b on a VM
Post by: nmpribeiro on 2014-07-02, 13:52:46
Hi all,

I'm testing kloxo 6.5.1b on a VM (need to be able to debug that php-fpm issue with sabredav)

Dummy domain is now working for me in http://IP/~admin/

Need guidance...
Thanks!
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: nmpribeiro on 2014-07-02, 14:27:40
Tryed to switch from apache to nginx and back to apache... /usr/sbin/httpd.event: No such file or directory.

yeah sure... lost internet while moving from nginx to apache...
FIxed..


But the problem pressists:
You don't have permission to access /~admin/ on this server.


After assgning a default domain (for admin), now it serves me a white page with this:
"No input file specified. "
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: nmpribeiro on 2014-07-03, 14:18:21
[Wed Jul 02 21:01:19 2014] [error] [client 192.168.56.1] FastCGI: server "/home/kloxo/httpd/default/default.0fake" stderr: Unable to open primary script: /home/admin/public_html/index.php (Operation not permitted)

Strange...
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: MRatWork on 2014-07-03, 14:28:13
There are the code inside website to refer to /home/admin/public_html/index.php instead /home/admin/<domain>/index.php.

Try change it.
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: nmpribeiro on 2014-07-03, 14:33:55
Thank you MR!

Well, now it's ready to experiment in a VM :)
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: nmpribeiro on 2014-07-03, 14:49:58
Sorry, but this is something else:

[Wed Jul 02 21:32:10 2014] [error] [client 192.168.56.1] FastCGI: server "/home/kloxo/httpd/default/default.0fake" stderr: Unable to open primary script: /home/admin/public_html/test/index.php (Operation not permitted)

Cause I can access public_html/index.php, however, test and everythign else I make I cannot.

ls -la:
drwxr-xr-x  6 admin apache 4096 Jul  2 21:29 .
drwxr-x--x  5 admin apache 4096 Jul  2 21:18 ..
drwxr-xr-x  2 admin admin  4096 Jul  2 21:17 cgi-bin
drwxr-xr-x  2 admin admin  4096 Aug 23  2013 images
-rw-r--r--  1 admin admin  2240 Jul  2 21:17 index.html
drwxr-xr-x  2 admin admin  4096 Jul  2 21:29 test

and in test folder:
drwxr-xr-x 2 admin admin  4096 Jul  2 21:29 .
drwxr-xr-x 6 admin apache 4096 Jul  2 21:29 ..
-rw-r--r-- 1 admin admin    31 Jul  2 21:29 index.php

and yes, public_html points to those dir I "ls -la" before:

[root@centos-test admin]# ls -la
total 36
drwxr-x--x   5 admin apache 4096 Jul  2 21:18 .
drwxr-xr-x. 23 root  root   4096 Jul  2 08:55 ..
-rw-r--r--   1 admin admin    18 Jul 18  2013 .bash_logout
-rw-r--r--   1 admin admin   176 Jul 18  2013 .bash_profile
-rw-r--r--   1 admin admin   124 Jul 18  2013 .bashrc
drwxr-xr-x   2 admin apache 4096 Jul  2 09:30 kloxoscript
drwxr-xr-x   5 admin admin  4096 Jul  2 08:54 Maildir
lrwxrwxrwx   1 root  root     27 Jul  2 21:18 public_html -> /home/admin/template.local/
-rw-r--r--   1 admin admin    11 Mar 10 22:37 .qmail
drwxr-xr-x   6 admin apache 4096 Jul  2 21:29 template.local

?
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: nmpribeiro on 2014-07-03, 14:55:58
I see... html is accessed, while php throws the error...

I guess my php installation is messed up still
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: MRatWork on 2014-07-03, 15:03:58
FYI, '/home/admin/public_html/' is symlink of the first domain or other domain where you set as 'domain default'.

In your server, '/home/admin/public_html/' is symlink of '/home/admin/template.local/'
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: nmpribeiro on 2014-07-03, 15:08:36
Yes, I can access .html files, not php... and if I switch to mod_php_itk, then php works. But perhaps would be good to have some sort of way to reinstal a selected php with a certain type of fpm (and really replace contents if there are, so we could have almost a clean install everytime we switch these on or off).

Having mixed results while doing so from webserver config UI.
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: nmpribeiro on 2014-07-03, 16:49:25

I wanted to debug an app with php-fpm, however, with this setup (clean install from 6.5.1b as for 3 Jan 14):

[root@centos-test owncloud]# sh /script/sysinfo

A. Kloxo-MR: 6.5.1.b-2014063001

B. OS: CentOS release 6.5 (Final) x86_64

C. Apps:
   1. MySQL: mysql55-5.5.38-1.ius.el6.x86_64
   2. PHP: php54-5.4.29-3.ius.el6.x86_64
   3. Httpd: httpd-2.2.27-1.mr.e6.x86_64
   4. Lighttpd: --uninstalled--
   5. Hiawatha: hiawatha-9.6-2.mr.el6.x86_64
   6. Nginx: --uninstalled--
   7. Cache: --uninstalled--
   8. Dns: bind-9.8.2-0.23.rc1.el6_5.1.x86_64
   9. Qmail: qmail-toaster-1.03-1.3.38.mr.el6.x86_64
      - with: courier-imap-toaster-4.1.2-1.3.16.mr.el6.x86_64

D. Php-type (for Httpd/proxy): php-fpm_event

E. Memory:
                total       used       free     shared    buffers     cached
   Mem:           996        702        293          0         78        395
   -/+ buffers/cache:        228        767
   Swap:          815          3        812


I am receiving "No input file specified. " from  " http://192.168.56.103/~admin/owncloud/ "
If I change to mod_php_itk, then all works fine, but all the other Php-type seam to break the php serving from the server.

------- END OF GENERAL PURPOSE TESTING, BEGINING OF PHP-FPM and OwnCloud Case Scenario Test -------

All with this error: from httpd/error_log:

[Wed Jul 02 23:29:08 2014] [error] [client 192.168.56.1] FastCGI: server "/home/kloxo/httpd/default/default.0fake" stderr: Unable to open primary script: /home/admin/public_html/owncloud/index.php (Operation not permitted)

Logs from php-fpm/* show nothing.

Please, beare in mind that I really want to make a test scenario only "php" with type "php-fpm" and owncloud. Not with mod_php_itk which works well.
How can I put php-fpm to spit some errors here?

Thanks in advance
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: nmpribeiro on 2014-07-03, 16:52:31
Making php  Display Errors and Log Errors, in Config php outputs a new but interesting string:

"Access denied. "

httpd/error_log now has more details:

[Wed Jul 02 23:39:27 2014] [error] [client 192.168.56.1] FastCGI: server "/home/kloxo/httpd/default/default.0fake" stderr: PHP message: PHP Warning:  Unknown: open_basedir restriction in effect. File(/home/admin/template.local/owncloud/status.php) is not within the allowed path(s): (/home/kloxo/httpd/:/tmp/:/usr/share/pear/:/var/lib/php/$
[Wed Jul 02 23:39:27 2014] [error] [client 192.168.56.1] FastCGI: server "/home/kloxo/httpd/default/default.0fake" stderr: PHP message: PHP Warning:  Unknown: failed to open stream: Operation not permitted in Unknown on line 0
[Wed Jul 02 23:39:27 2014] [error] [client 192.168.56.1] FastCGI: server "/home/kloxo/httpd/default/default.0fake" stderr: Unable to open primary script: /home/admin/public_html/owncloud/status.php (Permission denied)


Mustafa, this one is for you... default domain obeys "open_basedir" restrictions that do not encompass the domain's dir in user folder... we need to fix this...
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: nmpribeiro on 2014-07-03, 17:05:34
After going to http://forum.mratwork.com/kloxo-mr-technical-helps/php-detection-program-can-not-get-the-memory-and-cpu-information/ reply #1 from Mustafa I was able to get this working again:


nano /etc/php-fpm.d/default.conf

and added ":/home/admin" to open_basedir restriction


Obviously, be carefull when you add stuff, since it's the wrong user. Remember to chmod -R apache:apache all once and a while. Or else, Mustafa... there must be some way to assign these as vars that could be read from php-fpm to be able to execute chrooted but also able to use and exec admin's files.

Guess it's a bug in the dev 6.5.1b
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: MRatWork on 2014-07-03, 17:10:41
Default open_basedir for admin is '/home/admin/:/tmp/:/usr/share/pear/:/var/lib/php/session/:/home/kloxo/httpd/script/:/home/kloxo/httpd/disable/' where declare inside /etc/php-fpm.d/admin.conf.

So, possible your php code try to access to other then above path. That it.
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: MRatWork on 2014-07-03, 17:12:42
No reason to add '/home/admin' in default.conf, except your code need it. That it.
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: nmpribeiro on 2014-07-03, 19:18:14
I see what you mean. But that means http://IP/~admin/ is being processed with php-fpm chrooted from admin user? Might have some misconfiguration in my config then. Because my php code is only trying to access from /home/admin/template.local/owncloud/index.php other scripts and files inside /home/admin/template.local/owncloud/* not outside this dir.

When I have time, I'll generate a phpinfo() from there to check if we have "/home/admin/" in open_basedir, but I'm predicting I won't be able even to process the php file with <?php phpinfo(); ?> file itself, only html's, because I only have access to open_basedir directories that are in default.conf and nothing else. Since this domain doesn't resolve any IP (it's not mine), It's hard to access it other then http://IP/~admin/ to debug it.

I have no resources to test it further. But I can provide you the VM if you want (it's just a playground VM).
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: nmpribeiro on 2014-07-04, 14:20:12
Hi Mustafa,

Reproduced in a new clean machine, just installing kloxo-mr:

http://IP/~admin/ with an index.php only with these contents:
<?php
echo "Hello World";
?>

Outputs "Access denied. "
I'm pretty sure php is not allowing php execution in admin folder with default setup on "default domain" option (for those that just want to test kloxo-mr on a vm...

Kloxo 6.5.0.f-2014062701  here
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: nmpribeiro on 2014-07-07, 08:00:37
One last thing,

Needed mod_rewrite to work on IP/~admin/projectX/someUrlRewrite/, having projectX/index.php to rewrite from index.php?url=someUrlRewrite into projectX/someUrlRewrite

To do so, I needed to edit /etc/httpd/conf/httpd.conf and changed "AllowOverride None" to "AllowOverride All" in "<Directory />" tag.

Hum... not quite "out of the box"...
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: nmpribeiro on 2014-07-07, 13:34:56
Also:

from phpinfo(),
Environment
user: apache
home: /var/www

so... my advice is to backup /etc/php-fpm.d/default.conf and overwrite default.conf by admin.conf. Then IP/~admin/ will behave as if it was the actual domain on a production server.

*Disclamer: Use this only for test purpose, my lack of understanding must not be in no way liable for your "lack of understanding". Read what php and php-fpm are all about in the apropriate man pages please*
Title: Re: Testing Kloxo-mr 6.5.1b on a VM
Post by: MRatWork on 2014-07-07, 14:42:47
Try update to latest version where default with open_basedir to /home.