php include issue - works on one server... not another.. init file? - php

php "includes" are working fine on my current production server/site. (shared server)
I am moving this site to a new server and "includes" do not work. Error message:
Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/xxxxx/public_html/publications/abss/myfile.php on line 140
In control panel I can set php version from 5.2 to 5.6 and generate init file. When I look at init file I find no "include" option to enable.
Questions:
Why is there no enable option in php.ini file? (I tried both 5.2 and 5.6 versions) Can I manually enter?
Does the php.ini file run each time a page is rendered?
How do I know if php.ini is actually in effect?
Thank you very much.

First of all check
phpinfo()
to see allow_url_fopen" and "allow_url_include" are ON
If not, you need to set them on OR contact your webmaster or hosting provider to enable allow_url_fopen and allow_url_include in the PHP server configuration.

I had tryed "allow_url_include" on but didn't work.
However, when I copied my init file from the old server to the new it worked fine. Not sure why. Didn't do a file compare.

Related

Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0

I upload my Laravel project on shared hosting. When I upload my project on the server it throws an exception then switched my PHP version 5.4 to 7.4. Now am facing this issue.
Deprecated: Directive 'allow_url_include' is deprecated in Unknown on line 0
I also disable the allow_url_include in my PHP ini file which exists in project root directory but it still says allow_url_include depreciated error.
Also, I go into the PHP Multi INI Editor and change the allow_url_include but it still throw the above error.
Remove .htaccess or change name to .htaccess.backup and WP will generate new file based on your site configuration
Log into your website host and navigate to your public_html folder and find the php.ini file. Open the file and find this code:
; Whether to allow include/require to open URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-include
allow_url_include = On
Change allow_url_include = On to allow_url_include = Off and save the file.
This should fix the error.
Additional detail located here:
https://www.php.net/manual/en/filesystem.configuration.php#ini.allow-url-include
In case anyone comes across this:
Make sure that .htaccess files at all levels do not have conflicting code.
That is, I found that my ".../public_html/.htaccess" did not have any conflicts. However, I also had an .htaccess file in the folder level above that and it included code that read:
# Use PHP71 as default AddHandler application/x-httpd-php71 .php <IfModule mod_suphp.c> suPHP_ConfigPath /opt/php71/lib </IfModule>
Commenting this out resolved the error for me.
If your web host uses Cpanel, log in and under the Software section click Select PHP Version, then on the next screen click Options. Under Options, unclick allow_url_include:
Please Update PHP version of your site through CPanel to 7.3. This fixed the issue for my site. Thank you!
My client had 2 .ini files, conflicting max_input_var.
Deleting user.ini worked for me! Payment options were greyed out in WooCommerce. Now they are showing and this "allow_url" error is gone.

How to run php script on localhost stored on another server

I want to run php script from another server on localhost I tried include "http://example.com/settings/aiacacc.php"; but I'm getting an error.
include(): http:// wrapper is disabled in the server configuration by allow_url_include=0
How can I enable include from another server using php.ini file. I know it is not a good practice but my application is going run on localhost only. i don't want this setting to be disabled.
I want to return a php script from another server and then execute this script on my localhost
Go to your php.ini file and edit it to switch on the allow_url_include setting:
; Whether to allow include/require to open URLs (like http:// or ftp://) as files.
; http://php.net/allow-url-include
allow_url_include = On
Alternatively use the code below in your php file
ini_set('allow_url_include', 'On');
In php.ini:
allow_url_include=1
As you mentioned above. you want to return some PHP code from another server and execute it on the localhost. For that the first step is to edit your php.ini file and add this line allow_url_include = On and secondly the php script that you want to return from another server should not have .php extension instead It should be saved as a simple text file with .txt extension

How to fix PHP Deprecated Automatically populating $HTTP_RAW_POST_DATA is deprecated issue?

hello i'm getting this error in my error log:
"PHP Deprecated: Automatically populating $HTTP_RAW_POST_DATA is deprecated and will be removed in a future version. To avoid this warning set 'always_populate_raw_post_data' to '-1' in php.ini and use the php://input stream instead. in Unknown on line 0"
My wordpress version is 4.8.1 and the php version is 5.6.30.
I tried fixing the issue by creating a php ini file and setting always_populate_raw_post_data value to -1. But i still get the error.
If it cannot be fixed, how can i prevent it prints on the error log?
I'm using a shared hosting.
how can i prevent it prints on the error log?
Your problem here is not that you cannot access php.ini and it is not that error shows.
Your problem, in fact, is that you use deprecated variable
instead, you could try using
file_get_contents('php://input');
php.ini is located somewhere in the php files on the server, which I assume you have no access to on shared hosting.
The php.ini file you created needs to be located where PHP expects to find its config files. You can see the configs which PHP is already loading using the phpinfo() function:
Upload a file named info.php with the following contents to your web server root:
<?php
// delete this file or comment out the below function when not in use
phpinfo();
?>
Then use a browser to navigate to http://yourwebsite.com/info.php. A page should load which tells you all about your php configuration. Look for the part near the top which shows information about the loaded configuration files. In particular, look for these entries:
"Loaded Configuration File" and "Scan this dir for additional .ini files".
If you have access to the .ini file listed as the Loaded Configuration File simply modify the value for always_populate_raw_post_data there. Otherwise, upload the .ini file you already created to the directory that is scanned for additional configuration files. Of course, you'll need to reload or restart php in order to reparse the configuration files.
If you don't have access to any of the locations listed from the above steps, it's possible your hosting provider may give you access to your php.ini file through cPanel or a similar means. Otherwise, your best bet is to contact them directly.
Finally, if you don't care about the actual configuration value as much as just suppressing the warning message, you could use the ini_set() function to set your error reporting to a different value, eliminating any deprecation warnings. The variable you want to set is "error_reporting" and a list of possible values can be found here.
In addition, since you are running WordPress there are some debug and error reporting options you can set in the wp-config.php file.
If your Account (on the shared hosting) using (or Configured) PHP-FPM, you can't do it via php.ini (if you create php.ini in your root, it will have no effect)
you can try: add this code
<IfModule mod_php5.c>
php_value always_populate_raw_post_data -1
</IfModule>
in your .htaccess file in your root directory, if not helps then ask the server admin (support) to change that in core php.ini globally for the given host.
You cant create a PHP.ini just like that. This is a core config file that is part of the PHP install. http://php.net/manual/en/configuration.file.php Read over this documentation to get a better idea of what the ini does.
The ini file could be located in multiple places depending on the OS and who installed it. If you do not have access to it, talk to your hosting provider

How to make the server load php from another directory?

I have a dedicated server and I'm facing a strange issue. I found there 2 php installations and only one must be used and is correct, which is version 5.2.6, but currently, I see on phpinfo that the php.ini is being loaded isn't the right configuration. The php.ini which I need the server use is located in /opt/php-5.2.6/config/php.ini and the current in use is located in /etc/php.ini. How to turn on the php located in /opt/php-5.2.6/ ? I don't know what happened, maybe after I tried to install the xCache extension, but didn't work and in some way that installation of xCache changed where the php is loaded from.
How to make loading the php which I have in directory /opt/php-5.2.6/ ?
Thanks.
You can make your apache to point to another php.ini using .htaccess file.

d13slideshow for WordPress and "URL file-access is disabled"

I'm taking my chances with WordPress 3.0 beta 1 (single user)
Unfortunately, i ran into problems with d13slideshow.
I configured the plugin to display 5 latest from a category, added <?php d13slideshow(); ?> to home.php, but it bombed:
function.getimagesize: URL file-access is disabled in the server configuration in /<snip>/wp-content/plugins/d13slideshow/d13slideshow.php on line 538
Warning: getimagesize(http://<snip>/wp-content/uploads/2010/04/featured-2-580x386.jpg) function.getimagesize: failed to open stream: no suitable wrapper could be found in /<snip>/wp-content/plugins/d13slideshow/d13slideshow.php on line 538
Is this a problem with the php setup or is there something I can do with the plugin or the function call from the template files to make it work?
http://wordpress.org/extend/plugins/d13slideshow/
It seems to be a configuration stuff... you will have to edit your php.ini and change the allow_url_include option from Off to On. For example
# nano /etc/php5/apache2/php.ini
; Whether to allow include/require to open URLs (like http:// or ftp://) as files.
allow_url_include = On
Then, you will have to restart apache:
# /etc/init.d/apache2 restart
You will have to use the correct paths for your server ;)
Tell me if that works...
You may not have access to your php.ini file due to hosting restrictions. Ask you host or check for an update to that plugin.

Categories