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, 19: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, 15:53
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,751 Times in 2,581 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 7th November 2005, 00: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, 11:37
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,751 Times in 2,581 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, 18: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, 19:07
falko falko is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 41,701
Thanks: 1,900
Thanked 2,751 Times in 2,581 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 23rd December 2005, 17:09
newzen newzen is offline
Junior Member
 
Join Date: Dec 2005
Location: venezuela
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by falko
Can you give us the URL of your phpinfo.php script?

Might be a problem with PHP Safe Mode or register_globals, etc...
im traying to install OSCMAX ( similar OSCOMMERCE ) they have a install. when i try to run that escript, a have the follow message

FATAL ERROR: register_globals is disabled in php.ini, please enable it!

im running ispconfig under fedora core 4.

Iwas found all php.ini on my machine and change

registers_globals = on

and still without working

Would your maind do give me some help.

Really a have no idea and a very newbird in ispconfig and linux fedora core 4 too

thanks in advantage.
Reply With Quote
  #8  
Old 23rd December 2005, 17:11
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 37,015
Thanks: 840
Thanked 5,652 Times in 4,461 Posts
Default

have you restated apache after enabling register globals in php.ini?
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #9  
Old 23rd December 2005, 17:24
newzen newzen is offline
Junior Member
 
Join Date: Dec 2005
Location: venezuela
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by till
have you restated apache after enabling register globals in php.ini?
im restart the complete machine is that suficient?
Reply With Quote
  #10  
Old 23rd December 2005, 17:29
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 37,015
Thanks: 840
Thanked 5,652 Times in 4,461 Posts
Default

yes, restarting the machine restarts also the apache webserver.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
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 21:40
ISPConfig pop3 problem mphayesuk General 21 31st October 2005 11:53
Several minor issues dahljh Installation/Configuration 2 30th October 2005 23:22
Mail Configuration mphayesuk General 1 12th September 2005 14:16
fetchmail configuration lola Installation/Configuration 1 11th May 2005 11:57


All times are GMT +2. The time now is 16:43.


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