Is it possible to disable safe mode in PHP 5.6? - php

In PHP 5.6 is it possible to disable safe_mode? First I want to do it locally. I am using XAMPP and Windows. I have tried to find safe_mode in php.ini but not found.
I want to execute mysqlcheck -c eximstats this kind of command from script in server. What i have done so far is tried exec(), system() but not worked. This is why i need to disable safe_mode.

Related

Parallels PLESK 12.0.18 - PHP exec() disabled

I've been trying to exec() an exe which calls wkhtmltopdf to produce a PDF and then push it to the browser.
However, exec() and system() and shell_exec() seem to be not working under Plesk 12.0.18 on a windows machine, presumably for some crappy security reason.
Does someone know how I can go about enabling this? I know safe mode no longer exists in PHP 5.6 so I am not sure why this isn't working.
Very annoyed. I have root access as this is a dedicated server with 1 and 1.
I just uninstalled PLESK and installed Wamp Server.
Problem solved.

WAMP server is blocking shell_exec() in Windows?

I can't use shell_exec() when using a WAMP server in Windows. I am using PHP 5.4+ so there is no safe mode, I have checked disabled functions, nothing is disabled. I simply get nothing from shell_exec()!
I have tried just doing echos on strings and I get it out normally.
Is there some way that WAMP or Apache is disabling my use of shell_exec()?

php exec inside exec / nested exec

If I'm already running code in a background by exec
and inside it I call for another exec.
Is it possible ?
If so, does it need special permissions ?
The error I have (and I suspect nested exec in it):
exec() has been disabled for security reasons
Regular exec enabled and works.
Technically it's possible to have an exec in your exec, but it looks like you're using different configurations. Usually PHP has to different sets (Apache and CLI) of php.ini files (which might be configured to disable the exec function at all.
I assume your first exec call is coming from apache, which then calls a php script on the command line. The second seems to have a different configuration and therefore disallow the exec-call. So best have a look at /etc/php, if there are different php.inis set.
Can you please share your code.... It is difficult to determinate if there is any problem without looking the code.
If you have access to use exec it should not be a problem to use exec inside another exec.
This is your localhost or a shared hosting? Most shared hosting disable exec for security reasons.

How can I to run php script from powershell-commandline?

How can i setup my powershell to run php scripts in like a commandcall like this
php test.php
I'm able to do this on a server at work which I connect to by putty, but would be nice if I was able to execute those scripts directly from my own without having some server running.
I also know about Xaml, which I don't like since its require you to refresh some browser.
You can do all the stuff suggested above or ...
Go to php.net and download the php file stack for windows.
Copy the file stack into say c:\php or if you want multiple versions, say c:\php5 or c:\php7 etc.
Open powershell and type c:\php\php.exe -h, you will get the php help output. Yay you are up and running, whoot.
(Note: you may need to rename php.ini.development -> php.ini
Advanced instructions:-
Type env into os search (cortana) and select environmental variables.
Add your php location to path (c:\php) and create a variable php (or php5 etc) pointing to c:\php\php.exe
Now you can run php in powershell with php (php -h to test).
Note: while not the question, this also works in the git bash shell.
I'm assuming windows since you said powershell. You can just install php on windows but that means also installing apache or enabling IIS.
Or there's apparently a built-in webserver for command-line functionality that might minimize the amount of headache involved in configuring that stuff.
This might help get you going also:
http://php.net/manual/en/install.windows.legacy.index.php#install.windows.legacy.commandline

Running shell commands using PHP script

I'm creating an app using CodeIgniter, but I'm unable to run Linux commands using my PHP script.
How do I run terminal commands?
I've tried shell_exec() and exec(), but both don't work while using CI.
That depends on your server configuration if the functions are disabled, you need to enable them in your php.ini. Here are some alternatives:
popen()
or if you need an interactive way try proc_open()
system()

Categories