Sunday, January 8, 2012

Ubuntu Apache Dev Web Server Install


I'm investigating Yii, a PHP web framework, for some friends. We want to do a web project and they know at least some PHP. Since I don't want to do all the programming myself, PHP seems like a good option.

The first step is installing the Apache HTTP Server. While I have that self-same web server already installed on my machine as a service, I decided I wanted a development copy I could mess up and not hose my machine's install.

Going to the Apache download site, I see 2.2 is the latest stable version. I navigate to that page and find the Unix tarball to download. Once downloaded, I extract the file any old place.

Step 1 -  run 'configure' with your final install directory for Apache.
./configure --prefix=[Apache Install Dir] --enable-so
Lots of output follows. I recommend giving a full path vs. a relative path to the install directory. You can probably use either but you never know.

Step 2 - Now it's time to run 'make'.
make
Lots more output follows.

Now run 'make install'. This actually creates the server instance software in you install directory you picked in step 1.
make install
Now navigate to your Apache install directory. Since this is a development web server, we're going to change the default listing port to 8080. I do this so it won't interfere with an installed web server running on the default port of 80.
cd [Apache Install Dir]/Apache2.2/conf
Use your favorite editor, and open httpd.conf. Find the line 
Listen 80
Change it to
Listen 8080
You can substitute 8080 with any other open port. If you need to see if a port is open you can run
netstat -a
and look through the results to make sure your port isn't in use.

Now change directory to the Apache bin directory and run apachectl start. This starts your web server.

cd [Apache Install Dir]/Apache2.2/bin
./apachectl start
Now open a web browser and try
http://localhost:8080/
You should bet a message that says
It Works
If you get this pat yourself on the back and go get a cup of coffee smiling that you've successfully geeked for the day. If not, do what we professionals do, consult the all knowing Google search.

Coming up next, configuring Apache to run PHP.


No comments: