Apache server on Mac OS

Manage the Apache server

Terminal Commands

  • Starting:  $sudo apachectl start
  • Stopping: $sudo apachectl stop
  • Restarting: $sudo apachectl restart

Adding the Web Sharing option in Systems Preferences:
http://clickontyler.com/blog/2012/02/web-sharing-mountain-lion/

Configuring Sites folder

http://www.maketecheasier.com/setup-web-server-in-mountain-lion/

By default, Apache serves files that are in the folder location “/Library/WebServer/Documents”.
On a multiple users system, you can setup the web server to serve files for different users
using the URL “http://localhost/~tomeu.mir“.

1. create a folder Sites in /Users/tomeu.mir
$mkdir /Users/tomeu.mir/Sites

2. create a tomeu.mir.conf file in the apache server users folder:
$sudo vi /etc/apache2/users/tomeu.mir.conf

and copy and paste the following code to the conf file.

<Directory “/Users/tomeu.mir/Sites/”>
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>

3. test it

create a test html file and place it in /Users/tomeu.mir/Sites/

$cd /Users/tomeu.mir/Sites/
$vi myTest.html

insert your html test code and save it.

<html><body><h1>My site works cojones</h1></body></html>

Go to your browser and type: http://localhost/~tomeu.mir/myTest.html

 

Advertisements

One thought on “Apache server on Mac OS

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s