简体   繁体   中英

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 . 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.

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.

  1. Open Terminal.app
  2. Type the following:

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

This command recursively changes the permissions using sudo .

The process of enabling the default apache installation has been relatively consistent since Apple removed the web sharing option in 10.7?. 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";

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.

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". Example:

If you want to edit the index.html on /Library/WebServer/Documents, do this;

[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.)

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;

yourcomputername:~ yourusername$

As a root admin you can edit and do basically anything in your computer. 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. http://guides.macrumors.com/nano

The Nano Text Editor http://mintaka.sdsu.edu/reu/nano.html

Have fun! E\\

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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