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?
Can you give us the URL of your phpinfo.php script? Might be a problem with PHP Safe Mode or register_globals, etc...
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.
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.
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 ________________________________________
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!
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?
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 host’s 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 [email protected] 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 #
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.
include path and auto prepend when i edit the vhost entry for one of my sites and add php_admin_value include_path .:./include:/home/www/web5/web/include:/home/www/web5/shared php_admin_value auto_prepend_file prepend.php apache won't start. i also tried .htaccess but still got the 500 server error when i enabled allowOverride All any ideas?
First, don't change your Vhosts_ispconfig.conf file manually! Your changes will be overwritten by ISPConfig! What does Code: httpd -t show when you put in these directives?
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.
im restart the machine, still without working, then i do the folowing [root@dc9f8fe88 ~]# service httpd restart Parando httpd: [ OK ] Iniciando httpd: [Fri Dec 23 11:43:24 2005] [warn] NameVirtualHost 201.248.254.136:80 has no VirtualHosts (98)Address already in use: make_sock: could not bind to address [::]:443 no listening sockets available, shutting down Unable to open logs [FALLÓ] [root@dc9f8fe88 ~]# service httpd restart Parando httpd: [FALLÓ] Iniciando httpd: [Fri Dec 23 11:44:34 2005] [warn] NameVirtualHost 201.248.254.136:80 has no VirtualHosts i dont now how to repair that! any idea? Thanks
did you found the solution for install oscmax? if, please post the step to do or step to configure all for make that work. thanks a lot.