[Webtech] Messing with apache

We made it to server-side scripting with PHP. The professor said the people with Mac are lucky, got everything installed for them, just need to activate it. Hmm, I got a Mac too….

* Enable PHP :

#uncomment ‘Load php5module … ‘ from /etc/apache2/httpd.conf > All set

Open localhost and see It works, the hello world of Apache.

* The problem with DocumentRoot :

However, the DocumentRoot is set at “/Library/WebServer/Documents/” but my codes are in different location and I don’t want to copy my new codes to the path…..

One solution comes up to my mind is to do symbolic link the codes to documents, which does not work : ln -s /Library/WebServer/Documents /path/to/new/codes ( It shows permission error even though all the files are 755. Some guys said I have to do chmod 755 on parents folder as well as the path; in other words, chmod recursively ).

Why don’t you set DocumentRoot to the new paths instead ? Well, I should but I want to keep the default path. What I want is to point my codes to the new path after localhost,i.e something like localhost/HW6 it will point to HW6 real codes folder. Enter Alias:

<VirtualHost *:80>

ServerAdmin sth@sth.com

DocumentRoot /NewRoot

Alias /HW6 /HW6 Folder/  #Note: ‘/’ is a-must. Leave out the ‘/’ and it will not work.

#Aliasing later HW following

<Directory “/NewRoot”>

Options None

AllowOverride None

Require all granted #Apache 2.4 syntax


ErrorLog /logpath/error.log


Works OK so far…..( Keeping everything intact )


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 )

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s