Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > General

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 5th November 2005, 18:51
senzapaura senzapaura is offline
Junior Member
 
Join Date: Nov 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default PHP/MySQL/Apache2/ISPConfig configuration issues?

A web site application I have been running on a Fedora 4 system using PHP-5 & MySQL-4 broke when I moved it to a Suse 10.0 system with the same versions of PHP & MySQL; I can no longer upload a file and move it to a known directory even though all permissions are set. i.e. (chmod 0777) the problem appears to be in the PHP configuration. The upload and copy does work if I keep everything in the phptmp directory. But, when I try to copy it to another directory (Linux permissions set for all) it will not work. I have compared the PHP settings from both systems by running phpinfo.php, but nothing really stands out as being very different. I was going to change one or two things, but when I looked at the php.ini files on the Suse system. The configuration is not the same as it should be based on the output using phpinfo.php. I am not sure how these configuration settings are being set? I found four different php.ini files, but one setting was turned off in all of them yet displayed as being on by phpinfo.php in the local settings column, very confusing. I am also running with ISPConfig on the Suse system. This is the only major difference from the Fedora system.

A related problem appears to be with the MySQL privileges. After I upload a file then I recreate a database table from the uploaded file. I have granted all privileges on the database in question to the MySQL user, but it will not properly perform a load data function. It truncates the table OK but does not reload the new version. I get some error message indicating the file needs to be in the database directory or must have read permissions for the database user. But since I am unable to copy the file to the proper directory or use the exec function, I am unable to fix this problem.

I also want to be able to run system commands from PHP using the exec function. Any help or ideas would be appreciated.

I am pretty sure all of these problems can be solved by properly configuring the PHP, but I have been unsuccessful in doing so. It may be because of ISPConfig?
Reply With Quote
Sponsored Links
  #2  
Old 6th November 2005, 14:53
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,743 Times in 2,577 Posts
Default

Can you give us the URL of your phpinfo.php script?

Might be a problem with PHP Safe Mode or register_globals, etc...
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #3  
Old 6th November 2005, 23:57
senzapaura senzapaura is offline
Junior Member
 
Join Date: Nov 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

http://www.amg01.info/systemapps/phpinfo.php

this is the URL. The local setting is getting changed, but I do not know how. All the .conf file have safe_mode off.

Thanks for looking at this.
Reply With Quote
  #4  
Old 7th November 2005, 10:37
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,743 Times in 2,577 Posts
Default

Ok, your php.ini is /etc/php5/apache2/php.ini.

There are two values that are different from the default settings:

open_basedir your setting: /var/www/web8/ default setting: no value

upload_tmp_dir your setting: /var/www/web8/phptmp/ default setting: no value

Change these settings and restart Apache afterwards.
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #5  
Old 7th November 2005, 17:46
senzapaura senzapaura is offline
Junior Member
 
Join Date: Nov 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for looking at this problem. Unfortunately these changes did not fix my problem. I may not have stated it correctly, although it does appear to be in the php.ini configuration files. I tired to shotgun this problem and frankly I have confused myself. Let me regroup. The application is designed to upload a tab delimited file, and then move the file to a known directory where it will be used to recreate a database table. In order to accomplish this I use the following code snippets (see example code). This code allowed me to upload the file to the phptmp directory, but not move it to another directory (my first problem, see error message 1). I tried changing permissions on the target directory, but it still did not work. Trying to isolate the problem I changed the code to copy to a known file name within the phptmp directory. This worked, but them MySQL would not use the file as input to a load data command because of permissions (see error message 2). Also this is not the solution I wanted, because it did not save the file in a designated directory. Finally, I needed to change permissions for MySQL to work and inform the client of the status by listing his uploaded directory. I need to use some system commands to accomplish this task. I have attached output from a working example to demonstrate what I am trying to accomplish.

Questions: Where is the php.ini changed to make the local column different than the default column? How does this occur?

Is there any other documentation on php.ini file except in the examples of the default?

Example Code (snippets)
// to upload the file
if (is_uploaded_file($_FILES['userfile']['tmp_name'])) {
if (!move_uploaded_file($_FILES['userfile']['tmp_name'], $myfile)) {
echo 'Problem: Could not move file to destination directory';
exit;
}
}
else {
echo $tab.$tab.'Problem: Possible file upload attack. Filename: ';
echo $_FILES['userfile']['name'];
exit;
}

//to create the database
$cmd = "chmod 0666 ".$myfile; // input file for database creation
exec($cmd);
echo "Loading ".$load.".txt<br />";
$mysql = db_nameconnect("Bacchus");
$query = "TRUNCATE ".$load;
$result = dbquery( $query, $mysql );
echo "myfile ".$myfile."<br />";
$query = "LOAD DATA INFILE '$myfile' INTO TABLE ".$load; // into database
$result = dbquery( $query, $mysql );
echo "Successfully loaded file in ".$myfile." <br />";
echo "to $load table in Bacchus database<br /><hr><br />";
mysql_close($mysql);

Error message 1.
Problem: Could not move file to destination directory
output file = /home/web8/uploads/auth.txt
input file = /var/www/web8/phptmp/php0mYQNW

Error message 2.
MYSQL error was: The file '/var/www/web8/phptmp/auth.txt' must be in the database directory or be readable by all

Example working output:
Uploading file...
Selected file is auth.txt
File uploaded successfully

Preview of directory contents:
________________________________________
-rw-r--r-- 1 apache apache 2275 Nov 3 17:59 auth.2005-11-03.06:08:40
-rw-r--r-- 1 apache apache 2275 Nov 3 18:08 auth.2005-11-07.10:18:45
-rw-r--r-- 1 apache apache 2275 Nov 7 10:18 auth.txt
-rw-r--r-- 1 apache apache 199519 Oct 23 11:52 inventory.2005-10-23.12:05:45
-rw-r--r-- 1 apache apache 176081 Oct 23 12:05 inventory.2005-10-23.12:09:43
-rw-r--r-- 1 apache apache 179385 Oct 23 17:29 inventory.txt
-rw-r--r-- 1 apache apache 217754 Oct 24 07:28 learnmore.2005-10-24.07:30:01
-rw-r--r-- 1 apache apache 217754 Oct 24 07:30 learnmore.2005-10-24.07:39:04
-rw-r--r-- 1 apache apache 217754 Oct 24 07:39 learnmore.zip
________________________________________
Installing file...
________________________________________

Loading auth.txt from myfile /uploads/bb/auth.txt
Successfully loaded file in /uploads/bb/auth.txt to auth table in Bacchus database
________________________________________
Reply With Quote
  #6  
Old 7th November 2005, 18:07
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,743 Times in 2,577 Posts
Default

Quote:
Originally Posted by senzapaura

Error message 1.
Problem: Could not move file to destination directory
output file = /home/web8/uploads/auth.txt
input file = /var/www/web8/phptmp/php0mYQNW
This error is definitely caused by the open_basedir setting. One question: did you enable PHP Safe Mode in ISPConfig for that web site? If so, disable it!
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #7  
Old 7th November 2005, 21:20
senzapaura senzapaura is offline
Junior Member
 
Join Date: Nov 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You are correct safe mode was on in ISPConfig for the web site. But if I turn it off, I can no longer get the site using the URL I was using previously i.e. www.amg01.info .I guess there is something else I must configure?
Reply With Quote
  #8  
Old 7th November 2005, 21:35
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,743 Times in 2,577 Posts
Default

Quote:
Originally Posted by senzapaura
But if I turn it off, I can no longer get the site using the URL I was using previously i.e. www.amg01.info .
I have no idea what's going on on your system...
__________________
Falko
--
Download the ISPConfig 3 Manual! | Check out the ISPConfig 3 Billing Module!

FB: http://www.facebook.com/howtoforge

nginx-Webhosting: Timme Hosting | Follow me on:
Reply With Quote
  #9  
Old 10th November 2005, 17:04
senzapaura senzapaura is offline
Junior Member
 
Join Date: Nov 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I hope you have not given up on me. It is a mater of survival for me. I am continuing to pursue this problem and maybe in the process can gain some insight on how apache and ISPConfig work. Would you mind reviewing this information and letting me know your thoughts.

It looks (to me) that ISPConfig changes this file (Vhosts_ispconfig.conf) and then restarts apache automatically, if you change something within the forms. Problem is nothing seems to do this in a consistent manner. On one occasion when I turned safe_mode off (manually), it actually worked. Well almost, the write to /home/web1/uploads did not work, but I think that was because I had forgotten to set the open_base_dir value correctly. unfortunately when I did this it stopped working again. On another occasion when I changed the safe_mode setting on a form, the php settings were cleared from this file (Vhosts_ispconfig.conf). One thing (of many) I do not understand is why does turning safe_mode on or off affect apache from displaying a screen. When it is not working apache sends back an html file with an empty head and body area. I cannot even find a template like this on the system.

I know people always blame a new piece of software for any problem they are having when in reality it is operator error. I am resisting this urge, but I cannot help but wonder from the erratic behavior I have experienced from making some simple straight forward one line changes to this file that possibly apache2 has a problem? It also appears that if you make a change to the php.ini file like changing the open_base_dir value as you indicated previously and restart, ISPConfig will change it the first time in this file (Vhosts_ispconfig.conf), but ignores any subsequent changes, which is probably correct since once this virtual hosts settings are made they should not be changed globally, because they could be different for each virtual host. But that means the only way to change it (in this example open_base_dir) would be manually, since I do not see any form field for this setting this value.

In addition if you would review the warning messages (at the end of this message) I get when restarting apache, maybe this will provide a hint to where I made my mistake.

###################################
#
# ISPConfig vHost Configuration File
# Version 1.0
#
###################################
#
NameVirtualHost 192.168.3.170:80
#
#
######################################
# Vhost: www.amg01.info:80
######################################
#
#
<VirtualHost 192.168.3.170:80>
ServerName www.amg01.info:80
ServerAdmin webmaster@amg01.info
DocumentRoot /var/www/web1/web
ServerAlias www.amg01.info
DirectoryIndex index.html index.htm index.php index.php5 index.php4 index.php3 index.shtml index.cgi ind
ex.pl index.jsp Default.htm default.htm
ScriptAlias /cgi-bin/ /var/www/web1/cgi-bin/
AddHandler cgi-script .cgi
AddHandler cgi-script .pl
ErrorLog /var/www/web1/log/error.log
AddType application/x-httpd-php .php .php3 .php4 .php5
<Files *.php>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
<Files *.php3>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
<Files *.php4>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
<Files *.php5>
SetOutputFilter PHP
SetInputFilter PHP
</Files>
php_admin_flag safe_mode Off
php_admin_value open_base_dir /home/web1/uploads/
php_admin_value file_uploads 1
php_admin_value upload_tmp_dir /var/www/web1/phptmp/
php_admin_value session.save_path /var/www/web1/phptmp/
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
Alias /error/ "/var/www/web1/web/error/"
ErrorDocument 400 /error/invalidSyntax.html
ErrorDocument 401 /error/authorizationRequired.html
ErrorDocument 403 /error/forbidden.html
ErrorDocument 404 /error/fileNotFound.html
ErrorDocument 405 /error/methodNotAllowed.html
ErrorDocument 500 /error/internalServerError.html
ErrorDocument 503 /error/overloaded.html
AliasMatch ^/~([^/]+)(/(.*))? /var/www/web1/user/$1/web/$3
AliasMatch ^/users/([^/]+)(/(.*))? /var/www/web1/user/$1/web/$3
</VirtualHost>
#
#
#

Another hint may come from these messages I get when restarting apache:

amgsrv1:/etc/apache2/vhosts # /etc/init.d/apache2 restart
[Thu Nov 10 09:27:43 2005] [warn] NameVirtualHost 192.168.3.170:80 has no VirtualHosts
[Thu Nov 10 09:27:43 2005] [warn] NameVirtualHost 192.168.3.170:80 has no VirtualHosts
Syntax OK
Shutting down httpd2 (waiting for all children to terminate) done
Starting httpd2 (prefork) [Thu Nov 10 09:27:45 2005] [warn] NameVirtualHost 192.168.3.170:80 has no VirtualHosts
[Thu Nov 10 09:27:45 2005] [warn] NameVirtualHost 192.168.3.170:80 has no VirtualHosts
done
amgsrv1:/etc/apache2/vhosts #
Reply With Quote
  #10  
Old 10th November 2005, 20:28
senzapaura senzapaura is offline
Junior Member
 
Join Date: Nov 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
 
Default

My thanks to Falko. It was the open_base_dir value, not the safe_mode setting. Apparently what I did not understand was the value of the open_base_dir must be in the pathe of the web site. example web10 /var/www/web10/... whatever.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loading configuration file lance Kernel Questions 2 28th February 2007 20:40
ISPConfig pop3 problem mphayesuk General 21 31st October 2005 10:53
Several minor issues dahljh Installation/Configuration 2 30th October 2005 22:22
Mail Configuration mphayesuk General 1 12th September 2005 13:16
fetchmail configuration lola Installation/Configuration 1 11th May 2005 10:57


All times are GMT +2. The time now is 22:32.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.