No Ubuntu você pode fazer algo assim :
sudo adduser {username} www-data Isso não funciona no OS X, e pode não ser a melhor abordagem de qualquer maneira. No OS X, como você pode fazer o Apache Iniciar ou parar sem ter que inserir uma senha?
No Ubuntu você pode fazer algo assim :
sudo adduser {username} www-data Isso não funciona no OS X, e pode não ser a melhor abordagem de qualquer maneira. No OS X, como você pode fazer o Apache Iniciar ou parar sem ter que inserir uma senha?
On Ubuntu you can do something like this:
sudo adduser {username} www-data
That doesn't work on OS X, and may not be the best approach anyway. On OS X, how can you make Apache start or stop without having to enter a password?
terminal aberto e insira sudo visudo para modificar o arquivo / etc / sudoers .
Altere a parte:
## User privilege specification ## root ALL=(ALL) ALL %admin ALL=(ALL) ALL para
## User privilege specification ## root ALL=(ALL) ALL %admin ALL=(ALL) ALL your_username ALL=(ALL) NOPASSWD: /usr/sbin/apachectl e salve o arquivo.
Se você não sabe vi : depois de inserir sudo visudo você tem que mudar para o modo inserção batendo i . Digite a linha adicional conforme indicado acima. Para deixar Modo de inserção Hit ESC . Em seguida, insira : w q e a tecla inserir para gravar o arquivo modificado para o disco e sair VI.
. Iniciando e parando Apache com sudo apachectl start ou sudo apachectl stop
não requer mais uma senha.
apachectl requer raiz / sudo para executá-lo. Apenas o usuário root pode executar o comando sem inserir uma senha. Nem adicionar um usuário ao grupo de administrador nem para outro grupo (por exemplo _www) permite executar message0 sem senha.
Então, o método menos intrusivo é adicionar um usuário - até mesmo um usuário padrão - no arquivo sudoers e restringir a conta a executar / usr / sbin / apachectl somente. O usuário adicionado não é permitido executar qualquer outro comando como sudoer!
Open Terminal and enter sudo visudo
to modify the file /etc/sudoers.
Change the part:
## User privilege specification ## root ALL=(ALL) ALL %admin ALL=(ALL) ALL
to
## User privilege specification ## root ALL=(ALL) ALL %admin ALL=(ALL) ALL your_username ALL=(ALL) NOPASSWD: /usr/sbin/apachectl
and save the file.
If you don't know vi: after entering sudo visudo
you have to change to insert mode by hitting i. Enter the additional line as indicated above. To leave insert mode hit esc. Then enter :wq and the Enter key to write the modified file to disk and quit vi.
Starting and stoping Apache with sudo apachectl start
or sudo apachectl stop
doesn't require a password anymore.
apachectl
requires root/sudo to execute it. Only the root user can execute the command without entering a password. Neither adding a user to the admin group nor to another group (e.g. _www) allows to execute (sudo )apachectl
without password.
So, the least intrusive method is adding a user - even a standard user - in the sudoers file and restrict the account to execute /usr/sbin/apachectl only. The added user is not allowed to execute any other command as sudoer!
Eu não tenho a reputação de comentar (mas tenho o representante responder? Que sistema para trás), então isso é realmente uma resposta à resposta de Klanomath.
Eu só quero ter certeza de que as pessoas evitam corromper seu arquivo etc / sudoers como eu fiz (e tive que restaurar do time Machine Backup).
Não edite etc / sudoers de qualquer outra forma diferente de executar sudo visudo como Klanomath disse. Você provavelmente corromperá seu arquivo e não será capaz de executar sudo.
Outra dica: executar which apachectl para determinar o caminho para o Apache. O meu foi instalado via Homebrew para que o caminho seja diferente.
I don't have the reputation to comment (but I have the rep to answer? What a backwards system), so this is really a response to klanomath's answer.
I just want to make sure people avoid corrupting their etc/sudoers file like I did (and had to restore from Time Machine backup).
Do not edit etc/sudoers in any other way other than running sudo visudo
as klanomath said. You will likely corrupt your file and will not be able to run sudo.
Another tip: run which apachectl
to determine the path to Apache. Mine was installed via Homebrew so the path is different.
© 2022 pergunte.org All Rights Reserved. Casa de perguntas e respostas todos os direitos reservados