Jun 2, 2016
0
Level 2
How to check nginx config file using php shell_exec?
I have a task in Laravel to create a nginx.conf file in storage folder and test the file with nginx command. I have created a config file 'nginx.conf' in storage folder and I tried to test with the help of nginx command, shell_exec() or exec() but I am getting error 'Permission denied'.
Here is the command line I have followed to test nginx.conf file "https://www.nginx.com/resources/wiki/start/topics/tutorials/commandline/#"
#NginxController.php
public function nginxConfig(){
$path = storage_path('app/nginx/nginx.conf'); //"/home/vagrant/Code/Laravel/storage/app/nginx.conf"
/*$change_mode = exec('chmod -R 755 /home/vagrant/Code/Laravel/storage/app/nginx 2>&1');*/
$config = exec('/home/vagrant/Code/Laravel/storage/app/nginx -t 2>&1');
dd($config);
/*$restart_config = shell_exec('/etc/init.d/nginx restart');
$reload = shell_exec('nginx -s reload');*/
}
#message getting
"sh: 1: /home/vagrant/Code/Laravel/storage/app/nginx: Permission denied"
#nginx.conf
server {
listen 443 ssl http2
root /var/www/google.de/beta.google.de
index index.html index.htm index.php
server_name beta.google.de
include var/www/includes/contao
include var/www/includes/shopware
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
access_log off; log_not_found off; expires max;
}
}
Please or to participate in this conversation.