2016-06-07 4 views
1
을 입력하십시오.

/etc/nginx/sites-enabled/php에 파일을 만들고 싶습니다. 여러 번 시도했지만 PHP가 이미/etc/sudoers를 수정했다고 생각하지 않습니다. 나는 그들에게 사용자 ALL을 넣는다 : NOPASSWD : ALL 그리고 여전히 작동하지 않는 누군가는 왜 나에게 말할 수 있는가?/etc에 디렉토리를 만들고 PHP로

$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 

도와주세요!

+1

웹에 액세스 할 수있는 PHP 액세스 권한을 루트에 부여하는 것은 미친 짓입니다. – ceejayoz

+0

만약 그렇다면 사실 내 문제는 PHP 가상 호스트를 만들고 싶다는 것입니다. –

+0

와일드 카드 DNS와 같은 * .example.com과 논리로 요청 된 호스트를 결정할 수 있습니다. – user2182349

답변

1

이 목표를 달성하는 올바른 방법은 PHP 페이지가 작업 대기열에 항목을 작성하는 것입니다. 이 항목에는 가상 호스트의 새 도메인 만 포함하면됩니다. 그런 다음 호스트 이름을 확인하고 필요에 따라 nginx 레코드를 만들 수있는 root로 다른 프로세스를 실행해야합니다.

현재 작업 대기열을 사용하지 않는 경우 간단한 cron 작업으로도이를 수행 할 수 있습니다. 가상 호스트 이름으로 데이터베이스에 항목을 넣기 만하면됩니다. 그런 다음 cron 작업을 수행하여 매분 테이블을 확인하고 nginx 레코드를 만듭니다.