Error "Warning: putenv() has been disabled for security reasons"

Asked

Viewed 1,505 times

1

When I upload to production I get these errors:

Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86 Warning: putenv() has been disabled for security reasons in /home/httpd/htdocs/telekobr/site/vendor/vlucas/phpdotenv/src/Dotenv.php on line 86

I am using Laravel 5.1 and the server is with PHP5.6

1 answer

4


The getenv is not a function of Laravel, despite being used by him, messages "similar" to this:

Warning: ... has been disabled for security reasons

Indicate that the server administrator has disabled on php.ini some function or class specifies, in your case the php.ini must be something like:

; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
; http://php.net/disable-functions
disable_functions=getenv

The only way to enable is to edit and remove the getenv of disable_functions, if you don’t have access to php.ini just getting in touch with the hosting or administrator of the server.

If you have access just leave it empty, like this:

; This directive allows you to disable certain functions for security reasons.
; It receives a comma-delimited list of function names. This directive is
; *NOT* affected by whether Safe Mode is turned On or Off.
; http://php.net/disable-functions
disable_functions=

Generally in Linux the php.ini for Apache this located at (being php5.*):

/etc/php5/apache2/php.ini

However if you have doubts about the location create a file info.php in the briefcase htdocs and open via browser http://meusite/info.php look for php.ini with Ctrl+F it will show the location, now the most important delete the info.php for security reasons, it exposes sensitive server data.

So with the location of php.ini correct open the editor/word processor using sudo/su, after editing and saving restart Apache, this is the command (run with sudo/su):

service apache2 restart

If you’re using Xampp locations change and this I explained does not apply, Xampp usually has a configuration panel that facilitates all this (I can’t say why I don’t use).

Note:

To disable a function, for example the function mail, we use disable_functions thus:

disable_functions=mail

And to disable a class, for example Directory, we use disable_classes thus:

disable_classes=Directory
  • thanks a lot for the clarification, I took a look at the server and did not find this file, I will contact the support to change. Thanks

  • @Scooby php.ini is not loose anywhere, if you only have access to FTP you will never be able to access, especially if you are a SHARED server (common hosts), the only ones that can access are the server(s)/station(s)

  • I found the php.ini file but I am not allowed to edit it

  • I downloaded the server by the program Putty and logged with my user, then used sudo and sudo -s command, but gave invalid command. After a few attempts I am no longer able to access the server gets timeout. Thanks for the help, I will contact the support.

  • it would be the Ubuntu, yes I already used these commands, I contacted the support and they have to release even this permission of the function. I cannot change manually due to the server being shared. Thanks for the help, it was very helpful I will mark as solved.

  • @Scooby for nothing, thank you ;)

  • I was subpoenaed that they can not release this function for security reasons, know of any alternative to work the env of my site?

  • 1

    @Scooby unfortunately is impossible, just switching framework or even hosting, I find strange this argument of theirs, the getenv It will only be "insecure" if they release something sensitive in a forced manner in the "environment variables", which seems to me to be a huge failure on their part. Have accommodation in account that support everything in Brazil, maybe it’s time to migrate.

  • Thanks, I’ll have to change hosting rs

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.