xxxxxxxxxx
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo service nginx start
sudo service nginx stop
sudo service nginx restart
sudo /etc/init.d/nginx start
sudo /etc/init.d/nginx stop
sudo /etc/init.d/nginx restart
xxxxxxxxxx
// The nginx package supplies a /etc/init.d/nginx script that provides the usual start|stop|restart|reload ... functionality.
/etc/init.d/nginx restart
// will restart nginx as will
service nginx restart
xxxxxxxxxx
const { exec } = require('child_process');
exec('sudo service nginx restart', (error, stdout, stderr) => {
if (error) {
console.error(`Error: ${error.message}`);
return;
}
if (stderr) {
console.error(`stderr: ${stderr}`);
return;
}
console.log(`stdout: ${stdout}`);
});