Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/291.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/opengl/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用php在/etc中创建目录_Php_Linux_Nginx_Laravel 5_Shell Exec - Fatal编程技术网

使用php在/etc中创建目录

使用php在/etc中创建目录,php,linux,nginx,laravel-5,shell-exec,Php,Linux,Nginx,Laravel 5,Shell Exec,我想在/etc/nginx/sites enabled/php中创建一个文件,我已经尝试了很多次,但php不会让人认为我已经修改了/etc/sudoers,我把它们全部放在user:NOPASSWD:ALL中,但仍然不起作用。有人可以告诉我为什么 $result= shell_exec('sudo -u root mkdir /etc/nginx/myfile'); 我的文件/etc/sudoers # # This file MUST be edited with the 'visudo'

我想在/etc/nginx/sites enabled/php中创建一个文件,我已经尝试了很多次,但php不会让人认为我已经修改了/etc/sudoers,我把它们全部放在user:NOPASSWD:ALL中,但仍然不起作用。有人可以告诉我为什么

$result= shell_exec('sudo -u root mkdir /etc/nginx/myfile');
我的文件/etc/sudoers

#
# This file MUST be edited with the 'visudo' command as root.
#
# Please consider adding local content in /etc/sudoers.d/ instead of
# directly modifying this file.
#
# See the man page for details on how to write a sudoers file.  
#
Defaults        env_reset
Defaults        exempt_group=sudo
Defaults        mail_badpass
Defaults               secure_path="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"

# Host alias specification
# User alias specification

# Cmnd alias specification
Cmnd_Alias NGINXVHOST = /bin/ln, /bin/mkdir
# User privilege specification
# root  ALL=(ALL:ALL) ALL
root ALL= (ALL) NOPASSWD:ALL
# Members of the admin group may gain root privileges 
%admin ALL=(ALL) ALL

# Allow members of group sudo to execute any command
%sudo   ALL=(ALL) NOPASSWD:ALL
vagrant ALL=(ALL) NOPASSWD:ALL
subdominio ALL=(ALL) NOPASSWD:ALL
# See sudoers(5) for more information on "#include" directives:

#includedir /etc/sudoers.d

请帮忙

实现此目标的正确方法是让PHP页面在任务队列中创建一个条目。该条目只需要包含虚拟主机的新域。然后,您应该有另一个以root用户身份运行的进程,它可以检查主机名并根据需要创建nginx记录


如果您目前没有使用任何任务队列,那么也可以通过一个简单的cron作业来实现。只需在数据库中输入vhost名称即可。然后每分钟进行一次cron作业检查该表,并制作nginx记录。

让您的web可访问的PHP访问根目录简直是疯了。如果是,实际上我的问题是我想创建一个PHP vhost,因为这确实是meI建议通配符DNS的问题,比如*.example.com和确定请求哪个主机的逻辑。