Academia.eduAcademia.edu

Apache Web Server Installation

Step 1: configure IIS, Skype and other software (optional) If you have a Professional or Server version of Windows, you may already have IIS installed. If you would prefer Apache, either remove IIS as a Windows component or disable its services. Apache listens for requests on TCP/IP port 80. The default installation of Skype also listens on this port and will cause conflicts. To switch it off, start Skype and choose Tools > Options > Advanced > Connection. Ensure you untick "Use port 80 and 443 as alternatives for incoming connections". Step 2: download the files We are going to use the unofficial Windows binary from Apache Lounge. This version has performance and stability improvements over the official Apache distribution, although I am yet to notice a significant difference. However, it is provided as a manually installable ZIP file fromwww.apachelounge.com/download/ You should also download and install the Windows C++ runtime from Microsoft.com. You may have this installed already, but there is no harm installing it again.

How to Install Apache Web Server, PHP and MySQL Server on Windows By Craig Buckler, April 7, 2009. Apache Web Server Installation Step 1: configure IIS, Skype and other software (optional) If you have a Professional or Server version of Windows, you may already have IIS installed. If you would prefer Apache, either remove IIS as a Windows component or disable its services. Apache listens for requests on TCP/IP port 80. The default installation of Skype also listens on this port and will cause conflicts. To switch it off, start Skype and choose Tools > Options > Advanced > Co e tio . E su e ou u ti k Use po t 80 a d as alte ati es fo i o i g o e tio s . Step 2: download the files We are going to use the unofficial Windows binary from Apache Lounge. This version has performance and stability improvements over the official Apache distribution, although I am yet to notice a significant difference. However, it is provided as a manually installable ZIP file fromwww.apachelounge.com/download/ You should also download and install the Windows C++ runtime from Microsoft.com. You may have this installed already, but there is no harm installing it again. As always, remember to virus scan all downloads. Step 2a: extract the files We will install Apache in C:/Server/Apache2, so extract the ZIP file to the root of the C: /Server. Apache can be installed anywhere on your system, but you will need to change the configuration file paths a o di gl … Step 3: configure Apache Apache is configured with the text file confhttpd.conf contained in the Apache folder. Open it with your favourite text editor. Note that all file path setti gs use a / fo a d-slash rather than the Windows backslash. If you installed Apache anywhere other than C:Apache2, now is a good time to search and replace all efe e es to :/Apa he ″. There are several lines you should change for your production environment: Line 46, listen to all requests on port 80: Listen *:80 Line 116, enable mod-rewrite by removing the # (optional, but useful): 1 LoadModule rewrite_module modules/mod_rewrite.so Line 172, specify the server domain name: ServerName localhost:80 Line 224, allow .htaccess overrides: AllowOverride All Step 4: change the web page root (optional) By default, Apache return files found in its htdocs folder. I would recommend using a folder on an another drive or partition to make backups and re-installation easier. For the purposes of this example, we will create a folder called D:WebPages and change httpd.conf accordingly: Line 179, set the root: DocumentRoot "D:/WebPages" and line 204: <Directory "D:/WebPages"> Step 5: test your installation Your Apache configuration can now be tested. Open a command box (Start > Run > cmd) and enter: cd Apache2bin httpd -t Correct any httpd.conf configuration errors and retest until none appear. Step 6: install Apache as a Windows service The easiest way to start Apache is to add it as a Windows service. From a command prompt, enter: cd Apache2bin httpd -k install Open the Control Panel, Administrative Tools, and then Services and double-click Apache2.2. Set the “ta tup t pe to Auto ati to e su e Apa he sta ts e e ti e ou oot ou PC. Alte ati el , set the “ta tup t pe to Ma ual a d lau h Apa he he e e o a d et sta t Apa he . ″. 2 ou choose using the Step 7: test the web server C eate a file a ed i de .ht l i Apa he s e page oot eithe htdo s o D:We Pages a d add a little HTML code: <html> <head><title>testing Apache</title></head> <body><p>Apache is working!</p></body> </html> Ensure Apache has started successfully, open a web browser and enter the address https://localhost/. If all goes well, your test page should appear. In general, most problems will be caused by an incorrect setting in the httpd.conf configuration file. Refer to the Apache documentation if you require further information. 3 PHP Installation Step 1: download the files Download the latest PHP 5 ZIP package from www.php.net/downloads.php As always, virus scan the file and check its MD5 checksum using a tool such as fsum. Step 2: extract the files We will install the PHP files to C:php, so create that folder and extract the contents of the ZIP file into it. PHP can be installed anywhere on your system, but you will need to change the paths referenced in the following steps. Step 3: configure php.ini Copy C:phpphp.ini-recommended to C:phpphp.ini. There are several lines you will need to change in a text editor (use search to find the current setting). Define the extension directory: extension_dir = "C:phpext" Enable extensions. This will depend on the libraries you want to use, but the following extensions should be suitable for the majority of applications (remove the semi-colon comment): extension=php_curl.dll extension=php_gd2.dll extension=php_mbstring.dll extension=php_mysql.dll extension=php_mysqli.dll extension=php_pdo.dll extension=php_pdo_mysql.dll extension=php_xmlrpc.dll If you want to send emails using the PHP mail() function, enter the details of an SMTP server (your I“P s se e should e suita le : [mail function] ; For Win32 only. SMTP = mail.myisp.com 4 smtp_port = 25 ; For Win32 only. sendmail_from = [email protected] Step 4: add C:php to the path environment variable To ensure Windows can find PHP, you need to change the path environment variable. From the Co t ol Pa el, hoose “ ste , the Ad a ed s ste setti gs i Vista , sele t the Ad a ed ta , a d li k the E i o e t Va ia les utto . “ oll do the “ ste a ia les list a d li k o Path follo ed to the end of the Variable value line (remember the semi-colon). Now OK your way out. You might need to reboot at this stage. 5 the Edit utto . E te ;C:php Step 5: configure PHP as an Apache module E su e Apa he is ot u i g use et stop Apa he . ″ f o the o a d li e a d ope its confhttpd.conf configuration file in an editor. The following lines should be changed: Line 239, add index.php as a default file name: DirectoryIndex index.php index.html At the bottom of the file, add the following lines (change the PHP file locations if necessary): # PHP5 module LoadModule php5_module "c:/php/php5apache2_2.dll" AddType application/x-httpd-php .php PHPIniDir "C:/php" Save the configuration file and test it from the command line (Start > Run > cmd): cd Apache2bin httpd -t Step 6: test a PHP file C eate a file a ed i de .php i Apa he s e page oot eithe htdo s o D:We Pages a d add this code: <?php phpinfo(); ?> Ensure Apache has started successfully, open a web browser and enter the address https://localhost/. If all goes ell, a PHP e sio page should appea sho i g all the o figu atio setti gs. 6 MySQL Server Installation Step 1: download MySQL Download MySQL from dev.mysql.com/downloads/. Follow MySQL Community Server, Windows and do load the Without i stalle e sio . As always, virus scan the file and check the its MD5 checksum using a tool such as fsum. Step 2: extract the files We will install MySQL to C:mysql, so extract the ZIP to your C: drive and rename the folder from s l-x.x.xx- i ″ to s l . MySQL can be installed anywhere on your system. If you want a lightweight installation, you can remove every sub-folder except for bin, data, scripts and share. Step 3: move the data folder (optional) I recommend placing the data folder on another drive or partition to make backups and reinstallation easier. For the purposes of this example, we will create a folder called D:MySQLdata and move the contents of C:mysqldata into it. You should now have two folders, D:MySQLdatamysql and D:MySQLdatatest. The original C:mysqldata folder can be removed. Step 4: create a configuration file MySQL provides several configuration methods but, in general, it is easiest to to create a my.ini file in the mysql folder. There are hundreds of options to tweak MySQL to your exact requirements, but the simplest my.ini file is: [mysqld] # installation directory basedir="C:/mysql/" # data directory datadir="D:/MySQLdata/" (Remember to change these folder locations if you have installed MySQL or the data folder elsewhere.) 7 Step 5: test your installation The MySQL server is started by running C:mysqlbinmysqld.exe. Open a command box (Start > Run > cmd) and enter the following commands: cd mysqlbin mysqld This will start the MySQL server which listens for requests on localhost port 3306. You can now start the MySQL command line tool and connect to the database. Open another command box and enter: cd mysqlbin mysql -u root This ill sho a el o e essage a d the the pre-defined databases. s l> p o pt. E te sho data ases; to ie a list of Step 6: change the root password The MySQL root user is an all-powerful account that can create and destroy databases. If you are on a shared network, it is advisable to change the default (blank) password. From the mysql> prompt, enter: UPDATE mysql.user SET password=PASSWORD("my-new-password") WHERE User='root'; FLUSH PRIVILEGES; You will be prompted for the password the next time you start the MySQL command line. E te e it at the s l> p o pt to stop the o MySQL with the following command: a d li e lie t. You should o shut do mysqladmin.exe -u root shutdown Step 7: Install MySQL as a Windows service The easiest way to start MySQL is to add it as a Windows service. From a command prompt, enter: cd mysqlbin mysqld --install 8 Open the Control Panel, Administrative Tools, then Services and double-click MySQL. Set the Startup t pe to Auto ati to e su e M “QL sta ts e e ti e ou oot ou PC. Alte ati el , set the “ta tup t pe to Ma ual a d lau h M “QL he e e command et sta t s l . Note that the Windows service can be removed using: cd mysqlbin mysqld --remove 9 ou hoose usi g the