简体   繁体   English

如何在OS X Mavericks上控制apache2 Webroot?

[英]How to take control of apache2 Webroot on OS X Mavericks?

I have an apache2 server enabled on my Mac running Mac OS X 10.9 using the default WebRoot /Library/WebServer/Documents . 我在使用默认WebRoot /Library/WebServer/Documents运行Mac OS X 10.9的Mac上启用了apache2服务器。 However, whenever I try to add, edit, or delete a file from that directory in Finder logged onto an Administrator account the files are "Locked" no matter what I attempt, including the chmod command and Mac's Change Permission menu inside the "Get Info" window. 但是,每当我尝试在Finder中添加,编辑或删除该目录中登录管理员帐户的文件时,无论我尝试什么,文件都会被“锁定”,包括“获取信息”中的chmod命令和Mac的“更改权限”菜单“窗口。

I was wondering if anyone knows of a way to allow an Admin or any specific User account to edit the directory without opening up the entire Filesystem to all users. 我想知道是否有人知道允许管理员或任何特定用户帐户编辑目录的方法,而无需向所有用户打开整个文件系统。

Thanks :) 谢谢 :)

The easiest way to enable modification of the files within /Library/WebServer/Documents is to change the permissions from your shell to allow all users of your system to write to the directory. /Library/WebServer/Documents修改文件的最简单方法是更改​​shell的权限,以允许系统的所有用户写入目录。

  1. Open Terminal.app 打开Terminal.app
  2. Type the following: 输入以下内容:

    sudo chmod -R o+w /Library/WebServer/Documents

This command recursively changes the permissions using sudo . 此命令使用sudo递归更改权限。

The process of enabling the default apache installation has been relatively consistent since Apple removed the web sharing option in 10.7?. 由于Apple删除了10.7中的Web共享选项,因此启用默认apache安装的过程相对一致。 Here's a gist with a handful of bits and pieces related to the setup process. 这里有一个要点,其中包含与设置过程相关的一些零碎内容。

The right way to take control without messing up with the Mac permissions is to login as a "root administrator"; 在不弄乱Mac权限的情况下获得控制权的正确方法是以“root管理员”身份登录;

yourcomputer'sname:~ yourusername$ sudo tcsh
Password:

Do not worry, the password will not be transmitted...(visible as text). 别担心,密码不会被传输...(以文本形式显示)。 If this is your first time logging as a root administrator, you will see a welcome message and a caution message. 如果这是您第一次以root管理员身份登录,您将看到欢迎消息和警告消息。

After you have been logged in you will see only your computer name; 登录后,您将只看到您的计算机名称;

[yourcomputername:~] root#

Now be careful to do things from root in the terminal, read and follow the commands. 现在要小心从终端根目录做事,阅读并遵循命令。 Use the editor "nano". 使用编辑器“nano”。 Example: 例:

If you want to edit the index.html on /Library/WebServer/Documents, do this; 如果要编辑/ Library / WebServer / Documents上的index.html,请执行此操作;

[yourcomputername:~] root# nano /Library/WebServer/Documents/index.html

(Just grab the html page and drop inside of the terminal window will produce the path to the file.) (只需抓住html页面并放入终端窗口内部就会生成文件的路径。)

press, return and you will be seen something like; 按,返回,你会看到类似的东西;

 GNU nano X.X.X                      File: /Library/WebServer/Documents/index.html                                                   

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta content="text/html; charset=UTF-8" http-equiv="content-type">
...

You will see a cursor! 你会看到一个光标! Move the cursor up/down right/left using the arrow keys on the keyboard. 使用键盘上的箭头键向右/向左上/下移动光标。

Putting the cursor on before the letter and pressing the key "delete" will delete that letter or word. 将光标放在字母前面并按“删除”键将删除该字母或单词。 Press with caution because if you press down and do not release your finger it will run very fast. 请小心按下,因为如果按下并且不松开手指,它将会非常快速地运行。 Best is to experiment click by click first until you get used to. 最好是先点击一下点击,然后再习惯。

When you done; 当你完成;

Press "control o" and "return" to save it, then "control x" to exit.

To get out of root, type "exit" and you are out back to your; 要退出root,输入“exit”,你就会回到你的身边;

yourcomputername:~ yourusername$

As a root admin you can edit and do basically anything in your computer. 作为root管理员,您可以编辑并完成计算机中的任何操作。 You can even destroy the whole system. 你甚至可以摧毁整个系统。 So be careful. 所以要小心。 Read, learn and experiment with caution. 阅读,学习和谨慎实验。

To know more about the terminal and the nano editor; 了解终端和纳米编辑器的更多信息;

This article is about the Terminal command nano. 本文是关于终端命令nano的。 http://guides.macrumors.com/nano http://guides.macrumors.com/nano

The Nano Text Editor http://mintaka.sdsu.edu/reu/nano.html 纳米文本编辑器http://mintaka.sdsu.edu/reu/nano.html

Have fun! 玩得开心! E\\ Ë\\

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM