Pages

Sunday, February 06, 2005

How to install and configure your own web server

Install Apache2, PHP 4.3.10 and MySQL

Here is a quick tutorial to make your own web server [Apache, PHP4, MySQL] on Windows. Of course you can always download an already made server suite, but all you do next, next, next... and then edit your php scripts. Installing your own web server and configuring it will improve your knowledge in this field, and gives you the oportunity to configure it for your own needs. Download [latest stable realeses]: Apache [httpd-2.0.52-win32-x86-src.zip] PHP PHP 4.3.10 zip package MySQL 4.1.9 [I still use MySQL 3.23] Create a folder on your disk C:\www Run apache installer:
- install location c:\www
[default c:\program files\apache group]:
so it will install c:\www\apache2
- Hostname: localhost or your IP address
- Listen: 80
- admin email address: youremail@address.com
- finalize install
Create the folder: c:\www\htdocs Unzip php-4.3.10-Win32.zip to c:\www\php4 Copy [or cut] c:\www\php4\sapi\* to c:\www\php4\* Rename php.ini-dist to php.ini and edit it:
; The root of the PHP pages, used only if nonempty.
; if PHP was not compiled with FORCE_REDIRECT, you SHOULD set doc_root
; if you are running php as a CGI under any web server (other than IIS)
; see documentation for security issues.  The alternate is to use the
; cgi.force_redirect configuration below
doc_root = c:/www/htdocs
;...........................
extension_dir = "c:/www/php4/extensions"
; Uncoment eny extension that you may need
extension=php_xslt.dll
;............... display all error except notices
error_reporting  =  E_ALL & ~E_NOTICE
;displaying script errors:
display_errors = On
; if you are using for production is it recommended to be set to Off

Note: php_xslt.dll requiers sablot.dll [placed under %WINDIR%\system32] php_exif requires php_mbstring.dll loaded BEFORE. For other extensions check documentation first. Copy php.ini in your %WINDIR% directory [that is c:\windows or c:\winnt] Configure apache to handle php scripts: Open and edit c:\www\apache2\conf\httpd.conf
ServerRoot "C:/www/Apache2"
#....edit
Listen 80
#.....ad the line
LoadModule php4_module /www/php/php4apache2.dll
#....edit
ServerName localhost:80
#...edit
DocumentRoot "C:/www/htdocs"
#...edit
DirectoryIndex index.html index.php default.php index.html.var
#add the lines:
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
Save it and restart Apache [Apache Monitor->Apache2->Restart]. MySQL: Unzip mysql to c:\www\mysql and run c:\www\mysql\bin\winmysqladmin.exe, set root password and you will have mysql databaser server running. I also recommend phpMyAdmin for querying and administering mysql server. Now testing instalation: create a file index.php in c:\www\htdocs and put the following content: <? phpinfo(); ?> then open your browser and go to: http://localhost/ and you should see:

PHP Version 4.3.10 ....

If not, well there is a problem. Send me an email and I will try to help you. Hope this can help... This is mainly the way I've done it several times and it worked on Windows 2000, windows xp, sp2, and last evening was running on windows media center 2005. I also installed mod-python, but that will be another post :)

No comments: