Hello, I downloaded my php.ini file from my etc folder. I checked on my phpinfo() function, and it said that php.ini is located in /etc. However when I tried to run the zencart installer, it said that safe mode was on. When I looked in my php.ini file I looked at the line where safe mode is set, and it read:

safe_mode=off

I can't execute shell commands either through shell_exec, so I am thinking that there may be something weird going on with my php.ini flie...

    check theres not another copy of php.ini, also some settings can be set in .htaccess. also restart server after making any changes in php.ini.

      where would I begin to look for another copy of php.ini. Would safe mode be an option I can set in php.ini?

        windows key f, and search for it, or what ever is appropriate for your puter.

          Since you say your php.ini is located in /etc, I'll assume you are running a Linux box. Type this in the command prompt to see what php.ini's there are in your system:

          [root@host ~]# updatedb
          [root@host ~]# locate php.ini

          That should give you a listing like..

          /etc/php.ini.saved_by_psa
          /etc/php.ini
          /etc/php.ini.rpmnew
          /usr/local/psa/admin/conf/php.ini
          /usr/local/psa/admin/conf/php.ini.def

          Now, you can use the "ls" function to see which php.ini is really there 😉
          Run the following command to list a directory, and show any links to other documents:

          [root@host ~]# ls -las /etc | grep php

          You should get output like:

            4 drwxr-xr-x   2 root  root      4096 Jun 26 20:51 php.d
           40 -rw-r--r--   1 root  root     38512 Jul  9 20:18 php.ini
           44 -rw-r--r--   1 root  root     44717 Jan 19  2008 php.ini.rpmnew
           40 -rw-r--r--   1 root  root     38450 Sep 20  2007 php.ini.saved_by_psa

          Now, I have a directory, and 3 php.inis. One is saved from when I updated php by RPM from AtomicRocketTurtle's repository, and the other is saved by Plesk for whatever reason (way to long ago).

          I don't have any links, but if I did, it'd look something like:

           0 lrwxrwxrwx   1 root  root        33 Jun 10 13:01 rndc.conf -> /var/named/run-root/etc/rndc.conf

          Notice the "->"? That means that the file is really just a pointer to some other file. Now since you downloaded your php.ini, I'm guessing it's not a link. But just better to be sure 🙂

          Now, you should be able to edit what you need and then put it back up there. At this point, you need to (1) make sure it's owned and chmoded properly (owner:group = root:root & perms are 644). You can do this on the command line like:

          [root@host ~]# chown root:root /etc/php.ini
          [root@host ~]# chmod 644 /etc/php.ini

          Now, you need to restart your Apache server. This can be done one of two ways. Typically it's running as a service so you may be able to do:

          [root@host ~]# service httpd restart

          If all goes well, you should see something like:

          Stopping httpd:                    [ [color=green]OK[/color] ]
          Starting httpd:                    [ [color=green]OK[/color] ]

          If you didn't get that, then should get 1 of two outputs (if the httpd service didn't restart):

          httpd: unrecognized service
          -- OR --
          -bash: service: command not found

          If "httpd" isn't a recognized service, you could also try "apache" or "apache2". Some systems name them different things.

          If your system doesn't recognize the "service" command, you could install the package that gives "service" (not necessary) or you can locate apachectl and use that. So to locate apachectl, you just use the "locate" function.

          [root@host ~]# locate apachectl

          You should get something like:

          /usr/sbin/apachectl

          To which if it's /usr/sbin or /usr/bin you should be able to just call it like:

          [root@host ~]# apachectl graceful

          If it's not in /usr/sbin or /usr/bin then you need to call it directly like:

          [root@host ~]# /usr/sbin/apachectl graceful

          Note, that sometimes even though it's in /usr/sbin, you can't always call it from just "apachectl", you'll have to actually call it directly like I did above.

          Now that apache should be restarted, take a look at your phpinfo() output and see if anything has changed. If you look at the Master and Local values, you should see in the left column "safe_mode" and in the right columns "Off" and "Off". If they're off, then that's one thing down. If they're on, then something went wrong, and you'll have to try editing again.

          A good way to check what's on the server is what you expect is to use vi or ViM. You can open php.ini with:

          [root@host ~]# vim /etc/php.ini

          You can then use Page Up and Page Down to scroll through (arrow keys as well). You won't be able to make edits in this mode, so try not to type anything on the keyboard. If you find something you want to edit, hit the "i" key and you'll see "-- INSERT --" pop-up in the lower left-hand corner of your shell. From here you can make any modification you want. You'll be inserting into the file. If you just want to replace a letter or number, you can hit the "r" key and that will put you in replace mode until you type another character.

          If you screw something up while in ViM or Vi, fret not. You can easily ignore all the changes you made by hitting escape quite a few times and typing :q!. The ":" means a command is coming, the "q" means quit, and the "!" means discard changes.

          To save changes with ViM, you just need to type :x. Simple enough 🙂

          Now, if your phpinfo() output shows that you're okay and you have what you expect, try whatever install you want again. If it still shows an error, the you need to locate a .htaccess file between the file you're executing, and the document root of the website. In there, you might see something like:

          php_admin_flag safe_mode On

          Not sure if it's php_admin_flag, php_admin_value, or php_value, but one of those might be there. So you'll have to search for that if all else fails.

            Thanks a lot for the help guys I got it working now. I had these lines in my httpd.include file that must have been turning safe mode on:

            	<IfModule sapi_apache2.c>
            		php_admin_flag engine on
            		php_admin_flag safe_mode on
            		php_admin_value open_basedir "/var/www/vhosts/andydaykin.com/httpdocs:/tmp"
            	</IfModule>
            	<IfModule mod_php5.c>
            		php_admin_flag engine on
            		php_admin_flag safe_mode on
            		php_admin_value open_basedir "/var/www/vhosts/andydaykin.com/httpdocs:/tmp"
            	</IfModule>
            

            I just changed the on to off and restarted apache, and it worked.

            That locate is sure handy!

              Write a Reply...