Koozali.org: home of the SME Server

PHP.INI location and how to edit?

WACOMalt

PHP.INI location and how to edit?
« on: March 29, 2006, 03:52:39 AM »
ok, so I have this problem on my server, no one can upload avatars to my phpBB forum. the folders are chmodded correctly and everything.

now many people have this problem, and finnaly someone found a workaround. Here is what they said:

Quote
areacode212 wrote:
I had this problem the other day, and came across this solution on another site. Basically, I had to add something for "upload_tmp_dir" in php.ini
Quote:
Solution is on the surface (as always, though).

1. Create folder anywhere on server’s local drive. For example, “C:\Inetpub\TempUploads”
2. Set to your server’s internet user account ( IUSR_<computer name> by default) full NTFS rights to this folder.
3. Edit your php.ini to contain these directives:
Code:
file_uploads = On
upload_tmp_dir = "C:\Inetpub\TempUploads\"

4. Remember to set to your server’s internet user account full NTFS rights to folder, which you set in forum configuration at Administration > General Admin > Configuration > Avatar Settings > Avatar Storage Path.
5. Have fun.

Problem cause: This PHP issue. PHP config says that “Temporary directory for HTTP uploaded files will use system default if not specified”, but it couldn’t because Internet user account NEVER has access to server’s (Win2k/XP/2k3) TEMP folder.

After I did this, I restarted Apache, and avatar uploading worked.


now, hopefully that will work for me, but can anyone tell me, first, what do do for steps 1 and 2, as it look slike this was written from a win machine. and then tell me where php.ini is and how to add the requested data.

Thanks in advance.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Re: PHP.INI location and how to edit?
« Reply #1 on: March 29, 2006, 12:34:44 PM »
Quote from: "WACOMalt"
ok, so I have this problem on my server, no one can upload avatars to my phpBB forum. the folders are chmodded correctly and everything.

now many people have this problem, and finnaly someone found a workaround. Here is what they said:

Quote
areacode212 wrote:
I had this problem the other day, and came across this solution on another site. Basically, I had to add something for "upload_tmp_dir" in php.ini
Quote:
Solution is on the surface (as always, though).

1. Create folder anywhere on server’s local drive. For example, “C:\Inetpub\TempUploads”
2. Set to your server’s internet user account ( IUSR_<computer name> by default) full NTFS rights to this folder.
3. Edit your php.ini to contain these directives:
Code:
file_uploads = On
upload_tmp_dir = "C:\Inetpub\TempUploads\"

4. Remember to set to your server’s internet user account full NTFS rights to folder, which you set in forum configuration at Administration > General Admin > Configuration > Avatar Settings > Avatar Storage Path.
5. Have fun.

Problem cause: This PHP issue. PHP config says that “Temporary directory for HTTP uploaded files will use system default if not specified”, but it couldn’t because Internet user account NEVER has access to server’s (Win2k/XP/2k3) TEMP folder.

After I did this, I restarted Apache, and avatar uploading worked.


now, hopefully that will work for me, but can anyone tell me, first, what do do for steps 1 and 2, as it look slike this was written from a win machine. and then tell me where php.ini is and how to add the requested data.

Thanks in advance.


Your php.ini is located in the /etc directory, however do not edit this file as it is build from templates. These templates cam be fount in the /etc/e-smith folder. Have a look here: The SME Developer Guide, Chapter 7. Configuration file templates

About your needs... the user that httpd is running under is called www on SMEServer 7, so you should give this user rights to a temporary upload directory, however I don;t think it is neccesarry to create a extra directory as on the *NIX systems the /tmp folder is most of the times writeable by the webserver, so your best bet is to simply use the /tmp folder (or create a subdirectory in there) for your temporary upload directory.

As I remember correctly file uploading is enabled by default on the SMEServer, you can simply check using the following command
Code: [Select]
cat /etc/php.ini | grep file_uploads
This will look for the file_uploads section in your php.ini file if it is there it will display the setting, if not you should modify your templates to have it implemented in the php.ini file.

To set the temporary ipload directory in your php.ini file do this:
Code: [Select]
mkdir -p /etc/e-smith/templates-custom/etc/php.ini
cp -p /etc/e-smith/templates/etc/php.ini/60FileUploads /etc/e-smith/templates-custom/etc/php.ini

Now edit the copy of the original template file we just put in the templates-custom directory:
Code: [Select]
pico /etc-e-smith/templates-custom/etc/php.ini/60FileUploads
At the bottom enter the following code:
Code: [Select]
upload_tmp_dir = /tmp
Press Ctrl-X, confirm save with Y, and press enter as we do not want to modify the filename.

Expand the template:
Code: [Select]
expand-template /etc/php.ini
Verify that the settings you made are incorporated in the /etc/php.ini file:
Code: [Select]
cat /etc/php.ini | grep upload_tmp_dir

And restart the httpd deamon:
Code: [Select]
/etc/rc7.d/S86httpd-e-smith sigusr1
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline byte

  • *
  • 2,183
  • +2/-0
PHP.INI location and how to edit?
« Reply #2 on: March 29, 2006, 01:51:22 PM »
There is actually no need to do all of that all you need to do is what Charlie said in WACOMalt original post here http://forums.contribs.org/index.php?topic=31126.0

Quote From Charlie...

There's no need to change any templates to change those limits. The configuration database has properties for all those values:

config setprop php MemoryLimit nnnn
config setprop php PostMaxSize mmmm
config setprop php ploadMaxFilesize pppp
expand-template /etc/php.ini
/etc/rc7.d/S86httpd-e-smith restart


End Quote

If this doesn't work as above then rasie a Bug in the Bug Tracker.
--[byte]--

Have you filled in a Bug Report over @ http://bugs.contribs.org ? Please don't wait to be told this way you help us to help you/others - Thanks!

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
PHP.INI location and how to edit?
« Reply #3 on: March 29, 2006, 02:01:08 PM »
Quote from: "byte"
There is actually no need to do all of that all you need to do is what Charlie said in WACOMalt original post here http://forums.contribs.org/index.php?topic=31126.0

Quote From Charlie...

There's no need to change any templates to change those limits. The configuration database has properties for all those values:

config setprop php MemoryLimit nnnn
config setprop php PostMaxSize mmmm
config setprop php ploadMaxFilesize pppp
expand-template /etc/php.ini
/etc/rc7.d/S86httpd-e-smith restart


End Quote

If this doesn't work as above then rasie a Bug in the Bug Tracker.

And waht about  the temporary upload directory? It is not specified in the php.ini file by default so my guess is that you might need to configure it, or does php by default use the /tmp directory for that?
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline JonB

  • *
  • 351
  • +0/-0
PHP.INI location and how to edit?
« Reply #4 on: March 29, 2006, 02:37:59 PM »
It won't make any difference if you set the upload_tmp_dir to /tmp. SME will not allow php to access it due to the open_basedir restriction that is in place on all Ibays. This is a security feature to stop malicious php code from accessing the server outside the Ibay.

See http://no.longer.valid/phpwiki/index.php/TroubleshootingFAQ#php_basedir


I think you might find your problem is even simpler than that.
First make sure that phpBB is configured to use /images/avatars as the upload folder then make sure that /images/avatars is world writable i.e the permissions are set to 666.

Jon
...

WACOMalt

PHP.INI location and how to edit?
« Reply #5 on: March 29, 2006, 04:46:38 PM »
Quote from: "JonB"
It won't make any difference if you set the upload_tmp_dir to /tmp. SME will not allow php to access it due to the open_basedir restriction that is in place on all Ibays. This is a security feature to stop malicious php code from accessing the server outside the Ibay.

See http://no.longer.valid/phpwiki/index.php/TroubleshootingFAQ#php_basedir


I think you might find your problem is even simpler than that.
First make sure that phpBB is configured to use /images/avatars as the upload folder then make sure that /images/avatars is world writable i.e the permissions are set to 666.

Jon


we (all of the people with this problem) has set the upload directory (images/avatars) to 777. would 666 fix this?

but we have tried 777, which I thought was full access. The people with this problem use many different servers, from windows to this SME server.

now, I want to complete the instructions I posted in the first post, because everything else has failed, are the instructions that "cactus" posted the ones I should use to do what the original post said? just modified for SME?

Im sorry if I seem not responsive to your suggestions, but beleive me, this workaround needs to be done, it is a bug in phpBB or so it seems, about how the avatar uploads are handled. even if everything is set right, permissions are right and everything, it does not work, but yet my attach file mod works.. so I think its just how the avatars are handled. Now, this workaround alone should force it to work. so thats all I need to know. I will try cactus's suggestion when I get home, and if that doesnt work I will try to set the permissions to 666 rather than 777, but all of the phpBB upload settings are correct.

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
PHP.INI location and how to edit?
« Reply #6 on: March 29, 2006, 05:15:26 PM »
Quote from: "JonB"
It won't make any difference if you set the upload_tmp_dir to /tmp. SME will not allow php to access it due to the open_basedir restriction that is in place on all Ibays. This is a security feature to stop malicious php code from accessing the server outside the Ibay.

See http://no.longer.valid/phpwiki/index.php/TroubleshootingFAQ#php_basedir


I think you might find your problem is even simpler than that.
First make sure that phpBB is configured to use /images/avatars as the upload folder then make sure that /images/avatars is world writable i.e the permissions are set to 666.

Jon

I believe php is able to write to the /tmp directory for temporary processes as it is also able to write session data there, if not you can alter the open_basedir setting analogue to this thread: Enabling PEAR in an ibay
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

WACOMalt

PHP.INI location and how to edit?
« Reply #7 on: March 30, 2006, 03:13:09 AM »
thank you all for your suggestions!, but now, it seems there are many different overlapping instructions...

exactly what should I do to do the instructions int he original post?
I know there are other, possibly better ways to do it, but can someone tell me what to do, with only the changes that HAVE to be done for it to work at all?

Offline JonB

  • *
  • 351
  • +0/-0
PHP.INI location and how to edit?
« Reply #8 on: March 31, 2006, 06:31:24 AM »
Ok, I have just installed phpBB to try this out.

To be able to upload Avatars you need to disable the php_basedir restriction that is in place and allow php in that ibay access to tmp. Note that does decrease the security of your server.

http://no.longer.valid/phpwiki/index.php/TroubleshootingFAQ#php_basedir

Use the commands exactly as shown, remembering to replace <ibayname> with the correct ibay.

You need to chmod /images and everything inside it as 777 otherwise users wont be able to delete avatars.

Cactus, in SME the only PHP application that has access to /tmp by default  is Horde

Jon
...

WACOMalt

PHP.INI location and how to edit?
« Reply #9 on: March 31, 2006, 07:23:00 AM »
Thank you JonB I will try this tommorow.

and the default ibayname would be Primary right?

that what area all of my files are dragged to to put stuff online.

WACOMalt

PHP.INI location and how to edit?
« Reply #10 on: April 09, 2006, 02:31:34 AM »
Ok, I followed that word for word, and the ibay I use is called Primary.. so I put that inplace of <ibayname> I finished exactly as they said, and all seemed to go well.

..but now my forums dont work at all..

I restarted my server, and still no luck.

Ok, so I want to try this again, as I have tried so many things, I think a past change may have screwed with THIS change. so is there a way to reset all PHP settings? or every template and php.ini file back to how they are on a fresh SME install?

thank you very much for the help, I beleive this is the right fix, but I also see that I screwed something up along they way.

WACOMalt

PHP.INI location and how to edit?
« Reply #11 on: April 11, 2006, 01:47:25 AM »
please, the forums are the main part on my site, I need to at least get them back up!

so Im bumpin :/

how do I reset all php settings?

Offline JonB

  • *
  • 351
  • +0/-0
PHP.INI location and how to edit?
« Reply #12 on: April 11, 2006, 05:06:41 AM »
What does

#db accounts show Primary

say.

Jon
...

WACOMalt

PHP.INI location and how to edit?
« Reply #13 on: April 11, 2006, 05:51:25 AM »
Quote from: "JonB"
What does

#db accounts show Primary

say.

Jon


I get the following:

Code: [Select]
Primary=ibay
   CgiBin=enabled
   Group=shared
   Modifiable=no
   Name=Primary i-bay
   PHPBaseDir=/home/e-smith/files/ibays/Primary/tmp
   PasswordSet=no
   Passwordable=no
   PublicAccess=global
   Removable=no
   UserAccess=wr-admin-rd-group


I assume the PHPBaseDir shouldnt be set to tmp, so now how to fix?

Offline JonB

  • *
  • 351
  • +0/-0
PHP.INI location and how to edit?
« Reply #14 on: April 11, 2006, 06:51:07 AM »
Correct, you didn't set the PhpBaseDir correctly.

To remove the database entry

Code: [Select]
# db accounts delprop Primary PHPBaseDir

to add correctly

Code: [Select]
# db accounts setprop Primary PHPBaseDir /home/e-smith/files/ibays/Primary/:/tmp
# signal-event ibay-modify Primary


Watch the line wrap. The first line is all one line.

Jon
...