Setting up your own server

DON'T post new tutorials here! Please use the "Pending Submissions" board so the staff can review them first.
User avatar
CommonStray
Forum Assassin
Forum Assassin
Posts: 1214
Joined: 20 Aug 2005, 16:00
15

Setting up your own server

Post by CommonStray »

Whats up everyone Circuitbomb here, and well after a long interesting night of setting up my own server here on my home network, ive decided to tell you how i did it (on a Windows machine NT/2000/ME/XP, so that you can do it as well. so lets get started.


mind you ive been up all night so if this seems choppy i apologize...

Overview:

What we are going to do is set up a webserver, that, will run php, mysql, perl and cgi scripts.

First and foremost you want the webserver, the one i used and that i recommend is Apache HTTP Web Server

www.apache.org - I downloaded the win32 MSI package

When you goto install the server youll be asked for some info

Network Domain:
Server Name: l
Admin Email:

Enter as follows:

localhost
127.0.0.1
your e-mail address


Once installed, open the Apache Monitor and make sure its running
(run it as a service during install)

goto start->Apache HTTP Server-> Configure Apache Web Server->Edit Configuration File

this opens notepad and your config file
Find DocumentRoot and enter in the dir that you will be keeping your files in

like this E:/dir (use the backlash)

scroll down and Find <Directory =
and enter in the same dir that you used for your DocumentRoot

put an index.html page in that directory


goto Apache Monitor and restart

test it by going to http://localhost or http://127.0.0.1 in your web-browser

if you see your index page good its working

-------now to install CGI/PERL-----------

Get ActivePERL from www.activestate.com

Install ActivePERL to a directory named e:\usr (it dont HAVE to be that name but its recommended)

have the "add Perl to the PATH environment variable" checked
and "Create Perl file extension association" checked

open your Apache Config File like above

Find Options Indexes FollowSymLinks

add ExecCGI to the end of it

so it looks like Options Indexes FollowSymLinks ExecCGI

Next, Find ScriptAlias /cgi-bin/ "E:/Apache2/cgi-bin/"

hash it out by adding a # in front of that line

Next, Find #AddHandler cgi-script .cgi

Remove the hash and .pl to the end

like this : AddHandler cgi-script .cgi .pl

Test CGI/PERL: open a new notepad document and paste in

#!e:/usr/bin/perl
print "Content-type:text/html\n\n";
print "hello world";

where the top line is where perl.exe is installed

save as either test.cgi or test.pl

put into your DocumentRoot Directory

goto Apache Monitor and restart

goto http://127.0.0.1/test.cgi or http://localhost/test.pl
whichever you named the filetype

If you see the words Hello world, good its working

--------installing PHP------------------

goto www.php.net and get the zipped version of PHP that is Win32/Apache compliant

unzip and goto the directory you unzipped it to and rename php.ini-dist it to php.ini

open php.ini

Find doc_root = "e:\public_html" and change it to whatever your DocumentRoot is

Find extension_dir = "./"
change it to the ext folder that unzipped with php
kinda like E:/php/ext

Now open you Apache Config File again and paste

LoadModule php5_module "e:/php/php5apache2.dll"
AddType application/x-httpd-php .php
PHPIniDir "e:/php"

in the beginning or end of the config file, make sure to change the paths to the relevant ones where you unzipped php

save and goto Apache Monitor and reset

open up a new notepad put in

<?php
phpinfo();
?>

save as test.php in your DocumentRoot

goto it in your webbrowser

if you see a bunch of stuff, its working

---------Installing MySQL --------

goto http://dev.mysql.com/downloads/mysql/4.1.html and download the version for Windows

install the MSI and choose these

Typical Setup
Skip Sign-Up
make sure "Configure the MySQL Server now" is checked
Detailed Configuration"
Developer Machine"
Multifunctional Database"
InnoDB Tablespace Settings" - leave the same
Decision Support (DSS)/OLAP"
make sure "Enable TCP/IP Networking" is checked and leave the port number at 3306
Standard Character Set
check "Install As Windows Service"
"Include Bin Directory in Windows PATH" checked
enter root password
dont let remote access
hit "execute" and it'll install and set up.

Copy the libmysql.dll from your php directory to your system folder(usually system or system32)

open your php.ini file

Find ;extension=php_mysql.dll and remove the semi-colon

goto Apache Monitor and restart

to test yor MySQL by php

make a new notepad file and paste

<?php
// hostname or ip of server (for local testing, localhost should work)
$dbServer='localhost';

// username and password to log onto db server (what you entered in Step 4)
$dbUser='root';
$dbPass='';

// name of database (what you created in step 4)
$dbName='test';

$link = mysql_connect("$dbServer", "$dbUser", "$dbPass") or die("Could not connect");
print "Connected successfully<br>";
mysql_select_db("$dbName") or die("Could not select database");
print "Database selected successfully<br>";

// close connection
mysql_close($link);
?>

save it as sqltest.php in yor documentroot folder

load it in your browser if you see it you know its working

later on when ive had some rest ill tell you how to set phpMyAdmin so you can better have control over your MySQL databases ;) till then

zzzzzzzzzzzzzzzzz

User avatar
Merchant
suck-o-fied!
suck-o-fied!
Posts: 70
Joined: 30 Oct 2005, 17:00
15
Location: In the shadows of your mind...
Contact:

Post by Merchant »

Hey CircutB0mB, does the server work wtih html script too???? 8O

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11598
Joined: 06 Apr 2005, 16:00
16
Location: The zone.
Contact:

Post by bad_brain »

Sure, Merchant... :wink:
PHP is great for dynamic websites and database interaction, but of course a HTML-document works properly too. you only need Apache (or any other server, but Apache is the best anyway ) for this job. all you have to do is to place the .html or .htm-file(s) in the document root-folder.
oh,and HTML is no scripting language btw, it´s a markup language...:wink:

great post btw, Circuit... :)

User avatar
CommonStray
Forum Assassin
Forum Assassin
Posts: 1214
Joined: 20 Aug 2005, 16:00
15

Post by CommonStray »

thnx bad_brain, yea Merchant i failed to mention you dont need mysql, php, cgi and all that jazz to run a website, the apache Server is all you need, thats the foundation for the other stuff, everything else is for making a site dynamic

User avatar
Merchant
suck-o-fied!
suck-o-fied!
Posts: 70
Joined: 30 Oct 2005, 17:00
15
Location: In the shadows of your mind...
Contact:

Post by Merchant »

sweet, thanx all. hm, i got a cool site job tha other day, i used to make them from Earthlink, but its great to know a better way!

See yall round

User avatar
Decipher
forum buddy
forum buddy
Posts: 10
Joined: 08 Dec 2005, 17:00
15

Post by Decipher »

That was a great post, i know how to do that all in windows, but i wanna set up a http proxy server (apache) in a linux enviroment and have all that enabled(php, mysql, perl etc) but im not to sure how to do it? if anybody gets time can someone convert this to linux os? like suse...

User avatar
CommonStray
Forum Assassin
Forum Assassin
Posts: 1214
Joined: 20 Aug 2005, 16:00
15

Post by CommonStray »

well ill tell you i havnt done this in Linux yet (bad_brain can you pick up on this?) anyways if you want to do thism its esy enough to goto each of the websites for each thing that ive posted (apache, php, mysql etc...) and download the linux compatible versions, each comes with installation doc's so it may not be TO hard :lol:

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11598
Joined: 06 Apr 2005, 16:00
16
Location: The zone.
Contact:

Post by bad_brain »

bad_brain´s little setting-up-Apache-as-a-proxy-tut :)

-create a directory named proxy in home

-create 3 subdirectories in proxy named:
-cache
-proxy
-inter //not neccessary, for testing

-create a file named run in /home/proxy/proxy:
httpd -d/home/proxy/proxy -f/home/proxy/proxy/conf/httpd.conf

don´t forget to give this file the appropriate rights with chmod.

-create subdirectories in both proxy and inter:
-conf
-htdocs
-logs

-now copy httpd.conf into /home/proxy/proxy/conf

-now edit httpd.conf

Code: Select all

                     User >username<
                     Group >groupname<
                     Servername >name or IP<
                     Port >Port your Proxy should run on<
                     ProxyRequests on
                     CacheRoot /home/proxy/cache
                     CacheSize >Size of Cache in kb<
                     ServerRoot /home/proxy/proxy

------// for testing, not neccessary--------------------

-k,now we setup Apache a 2nd time which acts as the internet to see how it works, copy httpd.conf (the original one) to /home/inter/conf and edit it:

Code: Select all

                     User >username<
                     Group >groupname<
                     Servername >Ip or name<
                     Listen >serverIP<:80
                     DocumentRoot /home/proxy/inter/htdocs
-copy the run-file to inter

-chmod run

-place a index.html into inter/htdocs



-now stop Apache and start the proxy and the "internet" with the run-files.

-change your proxy-settings in the browser, you should be able to view the html-document you´ve placed in htdocs.
to make sure the proxy works just enter an unknown adress and you should get an proxy-error... :wink:

User avatar
Decipher
forum buddy
forum buddy
Posts: 10
Joined: 08 Dec 2005, 17:00
15

Post by Decipher »

thanks man, gave me a kick start in my web server, nice reply :D

User avatar
Wok
Newbie
Newbie
Posts: 3
Joined: 07 Dec 2005, 17:00
15
Contact:

Post by Wok »

Here's a cool little app I've used before that combines quite a few things in one install...

Image
http://www.apachefriends.org/en/xampp-windows.html

PHP, mySQL, Apache, CGI, Mercury Mail, FileZilla...and has add-ons for Perl, Python and Tomcat. It's pretty easy to install and setup...and their website has pretty good tutorials with pics for help with setup.

User avatar
CommonStray
Forum Assassin
Forum Assassin
Posts: 1214
Joined: 20 Aug 2005, 16:00
15

Post by CommonStray »

yea i tried that one...the only reason why i didnt end up using it is because i was having problems running the Apache Server within it, the MYSQL worked fine

so i just wanted to do it the ol fashioned way...

User avatar
Merchant
suck-o-fied!
suck-o-fied!
Posts: 70
Joined: 30 Oct 2005, 17:00
15
Location: In the shadows of your mind...
Contact:

Post by Merchant »

Hey CircutB0mb, what does the apache server cost?

User avatar
CommonStray
Forum Assassin
Forum Assassin
Posts: 1214
Joined: 20 Aug 2005, 16:00
15

Post by CommonStray »

the Apache HTTP Web Server is Free of charge.

you can download it at

http://httpd.apache.org/

User avatar
ilugd
Newbie
Newbie
Posts: 3
Joined: 15 Dec 2005, 17:00
15

Post by ilugd »

Well over here in India, most of us use Easy PHP (Windows). Quite simple to install really and has perl, php, mysql and ofcourse apache. Don't know really if it is comparitively better to the other options.

User avatar
bad_brain
Site Owner
Site Owner
Posts: 11598
Joined: 06 Apr 2005, 16:00
16
Location: The zone.
Contact:

Post by bad_brain »

well, there are a couple of such packages like XAMP or LAMP, the only difference is maybe the versions of servers and the i-face, so they´re all good to start and enough for any home network I think. if you´re more ambitioned in networking the next step is of course a Linux-server.. :wink:

Post Reply