php forum
php mysql forum
php mysql smarty
 
Topic Options
#286365 - 03/04/02 05:08 PM Tutorial: Setting up your own Web server
The Team Offline
Moderator

Registered: 08/11/00
Posts: 182
Loc: yes

   Tutorial: Setting up your own Web server to Del.icio.us Add to del.icio.us
  Digg Tutorial: Setting up your own Web server Digg it
<img src="http://www.ubbdev.com/columns/tackaberry/art/uzine/apache.gif" style="border: 1px black solid" align="left" alt="web server tutorial">
Article: Setting up your own Web Server
Tutorial by: Matt Jacob

<h1>Setting up your own Web server</h1>
<h2>Who should read this series?</h2>
Anyone who wants to have a fully-functioning Web server operating on their own computer should read this series. There are a few important benefits to having your own server, including:
  • You can test your scripts and applications without having to upload them;
  • You can create a personal Web site to share with friends and family;
  • You can possibly save hundreds of dollars a year on hosting*.

<h2>What will you learn in this series?</h2>My goal here is not to make you an expert on all possible aspects of server technology. All I want to do is teach you how to install and run a server locally, on your own computer. Here's what you'll learn:
  • How to install and configure Apache 2.0.39;
  • How to install and configure ActivePerl 5.6.1;
  • How to install and configure PHP 4.2.1;
  • How to install and configure MySQL 3.23.51;
  • How to make your server accessible to the world using dynamic DNS;
  • Necessary security cautions to take in order to protect your computer;
  • Note: version numbers above are current as of 7/5/02**.

<h2>Conventions used in this series</h2><code>Constant width</code> is used to indicate HTML tags, code examples, and keyboard commands

<kbd>Constant width bold</kbd> is used to indicate on-screen labels and user-entered text

<em>Italicized text</em> is used to indicate filenames, directory names, and URLs

<h2>Minimum system requirements</h2>
There are a few prerequisite items that you need to meet before you go any further.

First, these instructions are geared to Windows users only. Sorry if you're a Mac person--I like 'em too--but this series just isn't for you. Second, you need to have either Windows 2000 or Windows XP Professional installed, but nothing earlier. <em>And absolutely no Win95, Win98, or WinME</em>. I'll be using Windows 2000 with Service Pack 2, but I assure you that XP also works just fine. Third, you need to be able to download and unzip files, some of which are quite large. I estimate the combined size of the downloads at about 30 megabytes, so access to a broadband connection will come in handy.

Got all that? Let's get ready to roll!

Page 1: <a href="http://www.ubbdev.com/db/ultimatebb.php?ubb=get_topic;f=2;t=000032;p=2">Installing and configuring the
server</a>
<h2>Table of contents</h2>
  1. Installing and configuring the server
  2. Installing the Perl package
  3. Manually installing the PHP package
  4. Installing MySQL as a service
  5. Final comments and instructions

*This is actually only feasible if you have a broadband connection, and even then it's a little sketchy. Some ISPs don't allow you to run a HTTP server through their connection, so please check with <em>your</em> ISP before advertising that your server is accessible to the outside world.

**That date would be July 5, 2002 for the uninformed.

Contact: <em>matt@mattjacob.org</em>
AOL Instant Messenger: mattjacob1

Top
#286366 - 07/10/02 10:46 AM Re: Tutorial: Setting up your own Web server
The Team Offline
Moderator

Registered: 08/11/00
Posts: 182
Loc: yes
<h1>Installing and configuring the server</h1>
<h2>Downloading Apache for Windows</h2>
First things first!

You can find the binary of Apache 2.0.39 for Windows at:
<em>http://www.apache.org/dist/httpd/binaries/win32/</em>
[<a href="http://www.apache.org/dist/httpd/binaries/win32/apache_2.0.39-win32-x86-no_ssl.msi">direct link</a>]. The file is 3.2 MB, and is distributed as an MSI package.
<h2>Installing Apache</h2>
Open the file you just downloaded and read the prompts until you get to a screen
that looks like the one below. Fill in the information as I have, and then
enter your own email address in the last box.



The rest of the installation prompts are self-explanatory, so all you have
to do is pick a directory to install to and then wait for the installer to
finish. I recommend installing Apache to a separate partition
or drive in order to keep things neat and clean (if that's an option for you).
I should also mention that unless you choose otherwise, <em>Apache2</em> will
be appended to all folder paths. This means that if you install to something
like <em>H:Apache</em>, it'll actually get installed to <em>H:ApacheApache2</em>.
I guess it's just one of those weird idiosyncrasies that everyone loves.

Having done all that, open your browser and type <em>http://127.0.0.1/</em>.
If you see a page that looks like the one below, you may sit back and relax,
knowing that half the battle is already over.



If you don't see that page, uninstall Apache, and then start over, making sure
to read each prompt carefully. If you still can't get it to go after trying,
say, ten more times, email me and I might be able to help you out. Alternatively,
you can peruse the Apache help docs, located at <em>http://httpd.apache.org/docs-2.0/</em>.
<h2>Configuring Apache</h2>
And now comes the fun part.
<h3>Opening the httpd.conf file for editing</h3>
Click on <kbd>Start</kbd>, then <kbd>Apache HTTP Server 2.0.39</kbd>, then
<kbd>Configure Apache Server</kbd> and finally <kbd>Edit the Apache httpd.conf
Configuration File</kbd>. This will open up the <em>httpd.conf</em> file in
<kbd>Notepad</kbd> so that we can edit it. Know that if you make any huge
mistakes while editing this file, there's always a backup
copy available for you, and it's located in your <em>H:Apache2conf</em>
folder. The backup is named <em>httpd.default.conf</em>.
<h3>Setting up some basic values</h3>
Search for <code>DocumentRoot</code> and then change it from <code>DocumentRoot
"H:/Apache2/htdocs"</code> to wherever you want to keep your site's
HTML files. Mine is <code>DocumentRoot "H:/httpdocs"</code>, because
I have my HTML files located at <em>H:httpdocs</em>. Now search for <code><Directory
"H:/Apache2/htdocs"></code> and change that path to the same
as the previous one you picked out.
<h3>Turning on Server-Side Includes</h3>
If you don't know what SSIs are, or you just don't want to use them, you can
safely skip over this section. Otherwise, this is what you need to do in order
to turn site-wide SSIs on.

Search for <code>Options Indexes FollowSymLinks</code> and change it to <code>Options
All MultiViews</code>. Then, search for <code>#AddOutputFilter INCLUDES .shtml</code>
and change it to <code>AddOutputFilter INCLUDES .html .htm .shtml .shtm</code>.

Note: you can customize that last bit to your liking, if you
wish. If you don't want all files with the extensions <em>.html</em>
and <em>.htm</em> to be parsed, remove <code>.html</code> and <code>.htm</code>
from the list. If you want any other file extensions besides the ones I've
added to be parsed, add them in the same manner to that list.
<h2>Restarting Apache</h2>
Restarting Apache is easy to do, and it will need to be done whenever you make
any changes to the configuration file (<em>httpd.conf</em>). Because the file
gets read only when Apache starts, new changes won't take effect until you
restart Apache. Double-click the <kbd>Apache Service Monitor</kbd> icon in
the system tray (it's the one that looks like a feather with a green triangle
on it) to open the monitor. Now just click the <kbd>Restart</kbd> button and
wait for Apache to do it's thing.

After the server has been restarted, you'll see a message letting you know
that the changes went through successfully. If you made a major error editing
the file, Apache will let you know about it with an error message.



Page 2: Installing the Perl package

Top
#286367 - 07/10/02 10:48 AM Re: Tutorial: Setting up your own Web server
The Team Offline
Moderator

Registered: 08/11/00
Posts: 182
Loc: yes
<h1>Installing the Perl package</h1>
<h2>Downloading ActivePerl for Windows</h2>
You can find the binary of ActivePerl 5.6.1 for Windows at:
<em>http://www.activestate.com/Products/Download/Get.plex?id=ActivePerl</em>
[<a href="http://downloads.activestate.com/ActivePerl/Windows/5.6/ActivePerl-5.6.1.633-MSWin32-x86.msi">direct link</a>]. The file is 8.6 MB, and is distributed as an MSI package.
<h2>Installing ActivePerl</h2>
Start the installer, and then click through it (hopefully reading the prompts
along the way) until you get to a screen that looks like the one below.



I highly advise that you install Perl to a directory similar
to mine, which is <em>H:usr</em> (yours needs to be whatever drive you have
Apache installed on, i.e. <em>C:usr</em> or <em>D:usr</em>). This is quite
helpful if you also have a Unix or Linux Web server, because then the Perl
path (the first line of any Perl file, usually <code>#!/usr/bin/perl</code>)
will remain the same no matter what. Look at the screen below to see what
I mean regarding installation paths.



Continue to set up Perl until you get to the screen below, for which you should
make your options the same as mine.



Finish the installation by following the rest of the prompts, then continue
on to the next section when you're done.
<h2>Testing the Perl installation</h2>
Create a new blank document in <kbd>Notepad</kbd>, and then copy and paste
the code below into the file.
Code:
#!/usr/bin/perl
print "Hello, World";


Save the file as <em>C:hello.pl</em>. Start up the <kbd>Command Prompt</kbd>
and wait until you see <samp>C:></samp>. Type <kbd>perl hello.pl</kbd>,
hit <samp>Enter</samp>, and you should see <samp>Hello, World</samp>. If you
see this, this means that Perl was installed successfully!


<h2>Allowing Perl to run freely</h2>
Back in your <em>httpd.conf</em> file, search for <code>ScriptAlias /cgi-bin/
"H:/apache/cgi-bin/"</code> and change it to <code>#ScriptAlias
/cgi-bin/ "H:/apache/cgi-bin/"<em></em></code><em>.</em> Now find
<code>#AddHandler cgi-script .cgi</code> and change it to <code>AddHandler
cgi-script .cgi .pl</code>. What we've done here is allowed Perl to run from
any directory, and also for files with the extension <em>.pl</em> to be treated
as Perl files (which they should be!).

You'll need to restart Apache for these new changes to take
effect (see the previous page for information on how to restart Apache).
<h2>Testing Web-based Perl</h2>
Create a new blank document in <kbd>Notepad</kbd>, and then copy and paste
the code below into the file.
Code:
#!/usr/bin/perl
print "Content-type:text/htmlnn";
print "Hello, World";


Save the file as <em>H:httpdocshello.cgi</em> and then go to <em>http://127.0.0.1/hello.cgi</em>
in your browser to test that it works. If you see what I see (screen shot
below), give yourself a pat on the back!



Page 3: Manually installing the PHP package

Top
#286368 - 07/10/02 11:16 AM Re: Tutorial: Setting up your own Web server
The Team Offline
Moderator

Registered: 08/11/00
Posts: 182
Loc: yes
<h1>Manually installing the PHP package</h1>
<h2>Downloading PHP for Windows</h2>
You can find the binary of PHP at <em>http://www.php.net/downloads.php</em>
[<a href="http://www.php.net/do_download.php?download_file=php-4.2.1-Win32.zip">direct link</a>]. The file is 5.2 MB, and is distributed as a single zipped file.
<h2>Installing PHP</h2>
Extract the zip file to a directory of your choice. I put mine at <em>H:php</em>.
Some servers might crash if there's a space in the path name (i.e. <em>H:My
3l33t PHP Installation</em>), so try to steer clear of that.
<h3>Copying required files</h3>
You'll need to copy the file <em>php4ts.dll</em> to your <em>C:WINNTsystem32</em>
folder (or <em>C:Windowssystem32</em> for Windows XP). Also copy the file
<em>php.ini-recommended</em> to your <em>C:WINNT</em> folder (or <em>C:Windows</em>
for XP) and rename it to just plain ol' <em>php.ini</em>.
<h3>And now for more file copying</h3>
Due to some changes in the working of Apache 2.0.39, the standard PHP DLL file
for Apache2 will no longer function "out-of-box." This can be solved
easily, by downloading <em>http://www.ubbdev.com/files/php4apache2.dll</em>
[<a href="http://www.ubbdev.com/files/php4apache2.dll">direct link</a>]. Save
and copy that file to your <em>H:phpsapi</em> directory, overwriting any
existing file. Life is good--for the moment, at least.
<h2>Editing your php.ini</h2>
Open up your newly copied and renamed <em>php.ini</em> file. Search for <code>extension_dir
=</code> and change it to read <code>extension_dir = H:phpextensions</code>
(making sure to modify it to reflect <em>your</em> actual path). Search for
<code>doc_root =</code> and change it to <code>doc_root = H:httpdocs</code>
where the path is the same as the one you picked for your HTML files back
in step one. Sounds easy enough, right?

We'll leave the rest of the file alone for now, but if you'd like to modify
more on your own, read up at <em>http://www.php.net/manual/en/configuration.php</em>.
<h2>Apache, meet PHP</h2>
We're going to run PHP as a module for Apache, instead of as a CGI binary,
because it's more transparent and secure. And you really care about that,
right? You're just waiting for me to get to the good stuff, so here we go.

Open up your <em>httpd.conf</em> file again (it's the last time, I promise)
and search for <code>#LoadModule ssl_module modules/mod_ssl.so</code>. Directly
underneath that line, add <code>LoadModule php4_module H:/php/sapi/php4apache2.dll</code>.

To try to keep all the "scripting stuff" in the same spot of my <em>httpd.conf</em>
file, I put the remaining lines necessary for PHP near the line we modified
in order to use Perl before. Search for <code>AddHandler cgi-script .cgi .pl</code>
and then add this block of code a line or two below that.
Code:
#
# To use PHP scripts:
#
AddType application/x-httpd-php .php .php3 .phtml
AddType application/x-httpd-php-source .phps


The final section around that block should look like mine, which is below.
Code:
#
AddHandler cgi-script .cgi .pl

#
# To use PHP scripts:
#
AddType application/x-httpd-php .php .php3 .phtml
AddType application/x-httpd-php-source .phps

#
# For files that include their own HTTP headers:

<h3>Restarting the server</h3>

After making the outlined changes to <em>httpd.conf</em>, save and close the
file. Then, double-click the <kbd>Apache Service Monitor</kbd> icon in the
tray to pop open--you guessed it--the Apache Service Monitor! Click the <kbd>Restart</kbd>
button and then wait a few seconds while Apache shuts down and starts back
up.

When the server comes back online, your screen should look like mine; also
take note of the text at the bottom of the window that reads <kbd>Apache/2.0.39
(Win32) PHP/4.2.2-dev</kbd>. This just means that all is well in Apache land.


<h2>Your first PHP script</h2>
Copy 'n paste
Code:
[/code]into a new file in <kbd>Notepad</kbd> and then save it as<em> H:httpdocsphpinfo.php</em>. To recap, the entire file should read [code]
Now browse to <em>http://127.0.0.1/phpinfo.php</em> and check to make sure
that what you see looks like my screen shot below.



If you can't see this screen, you hit a bump in the road somewhere along the
way. Your first move should be to visit <em>http://www.php.net/manual/en/install.apache.php</em>.
Start by reading the newest comments (the ones at the very bottom of the page)
to check if your problem has already been encountered by another user.
<h2>Enabling compressed output</h2>
Optionally, you can choose to compress PHP output using zlib compression.
This cuts down on your bandwidth and also helps pages to load faster. If you'd
like to turn zlib on, just follow the steps below.

According to the zlib Web site (http://www.gzip.org/zlib/), zlib is "a
free, general-purpose, legally unencumbered--that is, not covered by any patents--lossless
data-compression library for use on virtually any computer hardware and operating
system." So there you have it, straight from the horse's mouth. Let's
turn it on already, shall we?

In <em>php.ini</em>, search for <code>zlib.output_compression = off</code>
and change it to read <code>zlib.output_compression = on</code>. All you have
to do next is search for <code>;extension=php_zlib.dll</code> and change the
line to read <code>extension=php_zlib.dll</code>. Browse to <em>http://127.0.0.1/phpinfo.php</em>
once more and then scroll down to the section about zlib. You should see what
I see.



Page 4: Installing MySQL as a service

Top
#286369 - 07/10/02 11:20 AM Re: Tutorial: Setting up your own Web server
The Team Offline
Moderator

Registered: 08/11/00
Posts: 182
Loc: yes
<h1>Installing MySQL as a service</h1>
<h2>Downloading MySQL for Windows</h2>
You can find the binary of MySQL at:
<em>http://www.mysql.com/downloads/mysql-3.23.html</em>
[<a href="http://www.mysql.com/Downloads/MySQL-3.23/mysql-3.23.51-win.zip">direct link</a>]. The file is 12.1 MB, and is distributed as a single zipped file.
<h2>Installing MySQL</h2>
I love installing MySQL because of its straightforwardness. It's a nice break
from all this configuration file mumbo jumbo that we've been working with.
All you need to do is unzip the <em>mysql-3.23.51-win.zip</em> file to a folder
(<em>C:Temporary</em> for all I care) and then execute the <em>setup.exe</em>
program. I'd guess that the hardest part of the entire installation is deciding
<em>where</em> you want to install to. I picked <em>H:mysql</em>, but you
can choose whatever you want.


<h2>Configuring MySQL</h2>
<h3>Editing your my.ini</h3>
Create a new file in <kbd>Notepad</kbd> and copy these three lines into it.
Code:
[mysqld]
basedir = H:/mysql/
datadir = H:/mysql/data/


Change the <code>basedir</code> and <code>datadir</code> to suit your actual
installation, using mine as a model. Then, save the file as <em>my.ini</em>
and place it in your <em>C:WINNT</em> directory, so that the full path of
the file is <em>C:WINNTmy.ini</em>. You can close the file now.
<h3>Running as a service</h3>
Start up the <kbd>Command Prompt</kbd> and wait until you see <samp>C:></samp>.
Switch to the drive you installed MySQL to by typing <kbd>h:</kbd> and then
<samp>Enter</samp>. To switch to MySQL's <em>bin</em> directory, type <kbd>cd
mysqlbin</kbd> and hit <samp>Enter</samp>. To install MySQL as a service
under Windows 2000/XP, type <kbd>mysqld-nt -install</kbd> and hit <samp>Enter</samp>.

You should see a screen similar to the one below, with a message letting you
know that the service was successfully installed.



At this point, you can restart your computer. You <em>could</em> forge ahead
without restarting by typing <kbd>net start mysql</kbd> and then pressing
<samp>Enter</samp>. What you'll see is a message confirming that the MySQL
service was started successfully. It looks strikingly and amazingly similar
to the one below.


<h3>Messing with the settings</h3>
To change the default MySQL password, enter the <kbd>mysqladmin -u root password
"myNewPass1488"</kbd> command from the <em>H:mysqlbin</em> directory.
Change <samp>myNewPass1488</samp> to a <em>real</em> password of your choosing.
To make sure that the change went through, type <kbd>mysqladmin -u root reload</kbd>
and hit <samp>Enter</samp>. What you want is a message telling you that access
was denied.



Let's just play with one more thing before calling it a night (which has no
doubt turned back into day by now). Type <kbd>mysqladmin -u root -p status</kbd>
and press <samp>Enter</samp>, and then type in your password when prompted.
You'll see some basic information about the currently-running service.



To shut down MySQL, type <kbd>mysqladmin -u root -p shutdown</kbd> and hit
<samp>Enter</samp>. Enter your password, press <samp>Enter</samp> again, and
then close the <kbd>Command Prompt</kbd> window. And that's that for MySQL!

Page 5: Final comments and instructions

Top
#286370 - 07/10/02 11:21 AM Re: Tutorial: Setting up your own Web server
The Team Offline
Moderator

Registered: 08/11/00
Posts: 182
Loc: yes
<h1>Final comments and instructions</h1>
<h2>Sitting through this series</h2>
If you've gotten this far, I congratulate and commend you,
brave soldier! I know that this subject matter is not exactly on the same
"fun level" as riding a roller coaster, but I tried to keep it as
straightforward and to-the-point as I possibly could. By now, you should be
able to walk away with a fully-functioning, feature-packed, somewhat-secure
(just kidding on that one) Web server of your very own to play with.

As your guide through the rough terrain, I can look back and rest easy tonight
knowing that someone with the very same questions as me will now have answers
to [some of] them.
<h2>What to do with this guide</h2>
You could:
  • </font></li>
  • Print it out for reference;
  • Save it to your hard drive;
  • Give it to your niece as a Christmas present;
  • Let your dog relieve hims--nevermind.

If you found this series useful, spread the word by emailing your friends,
posting a link back to it in your blog, or even writing a short blurb on your
site about it.
<h2>Going live with it all</h2>
<h3>Everyone loves .coms</h3>
If you have a broadband (cable, DSL, T1) connection to the Internet, you've
probably got this crazy notion in your head that you can just leave your computer
on all the time and start printing your IP address on your business cards
in place of a URL. Well, you <em>could</em> do that, but I've got a better
idea.

I suggest you read about DNS2Go at <em>http://dns2go.deerfield.com/</em>.
The program is free to download and use, and you can even get a free subdomain
of your choice when you sign up. If you've already got your own FQDN (Fully
Qualified Domain Name), you can even use that, too! There are far too many
good features of DNS2Go to list here, so instead of trying, I'll just remind
you to check out that URL above.
<h3>Server security concerns</h3>
If you're planning on making your computer available to the world 24/7, you're
going to need some protection for it. Luckily, half the work has already been
done, because we're using Apache instead of IIS. However, there are a few
more products you'll need to obtain in order to have some system security.
I recommend getting:
  • A hardware firewall (Linksys makes an excellent router/firewall);
  • A software firewall program, such as ZoneAlarm by Zone Labs;
  • <font size="2" face="verdana, arial, helvetica, sans-serif">A good anti-virus program, such as Norton AntiVirus by Symantec.

Also make sure that Windows is fully patched and that your virus definition
files are up-to-date. IE6 is notorious for having gaping security holes, so
just keep an eye out for any alerts or warnings you read.
<h2>The inevitable © garbage</h2>
All I ask is that you don't slap your name on the front page and publish this
guide elsewhere to gain quick recognition from your friends and family. If
you want to re-publish this on any site or actually anywhere, for that matter,
please just get my permission first by dropping me a line. I'd be more than
happy to help you out.

Thanks for investing your time by listening to my drivel, and I hope this has
been as much fun for you as it was for me!

Back to: <a href="">Index & Table of contents</a>

Top


Who's Online
0 Registered (), 39 Guests and 6 Spiders online.
Key: Admin, Global Mod, Mod
Shout Box

Latest Posts
Blogs, love em or hate em?
by Ian_W
Yesterday at 03:47 PM
What do you use to edit the files
by Ian_W
Yesterday at 03:33 PM
BeyondCompare v3.00
by Ian_W
Yesterday at 03:32 PM
Glossy Black Theme with Image Reflection
by Gizmo
Yesterday at 02:17 PM
ShareThis
by Gizmo
09/28/08 05:06 AM
[7.3] Viewing MySQL logfiles made easier
by AllenAyres
09/27/08 09:57 PM
Looking for a simple upload script
by Murphdog
09/26/08 08:45 PM
New Mods
[7.3] Viewing MySQL logfiles made easier
by blaaskaak
09/24/08 05:39 PM
[7.3] Language file checker
by blaaskaak
09/09/08 12:56 AM
[7.3.1] add search to showmembers page
by blaaskaak
09/07/08 04:50 AM
Multiple Identity Detector
by
12/30/06 06:39 PM
Newest Members
ghengis317, NitroX, Dogan, EliYah-, W-D
13344 Registered Users
Top Posters Last 30 Days
AllenAyres 16
blaaskaak 13
FREAK1 7
Mike L_dup1 4
Chris Bale 4
Ian_W 4
tackaberry 3

 

 

 
fusionbb message board php hacks