Jump to content
The Uniform Server Community

php.ini


mrippon
 Share

Recommended Posts

Hi, I'm using uniserver to develop my website on my local machine so I don't have to keep uploading files to my remote server to test everything.

 

I don't have access to the remote server's setup so to change some of the settings (in particular auto_prepend_file and auto_append_file) I created my own php.ini and put it in the base directory of the server where my index.php is. This works great on the remote server but on my uniserver setup, the php.ini file seems to be completely ignored no matter where I put it (I would expect it to work if it was in the www folder?)

 

If I modify the main php.ini and restart uniserver then it works but that isn't much help because it breaks the apanel.

 

I'm using the default setup of uniserver 3.3. I know I am probably missing something really obvious but any help would be appreciated as I am a bit of a novice when it comes to setting up servers.

Link to comment
Share on other sites

An alternative to using php.ini is to use .htaccess for auto_prepend_file and auto_append_file, this example explains how.

 

1) In your root folder (wwww) create a new folder named atest

 

In this folder add the following files:

 

test.php

 

Test page

This is a test file

echo "

Content TEST

"?>

 

top.php

TOP TEST

 

bottom.php

BOTTOM TEST

 

.htaccess

php_value auto_prepend_file "top.php"

php_value auto_append_file "bottom.php"

 

Top.php and bottom.php are not practical however they do demostrate the point.

View test.php in a browser and you will see the files have been appended and prepended accordingly.

 

2) In the folder that you created (atest) create a new folder named test2

 

In this folder, add the following file:

 

test2.php

 

Test page 2

This is a test2 file

echo "Content TEST2" ?>

 

View test2.php in a browser and you will be greeted with an error message similar to this:

 

Warning: Unknown: failed to open stream: No such file or directory in Unknown on line 0

 

Warning: Unknown: Failed opening 'top.php' for inclusion (include_path='.;/usr/local/PHP/includes;/usr/local/PHP/pear') in Unknown on line 0

 

The reason why this does not work is because includes (note: auto_prepend and auto_append are just fancy includes) are relative to the file that initiated them in this case test2.php. The directives in .htaccess were applied to the file however the includes were not found in the current folder (test2). At this point PHP does not give up hence it looks in any include paths for the files. It still cannot find the files, gives up, and produces the error message.

 

I have laboured this a little to make a point in most cases the answer lies in the error message this is crying out for an include path to fix the problem. The final .htaacess file looks like this:

 

 

php_value include_path ".;/www/atest"

php_value auto_prepend_file "top.php"

php_value auto_append_file "bottom.php"

 

The include path points to the folder that contains the pages to be included. Net result of adding the above line is that any php file within the folder containing .htaccess and sub-folder files will have top.php and bottom.php automatically included.

 

All the best :D

Link to comment
Share on other sites

I forgot to answer your original question. :lol:

 

I think the reason why your php.ini is not seen is because UniServer runs PHP as a module hence php.ini is only used (read) when apache is started. If PHP is running as a CGI then the php.ini file is checked per request just like your service providers installation. In terms of security, there is some debate between running php as a module or as a CGI, looks as if the UniServer team has chosen running as a module.

 

Could be wrong :D

Link to comment
Share on other sites

You cannot put it anywhere! It is not mobile and not meant to be moved! And there are some variables that must be in the file so modification of the original is the best way to go.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...