What I'm trying to achieve is, to reload php7.2-fpm service via php-deployer. According to php-deployer's documentation, it can be done like the code below:
task('reload:php-fpm', function () {
run('sudo /usr/sbin/service php7-fpm reload');
});
after('deploy', 'reload:php-fpm');
However, I face the error below while deploying:
➤ Executing task deploy:reload_php_fpm
↳ on [prod]
sudo service php7.2-fpm reload
In PhpSecLib.php line 124:
[RuntimeException]
sudo: no tty present and no askpass program specified
System info:
PHP Version 7.2
Ubuntu 18.04 LTS
PHP-Deployer Version 6.3.0
Do you have any idea how can I solve this issue?
After digging around, I finally found the proper answer to handle the situation.
I edited /etc/sudoers file by following command:
sudo visudo
At the end of the file, I added this line:
siamak ALL=(ALL) NOPASSWD:/etc/init.d/php7.2-fpm reload
It means that, the user siamak has permission to just reload php7.2-fpm without entering password. For any other administrative tasks, siamak must enter password.
Related
I know that there are a lot of similar questions already on the website or even in the another ones but I didn't get the solution even looking for all the information of this questions.
From PHP code, I'm trying:
exec('/etc/init.d/apache2 restart');
And on my sudoers file, I added the following line:
www-data ALL=(ALL) NOPASSWD: ALL
I tried a lot of combinations here like for exaple creating Cmnd_Alias but nothing works.
If I execute this exec, I get "Restarting apache2 (via systemctl): apache2.service failed!". And If I execute this exec command but with sudo, I get an error "Failed to restart apache2.service: Interactive authentication required." (seen on apache error.log). I have seen this error from browser console because I'm running the code from an AJAX post.
But if I try from the cmd, this command ask for a password (I don't understand why if I added the line I explained before on sudoers file):
sudo -u www-data /etc/init.d/apache2 restart
And of course if I add sudo, it works:
sudo -u www-data sudo /etc/init.d/apache2 restart
So I really don't know what is wrong here. If someone can help I will appreciate it because I am quite lost...
Regards
I am trying to build a vm, where exactly one user (as sudo or not) can brew and start a custom php build.
The current "default" php version should be started as phpbrew fpm process on system start. I was putting something like
phpbrew fpm start
in /etc/rc.local which seems to result in starting up the process. But the process is terminated as soon, as the rc.local script finished. It seems, that without an active login session, the process can't live.
Any suggestions, as how to make the fpm process survive?
Many thanks in advance.
You can modify this config according your needs.
phpbrew 1.22.0 now supports "fpm setup --systemctl" command to help you setup the service.
be sure to enable --with-fpm-systemd when building your php.
In phpbrew build directory it is exists ready file. For example:
~/.phpbrew/build/php-7.0.22/sapi/fpm/init.d.php-fpm
But more comfortable way is: temporary change owner of /etc/init.d to current user, then run command
phpbrew fpm setup --initd
then return back
sudo chown root:root /etc/init.d
sudo chown root:root /etc/init.d/phpbrew-fpm
and then
sudo update-rc.d phpbrew-fpm defaults
If you run it in macOS.
sudo PHPBREW_PHP=$PHPBREW_PHP phpbrew fpm setup --launchctl
and then add it to your launchctl list.
# Activate a system-wide daemon to be loaded whenever the system boots up (even if no user logs in):
sudo launchctl load /Library/LaunchDaemons/<path_to_phpbrew>.plist
when I input hhvm command. Terminal deoesn't response.
[environment]
Ubuntu 15.10
HipHop VM 3.11.0
Composer 1.0-dev
vagrant#vagrant-ubuntu-trusty:/var/www/html$ cat test2.hh
<?hh
require_once 'vender/facebook/xhp-lib/init.php';
echo <p>test</p>;
vagrant#vagrant-ubuntu-trusty:/var/www/html$ sudo hhvm test2.hh
Why??
If I remove .hhconfig file and input "touch .hhconfig" command, "hhvm test.hh" success one time.
But, I re-try "hhvm test.hh" and no-response....
vagrant#vagrant-ubuntu-trusty:/var/www/html/project$ sudo rm .hhconfig
vagrant#vagrant-ubuntu-trusty:/var/www/html/project$ sudo touch .hhconfig
vagrant#vagrant-ubuntu-trusty:/var/www/html/project$ sudo hhvm test.hh
<p>test</p>vagrant#vagrant-ubuntu-trusty:/var/www/html/project$
vagrant#vagrant-ubuntu-trusty:/var/www/html/project$ sudo hhvm test.hh
^Cvagrant#vagrant-ubuntu-trusty:/var/www/html/project$
I guess some service got lock of .hhconfig file...
Does someone give me hint??
I strongly suspect you are running into this issue with hh_client, which affects hhvm since the latter calls into the former. We are investigating it now, and will release 3.11.1 to fix it when we pin down the problem.
In the meantime, you can use the 3.9 LTS, or you can try passing -d hhvm.hack.lang.auto_typecheck=0 when invoking hhvm. (Though if you do the latter, make sure to stop doing that when 3.11.1 is out, since it removes protection against Hack type errors sneaking into your code!)
I was struggling with apache2 already installed in ubuntu so I decided to return back to lampp..I have unistalled apache 2 mysql server and phpmyadmin.
The problem is that when I type sudo which php
I get nothing...
So I cannot request e.g. sudo composer create-project laravel/laravel.....
since php is missing for root user..
Although when I type which php I get /opt/lampp/bin/php..
Is it possible to make the root user use the same path..?
You can do this:
Switch to root user
sudo su -
Edit the .bashrc
vi ~/.bashrc
And add a new path to the current one:
export PATH=$PATH:/opt/lampp/bin
Am trying to reload Apache 2 via /init.d/apache2 reload command in terminal but I get a command not found error and when I look at the etc/ directory in Finder I can't see any init.d folder. Is there somewhere else this init.d folder might be?
Just type in the terminal:
sudo apachectl graceful
graceful reloads the configuration files and gracefully restarts. Any current connections are allowed to complete.
For more info on the apachectl command just type:
man apachectl
And if that doesn't work, you can try sudo apachectl restart. Just for reference, OS X doesn't use init.d (although it used to); it uses launchd instead. See http://launchd.macosforge.org/.