An eBook on the installation and configuration of the XAMPP web server package on your Windows machine, which includes the Apache web server, PHP, MySQL, Perl and many other useful tools.
- Updated December 2013 for XAMPP 1.8.2 and above. - How to get the ionCube loader, curl and sendmail to work through stunnel. - How to create Apache virtual hosts for your web sites. - How to create MySQL databases and users for your web sites. - How to synchronise your remote MySQL database with your local MySQL database. - How to share your web sites on the internet with free Dynamic IP services. - How to run WordPress web sites on your XAMPP server. - And more insider tips from a web developer with over 10 years of experience.
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
How to Install and Configure XAMPP on Your Windows PCby Vince Law
Version: 2.0
First Edition: 30 April 2010Last Update: 8 December 2013
About this eBook................................................................................................................................................... 1Copyright................................................................................................................................................................... 2Legal............................................................................................................................................................................. 2Software Requirements...................................................................................................................................... 2Feedback.................................................................................................................................................................... 2Acknowledgements............................................................................................................................................. 2Modifications and Updates.............................................................................................................................. 2
Chapter 1: First Things First....................................................................................................3
Download XAMMP for Windows................................................................................................................. 3Download ionCube Loader for Windows.................................................................................................. 6Download Stunnel for Windows................................................................................................................... 7Download the Free PHP Mail Script............................................................................................................ 7
Chapter 2: Install XAMPP for Windows..............................................................................8
Run the XAMMP Installer for Windows................................................................................................... 8Configure the XAMPP Control Panel........................................................................................................ 11Install the Apache and MySQL Services.................................................................................................. 15Start the Apache and MySQL Services...................................................................................................... 18Test XAMPP........................................................................................................................................................... 18Configure XAMPP Security............................................................................................................................ 20
Chapter 3: Install ionCube Loader for Windows............................................................25
Run the ionCube Installer for Windows................................................................................................. 25Enable ionCube Loader for Windows in the php.ini File................................................................28
Chapter 4: Install Stunnel for Windows...........................................................................30
Run the Stunnel Installer for Windows.................................................................................................. 30Configure Stunnel Settings in the stunnel.conf File..........................................................................32
Configure Stunnel with Google Gmail................................................................................................ 32Configure Stunnel with Your Web Domain's SMTP.....................................................................33
Install the Stunnel Service............................................................................................................................. 35
Chapter 5: Enable the PHP Sendmail Module.................................................................36
Configure Sendmail Settings in the php.ini File.................................................................................. 36Configure Sendmail Settings in the sendmail.ini File......................................................................37Test Sendmail........................................................................................................................................................ 38
Chapter 6: Enable the PHP curl Module...........................................................................40
Enable curl in the php.ini File...................................................................................................................... 40
Chapter 7: Update the Apache IP Address & Port Number..........................................41
Configure the IP Address in the httpd.conf File................................................................................... 41Configure the Port Number in the httpd.conf File.............................................................................42
Chapter 8: Managing MySQL Databases...........................................................................44
Creating a MySQL Database in phpMyAdmin..................................................................................... 44Creating a MySQL User in phpMyAdmin...................................................................................................Synchronising Your Local MySQL Database with Your Remote MySQL Database...........47
Exporting Your Remote MySQL Database........................................................................................48Importing Your Remote MySQL Database with phpMyAdmin............................................49Importing Your Remote MySQL Database with the MySQL Command Line.................50
Chapter 9: Managing Apache Web Sites...........................................................................52
Enabling Access to Your Virtual Hosts..................................................................................................... 52Creating Virtual Hosts for Each Web Site................................................................................................ 52
Chapter 10: Connecting Apache to the Internet.............................................................55
Enable Public Access to the Apache Web Server.................................................................................55Internet Connection.......................................................................................................................................... 56
Direct Internet Connection...................................................................................................................... 56Shared Internet Connection.................................................................................................................... 56
Port Forwarding.......................................................................................................................................................Router Port Forwarding..................................................................................................................................Windows Firewall Port Forwarding.................................................................................................... 58
Windows 7.................................................................................................................................................. 59Disabling Windows Firewall....................................................................................................... 60Creating a TCP Port Forward......................................................................................................... 63
Windows Vista.......................................................................................................................................... 67Disabling Windows Firewall....................................................................................................... 67Creating a TCP Port Forward......................................................................................................... 69
Windows XP............................................................................................................................................... 71Disabling Windows Firewall....................................................................................................... 71Creating a TCP Port Forward......................................................................................................... 72
Third Party Firewall Port Forwarding................................................................................................. 73Testing Your Port Forwarding Settings............................................................................................... 74
Dynamic IP Address.......................................................................................................................................... 74No-IP.com......................................................................................................................................................... 75
Creating a No-IP.com Free Account............................................................................................... 75Installing the No-IP.com Dynamic DNS Update Client......................................................76Creating No-IP.com Hosts................................................................................................................... 80
DNS Host (A)........................................................................................................................................ 81Port 80 Redirect................................................................................................................................... 82
DynDNS.com.................................................................................................................................................. 84Creating a DynDNS.com Free Account......................................................................................... 84Installing the DynDNS.com Dynamic DNS Update Client................................................85Creating DynDNS.com Hosts............................................................................................................. 89
DNS Host (A)........................................................................................................................................ 90Testing Your Dynamic DNS Hosts........................................................................................................ 93
How to Install and Configure XAMPP on Your Windows PC
Overview
About this eBook
This eBook is a step-by-step instructional manual on how to install and configure a web server on your Windows PC. I will be using XAMPP 1.8.2/1.8.3 as my preferred all-in-one package because it is easy to install and run without having to enter a lot of commands in the Windows command window.
The purpose of this eBook is not to enable you to run a web server to host a public web site on the internet. XAMPP is more for development purposes on a computer or local area network.
Nonetheless, I will still show you how to connect your XAMPP web server with a dynamic DNS service like No-IP.com so that you may let others access the web sites hosted on your Windows PC's web server. This would be very useful for web designers/developers to let their customers take a look at the development progress of their projects.
You can also use XAMPP to install and run PHP web applications. At a minimum, you will need the Apache web server, MySQL, phpMyAdmin, curl, sendmail and PHP loaders to run encoded (encrypted) PHP files. Some of them are not well documented by XAMPP and that is where I will step in and show you how to get them up and running in no time.
While most PHP web applications are open source, some commercial PHP web applications are not. What that means is the source code of some PHP web applications are encoded. The two most popular PHP encoding software are Zend Guard and ionCube PHP Encoder.
You will need Zend Guard Loader and ionCube loader installed on your web server to run these encoded web applications. XAMPP does not support Zend Guard Loader because it compiles PHP with thread safety enabled. Therefore, if you need to use Zend Guard Loader, it would be easier if you installed Zend Server instead.
At the time of this writing, Zend Guard Loader and ionCube loader do not work with PHP 5.5. If you need to use ionCube loader, please install XAMPP 1.8.2 as this version uses PHP 5.4. XAMPP 1.8.3 and above uses PHP 5.5.
My wish is that by the end of this eBook, you will be able to successfully install and configure your very own XAMPP web server by applying the “tricks of the trade” of Web developers and Webmasters. I spent hours and hours learning to get my XAMPP web server running with all the tools and settings required to fulfil all my needs as a Web developer.
Now, with this eBook, you will be able to reduce your learning curve by following the step-by-step instructions and avoid all the mistakes and wasted time it took me to figure out all how to do all this.
How to Install and Configure XAMPP on Your Windows PC
I hope you enjoy the eBook and please feel free to contact me should you have any questions.
Copyright
All rights reserved. No part of this publication may be reproduced or transmittedin any form or by any means, electronic or mechanical. Any unauthorized use, sharing, reproduction, or distribution is strictly prohibited.
Legal
While attempts have been made to verify information provided in this publication, neither the author nor the publisher assumes any responsibilities for errors, omissions, orcontradictory information contained in this document.
This document is not intended as legal, investment, or accounting advice. The purchaseror reader of this document assumes all responsibility for the use of these materials andinformation. Vince Law assumes no responsibility or liability whatsoever on behalf of anypurchaser or reader of these materials.
Software Requirements
• Windows XP, Windows Vista, Windows 7, Windows 8 or any Windows Server operating system.
• Mozilla Firefox 3 +, Safari 3 +, Internet Explorer 7 +, Opera 9 + or your favourite browser
Feedback
Please direct any comments or suggestions about this eBook to me at:
http://www.VinceLaw.com.au/contact/
Acknowledgements
Modifications and Updates
Version 2.0
1. XAMPP – 1.8.2 & 1.8.3.2. Updated the link to the Free PHP Mail Script.3. Added sections on Stunnel for use with Sendmail.
How to Install and Configure XAMPP on Your Windows PC
• If you need to use PHP 5.5, please download XAMPP 1.8.3 and above. Zend Guard Loader and ionCube loader won't work with PHP 5.5 at the time of this writing.
• If you need to use Zend Guard Loader or ionCube loader for PHP 5.4, please download XAMPP 1.8.2 or below.
• Click on the Installer link to download XAMPP to your computer.
How to Install and Configure XAMPP on Your Windows PC
Chapter 2: Install XAMPP for Windows
Run the XAMMP Installer for Windows
To start the XAMPP installer, simply double click on the XAMPP file you downloaded in the previous chapter.
You will see a warning message about installing XAMPP outside of the “Program Files” folder to prevent user rights restriction issues. We will get to that in a moment.
How to Install and Configure XAMPP on Your Windows PC
Close your XAMPP Control Panel and launch it with the shortcut you created.
You should see a slightly different XAMPP Control Panel like the screen shot above. The Service options now have X's and you should see a “running with administrator rights” message.
Click on the Config button to configure the XAMPP Control Panel options.
How to Install and Configure XAMPP on Your Windows PC
Install the Apache and MySQL Services
If you install the Apache and MySQL services, they will start automatically whenever youstart Windows.
If you don't want them to start automatically, you can either have them start with the XAMPP Control Panel or you can manually click on the Start button of the Apache and MySQL modules.
The checkboxes marked with red X's are for services that have not been installed.
Please ensure that both the Apache and MySQL modules have been stopped before proceeding.
Click on the Stop buttons next to Apache and MySQL to stop them if they are running.
• Check on the Apache checkbox and a confirmation window will pop up.
How to Install and Configure XAMPP on Your Windows PC
The MySQL checkbox should now display a green tick and there should also be an “ MySQL service installation successful” message.
You may repeat this process for the FileZilla and Tomcat services if you are planning to use them. I personally don't use these two services and I won't be covering how to use them in this eBook.
An alternative way to get to the XAMPP welcome screen is to click on the Admin button of the Apache module at the XAMPP Control Panel.
If you do not see the XAMPP welcome screen, go to http://www.apachefriends.org/en/faq-xampp-windows.html for troubleshooting help. Most likely, it is going to be something to do with your Apache web server not running properly.
Click on the “Status” link on the left. You should see a page with the status of the XAMPP components.
How to Install and Configure XAMPP on Your Windows PC
Configure XAMPP Security
Click on the Security link on the left of your XAMPP admin. You should see a page with the security status of XAMPP, MySQL and phpMyAdmin. You should also see an UNSECURE status messages to the right of the 3 components.
Click on the http://localhost/security/xamppsecurity.php link at the bottom of the Securitypage.
This is the page you enter passwords to protect your XAMPP and MySQL root user account. The top section is for the MySQL database root password while the bottom sectionis for the XAMPP directory protection.
How to Install and Configure XAMPP on Your Windows PC
Go back to the Security page by clicking on the Security link on the left of your XAMPP admin. You should see a SECURE status to the right of the XAMPP pages row.
MySQL Root Password
The MySQL root password should be entered to protect your MySQL databases from unauthorised access.
• Enter the same password into the two password fields.
• Check on either http or cookie for the phpMyAdmin authentication field.
• Check on Yes for the “random password” field.
• Click on the Password changing button to save your password.
How to Install and Configure XAMPP on Your Windows PC
Your MySQL service should now be started with the new password.
Go back to the Security page by clicking on the Security link on the left of your XAMPP admin. You should see a SECURE status to the right of the MySQL and phpMyAdmin rows.
How to Install and Configure XAMPP on Your Windows PC
Chapter 3: Install ionCube Loader for Windows
Run the ionCube Installer for Windows
The ionCube loader for Windows will allow you to run ionCube encoded PHP files on your Apache web server.
The ionCube Loader installation has two parts to it. The first one is the easy one because you will be running a Windows installation program. The second part is a bit tricky because you will be editing the php.ini file.
The whole process is pretty easy if you follow my step-by-step instructions carefully.
The ionCube installer usually comes in a zip file. Open the zip file and double click on the file in the zip archive to run the installer.
Click on the Finish button to complete the installation process.
How to Install and Configure XAMPP on Your Windows PC
Enable ionCube Loader for Windows in the php.ini File
The php.ini file controls the settings of how PHP is run on your web server.
The easiest way to open the php.ini file is to click on the Config button of the Apache module on the XAMPP Control Panel and click on the PHP (php.ini) option.
Your editor should open the php.ini file and display its contents.
How to Install and Configure XAMPP on Your Windows PC
Click on the phpinfo() link on the left of the XAMPP admin. You should see a web page with the PHP version at the top of the page.
Open the php.ini file in Notepad or your favourite text/HTML editor.
• Add the line 'zend_extension = “E:\xampp\ioncube\ioncube_loader_win_5.4.dll” at the bottom of the php.ini file.
• Save the php.ini file.
Please replace the path of your XAMPP folder and the first two digits in your PHP version in the path above.
Please note that part of the official installation instructions is incorrect at the time of this writing.
ionCube's instructions has the “zend_extension_ts” parameter instead of the “zend_extension”. I have not been able to get “zend_extension_ts” to work in PHP 5.3 or 5.4.
Now we need to restart the Apache service. Similar to what we did to restart the MySQL service, click on the Stop button of the Apache module on the XAMPP Control Panel and click on the Start button after the service has stopped.
Click on the phpinfo() link on the left of the XAMPP admin. You should see “with the ionCube PHP Loader” text in the “Powered by Zend Engine 2” box.
How to Install and Configure XAMPP on Your Windows PC
Chapter 4: Install Stunnel for Windows
Run the Stunnel Installer for Windows
Stunnel allow you to send emails through a SSL connection to Sendmail. I could not get Sendmail to work without Stunnel but you could possibly still use Sendmail by itself if your mail server does not requires the use of a SSL connection to send emails.
Double click on the Stunnel installer exe file to run the installer.
How to Install and Configure XAMPP on Your Windows PC
Click on the Install button to continue.
A command window will pop up prompting you to enter the following information:
1. Country Name in two letter code.2. State or Province Name.3. Locality Name.4. Organisation Name.5. Organisational Unit Name.6. Common Name (FQDN of your server). Enter localhost for this field.
Once you have entered all the required information, the installer will continue.
How to Install and Configure XAMPP on Your Windows PC
Click on the Close button to complete the installation process.
Configure Stunnel Settings in the stunnel.conf File
Click on stunnel GUI Start in the stunnel program groupof your start menu.
You should see a stunnel icon in your taskbar.
Right click on the stunnelicon and click on Editstunnel.conf to open thestunnel.conf file.
You should see thestunnel.conf file in yourdefault notepad
application.
Configure Stunnel with Google Gmail
If you are planning on using Gmail's SMTP service, you are going to need to have a Gmail account. If you don't have a Gmail account, I highly recommend that you register a free account at Gmail.com. You may also use other free email services like Yahoo or Hotmail aslong as they allow you to use the SMTP server to send emails.
Before we get started with using Gmail with Sendmail, please enable your POP access by following Google's tutorial on enabling POP.
Gmail's “from” address will match whatever you set as the default identity. Please read Google's documentation on how to add a “from”address in Gmail.
How to Install and Configure XAMPP on Your Windows PC
This would be okay if the applications you are running from your web server do not require a specific “from” address. This wouldn't look good on a professional application that is being used by your customers.
• Remove the [;] character from the four lines as shownin the screen shot above.
• Save the stunnel.conf file.
• Right click on the stunnel icon in the taskbar andclick on Reload stunnel.conf to load the new settingsin Stunnel.
Configure Stunnel with Your Web Domain's SMTP
If you already have a web domain hosted on a web host, you may use your own SMTP server to send emails.
Usually, the emails created on your web host do not have any “from” address restrictions. For example, you could have an email address like [email protected] but you could still receive emails with a “from” address like [email protected]. Gmail does not allow this and they will replace your “from” address with the default email address identity of your Gmail account.
Before we start, you need to have an email account created at your web host's control panel.
How to Install and Configure XAMPP on Your Windows PC
My web host uses the cPanel control panel. Once you are logged in to your cPanel, simply click on Email Accounts to continue.
Create an email account now if you have not done so.
Once you have an email account, click on More and Configure Email Client to continue.
Check out the Manual Settings section. You should see a list of settings you need to enter into your mail client. Take note of the Outgoing Server (SSL) + port number settings.
How to Install and Configure XAMPP on Your Windows PC
Let's go back to the stunnel.conf file to add your web domain's SMTP settings.
• Add a [;] character on the four lines as shown in thescreen shot above to hide the Gmail SMTP settingsfrom stunnel.
• Copy the Gmail STMP settings and paste it below.
• Remove the [;] character from the four lines as shownin the screen shot above.
• Create a name for your web domain's settings. I decided to name mine [vince-smtp] .
• Enter the outgoing server and port number on the “connect = “ line.
• Save the stunnel.conf file.
• Right click on the stunnel icon in the taskbar and click on Reload stunnel.conf to load the new settings in Stunnel.
What we have been doing in the previous steps is to configure Stunnel to listen on port 25 and connect to a SSL server on your desired host and port number.
We will be using port number 25 in the Sendmail settingsand it will all make more sense n the next chapter.
Install the Stunnel Service
If you install the Stunnel service, it will startautomatically whenever you start Windows.
To install the Stunnet service, simply click on stunnelService Install in the stunnel program group of your startmenu.
If you don't want it to start automatically, you can manually click on stunnel GUI Start inthe stunnel program group of your start menu.
How to Install and Configure XAMPP on Your Windows PC
Chapter 5: Enable the PHP Sendmail Module
Configure Sendmail Settings in the php.ini File
Sendmail allows you to send emails from your PHP scripts. This was one of the trickiest things I had to figure out how to configure because there are a lot of ways to enable PHP to send emails but this is simplest way I know.
Open the php.ini file by clicking on the Config button of the Apache module on the XAMPP Control Panel and click on the PHP (php.ini) option.
• Add a [;] character in front of “SMTP = localhost”.
• Add a [;] character in front of “smtp_port = 25”.
• Remove the [;] character in front of 'sendmail_path = "\"E:\XAMPP\sendmail\sendmail.exe\" -t"'.
• Add a [;] character in front of 'sendmail_path="E:\XAMPP\mailtodisk\mailtodisk.exe"'.
• Add a [;] character in front of “mail.add_x_header = Off”.
How to Install and Configure XAMPP on Your Windows PC
Enter "http://localhost/mail.php" into your browser.
You should see the Mail Tester script in the screen shot on the left.
• Enter a return email address into the From field.
• Enter a recipient email address into the To field. Use one of your own email addresses so that you may receive the email.
• Enter an email subject into the Subject field.
• Enter a message into the Message field.
• Click on the Send button to send the email.
Now check your email to see if the email has been sent to you.
If you receive an error in the Mail Tester script, ppen the error.log and debug.log files in E:\XAMPP\sendmail to get clues about why the email was not sent.
How to Install and Configure XAMPP on Your Windows PC
Chapter 6: Enable the PHP curl Module
Enable curl in the php.ini File
PHP supports libcurl, a library created by Daniel Stenberg, that allows you to connect and communicate to many different types of servers with many different types of protocols. After you enable curl, you will be able to use the PHP curl functions in your PHP files.
One of the first things you need to do is to check if curl has been enabled in PHP.
Click on the phpinfo() link on the left of the XAMPP admin. Scroll down to see if you can find a curl section.
If you see a curl section like the screen shot above, you don't have to continue with the steps below. Simply proceed to the next chapter.
If you don't see a curl section like the screen shot above, you are going to need to enable curl manually.
Open the php.ini file by clicking on the Config button of the Apache module on the XAMPP Control Panel and click on the PHP (php.ini) option.
• Remove the [;] character in front of “;extension=php_curl.dll”.
• Save the php.ini file.
• Restart the Apache service.
Once you have restarted the Apache service, click on the phpinfo() link on the left of the XAMPP admin again. You should see a curl section on the page now.
How to Install and Configure XAMPP on Your Windows PC
Chapter 7: Update the Apache IP Address & Port Number
Configure the IP Address in the httpd.conf File
If you plan on sharing your XAMPP web server on your local area network, you need to change the IP address in the Apache httpd.conf file. The default “localhost” address only works on the same computer XAMPP was installed on.
It is best that you assign a fixed IP address on your XAMPP web server's computer. This can be configured in your network router's LAN settings or in your Network Connections settings.
Open the command prompt by going to Start Menu Run Enter cmd or Start Menu → → →Accessories Command Prompt.→
Enter the command “ipconfig” into the command prompt. Take note of the IP address of your computer.
Open the C:\xampp\apache\conf\httpd.conf in Notepad or your favourite text/HTML editor.
• Replace the “localhost:80” text with your IP address. For example, 192.168.0.2:80.
How to Install and Configure XAMPP on Your Windows PC
Enter your computer's IP address into your browser. You should see the XAMPP welcome screen.
Configure the Port Number in the httpd.conf File
In the previous section, we updated the IP address of the Apache web server. We left the port number unchanged at 80. When the web server's port number is 80, the browsers will automatically assume that it is a web server. That is why you see your XAMPP welcome screen just by entering the IP address of the XAMPP web server.
Most internet service providers do not allow you to host your web server from their internet connection. They limit your upload speeds and block port 80 to try to deter you from doing that. A normal broadband internet connection is unsuitable for hosting web sites due to these restrictions.
However, you could still use your XAMPP web server for development purposes and share your web server to a small group of people. That is why you need to change the port number to a port number that is currently available.
You will see a list of port numbers currently used by your computer. Pick a port number that is not on the list for your new Apache port number.
Open the C:\xampp\apache\conf\httpd.conf in Notepad or your favourite text/HTML editor.
• Replace the “Listen 80” text with a new port number. For example, “Listen 1234”.
• Replace the “80” in the “ServerName” line with a new port number.
• Save the httpd.conf file.
• Restart the Apache service.
Enter your computer's IP address followed by the port number into your browser. For example, 192.168.0.2:1234. You should see the XAMPP welcome screen like before.
How to Install and Configure XAMPP on Your Windows PC
Chapter 8: Managing MySQL Databases
Creating a MySQL Database in phpMyAdmin
MySQL can be managed from the user-friendly phpMyAdmin interface.
• Click on the “phpMyAdmin” link on the left of your XAMPP screen.
• Enter “root” into the “User Name” field.
• Enter your MySQL root password into the “Password” field.
• Click on the “OK” button to login to phpMyAdmin.
How to Install and Configure XAMPP on Your Windows PC
• Click on the “Check All” link to grant all privileges for the database to the MySQL user.
• Select the MySQL database you created for the “Database-specific privileges” field.
• Click on the “Go” button to add the database privileges to the MySQL user.
Synchronising Your Local MySQL Database with Your Remote MySQL Database
If you're planning to synchronise the MySQL database of a web site on your XAMPP web server with the MySQL database on your web host, it is best that you create a database, user and user password on your XAMPP web server with the same name as the one on your web host.
Let's say your have a database on your web host is titled “superdatabase”, the database user is titled “superman” and the password is “superpass”. What you need to do is create a database in phpMyAdmin with the title “superdatabase”, create a database user with the username “superman” and password “superpass”. Finally, grant all privileges to the “superman” user to access the “superdatabase” database.
How to Install and Configure XAMPP on Your Windows PC
• Check on the “Save as file” option.
• Check on any option of the “Compression” field. The “zipped” and “gzipped” versions will generate smaller file sizes.
• Click on the “Go” button to export the MySQL database to a file.
Importing Your Remote MySQL Database with phpMyAdmin
Importing a MySQL database from phpMyAdmin is relatively simple with its user-friendly interface. However, it works smoothly when you have a tiny database file to import. phpMyAdmin won't be able to handle large database files with its default settings.
• Login to your XAMPP web server's phpMyAdmin.
• Click on the database you wish to import to on the left.
• Click on the “Import” tab at the top of the page.
• Click on the “Browse” button to select the database file you exported in the previousstep.
• Click on the “Go” button to import the database.
If the import was successful, you should see an “Import has been successful” message.
How to Install and Configure XAMPP on Your Windows PC
If the database file was too big for phpMyAdmin to handle, you will receive a “Fatal error”message. If you see error messages like this, the easiest alternative would be to use the MySQL command line to manually import your database into MySQL.
Importing Your Remote MySQL Database with the MySQL Command Line
If you can't get your MySQL database file to import successfully with phpMyAdmin, the best alternative solution would be to use the MySQL command line.
Before we start the MySQL command line, copy and paste your database file into the C:\xampp\mysql\bin directory. If your database file name is very long, you may shorten it to make it easier for the next step.
Open the command prompt by going to Start Menu Run Enter cmd or Start Menu → → →Accessories Command Prompt.→
• Enter cd\xampp\mysql\bin to get to the MySQL bin directory.
The MySQL command you need to enter is “mysql” followed by the following parameters:
• -uroot : The MySQL root user. You may choose to use another MySQL user as long asit has the appropriate access rights to the database you are importing to.
• -p : The password parameter. Some people enter their password immediately after the “-p” like “-pPASSWORD”. If you omit your password, you will be asked to enter your password on the next line and it will be masked with * symbols, which is more secure.
• Database name: After the password parameter, enter the database name of the database you wish to import to.
• < : This symbol indicates you wish to import data into a database. The opposite of the this symbol is the >, which indicates export.
• Database file name: This is the database file name you wish to import from.
In short, the command format to enter is “mysql -uUSER -p DATABASE < FILE”.
Depending on the size of your database file, it may take a few seconds to a few hours to complete the database import.
How to Install and Configure XAMPP on Your Windows PC
Chapter 9: Managing Apache Web Sites
Enabling Access to Your Virtual Hosts
This is an optional step but if your virtual hosts web sites are giving you a 403 error, this might solve the problem.
Open the C:\xampp\apache\conf\httpd.conf in Notepad or your favourite text/HTML editor.
• Edit the code “Require all denied” to “Require all granted”.
• Restart the Apache service.
Creating Virtual Hosts for Each Web Site
If you're planning on developing web sites or installing web applications on your Apache web server, you will need to create additional Virtual Hosts in Apache to run these web sites.
Unfortunately, I do not know of any other user-friendly way to add Virtual Hosts (additional web sites) other than editing the Apache configuration file. The Apache documentation on Virtual Hosts is quite limited. I need my web sites to work with Apache's mod_rewrite module but the documentation didn't cover that very well.
I also develop WordPress web sites on my XAMPP server and I need to enable FollowSymLinks option and FileInfo directives in Apache to get the Permalinks feature towork.
Open the C:\xampp\apache\conf\httpd.conf in Notepad or your favourite text/HTML editor.
I like to add this block of code to the end of the httpd.conf file:
• #(OPTIONAL COMMENT) : I use this as a label of the web site. Simply edit the text after the “#” character to enter your own label.
• (IP ADDRESS OR localhost):(PORT NUMBER) : This is the IP address and port number of your web site. The IP address should match your XAMPP web server's IPaddress while the port number should be an unused port number.
• (PATH TO DIRECTORY e.g. C:/Projects/) : This is the directory path of your web site's files. This has to be 100% correct or your Apache web server will fail to start!
• (ERROR LOG FILE NAME e.g. error.log) : This is the file name of your web site's errorlog file. Give it a unique name to avoid being overwritten by another web site's error log.
• (ERROR LOG FILE NAME e.g. custom.log common) : This is the file name of your web site's custom access log file. Give it a unique name to avoid being overwritten by another web site's custom access log.
• Directory parameters:
◦ Options : This sets the various options of your web site.
◦ Indexes : If the user requests a URL that points to a directory, and there is no index.html there, this option allows the suite of indexing commands to be used.
◦ FollowSymLinks : This option allows the web site to follow symbolic links, which are links to content that aren't really where the URL says they are at. Thisis required for WordPress and other web sites that use the mod_rewrite module.
#(OPTIONAL COMMENT)NameVirtualHost (IP ADDRESS OR localhost):(PORT NUMBER)Listen (IP ADDRESS OR localhost):(PORT NUMBER)
<VirtualHost *:(PORT NUMBER)>ServerAdmin ([email protected])ServerName (IP ADDRESS OR localhost):(PORT NUMBER)DocumentRoot "(PATH TO DIRECTORY e.g. C:/Projects/)"ErrorLog logs/(ERROR LOG FILE NAME e.g. error.log)CustomLog logs/(ERROR LOG FILE NAME e.g. custom.log common)<Directory "(PATH TO DIRECTORY e.g. C:/Projects/)">
Options Indexes FollowSymLinks Includes ExecCGIOrder allow,denyAllow from allAllowOverride allRequire all granted
</Directory></VirtualHost>
How to Install and Configure XAMPP on Your Windows PC
◦ Includes : This option allows the use of server-side includes.
◦ ExecCGI : This option allows the execution of CGI scripts on your web site.
◦ Order allow,deny : First, all Allow directives are evaluated; at least one must match, or the request is rejected. Next, all Deny directives are evaluated. If any matches, the request is rejected. Last, any requests which do not match an Allowor a Deny directive are denied by default.
◦ Allow from All : This option allows all hosts to access your web site.
◦ AllowOverride All : The option allows the web site to read the commands in the .htaccess file.
◦ Require all granted: This option grants access to your web site from all sources.
Don't worry if you don't understand all the code above. Simply copy and paste it into yourhttpd.conf file, edit the code to suit your web site and save the file. The code template above will work for WordPress web sites and most web sites.
The screen shot above is an example of a testing web site I created. Enter the IP address followed by the web site's port number in your browser and you should see the web site.
How to Install and Configure XAMPP on Your Windows PC
Chapter 10: Connecting Apache to the Internet
This is one of the hardest things for me to figure out. I tried to share my Apache web serveron the internet a couple of times a few years back and failed without finding a solution. After doing lots of research, I finally found all the missing bits and pieces of sharing my Apache web server on the internet.
Having your own web server does not really compare with outsourcing it to a web host. Unless you have the technical know how of running and managing web servers, I wouldn't recommend hosting live web sites on your own web server.
As a web designer/developer, I personally use this for letting my customers check out the progress of their web sites on my Apache web server because it would be more convenientthan uploading and setting up a web site on a web host. You could also use your own webserver to run web applications like project management applications that will be shared among a few people.
Most internet service provider's (ISP) limit their upload speeds to prevent users from running their own web servers. You don't want to arouse your ISP's suspicions because it is usually against their terms of service to run web servers with your internet connection.
You will need a few things to get this up and running...
Enable Public Access to the Apache Web Server
In Chapter 8, I went through the process of adding virtual hosts in Apache for use on your local area network. For Apache to be accessible from the internet, you need to edit the C:\xampp\apache\conf\extra\httpd-xampp.conf file.
I put this at the top of list of things to do because this is something you must edit to get Apache to work on the internet regardless of the type of internet connection, networking equipment or firewall you have.
Open the C:\xampp\apache\ extra\httpd-xampp.conf in Notepad or your favourite text/HTML editor.
Scroll down to the bottom of the page and you will see a header with the text “New XAMPP security concept”. This is the block of code you need to edit
How to Install and Configure XAMPP on Your Windows PC
Update the code to match the following code:
• Change “Order deny,allow” to “Order allow,deny”.
• Delete the line “Deny from all”.
• Change the “Allow from” line to “Allow from all”.
• Save the httpd-xampp.conf file.
• Restart the Apache service.
Internet Connection
You need a good internet connection to run your own web server. An unlimited usage broadband internet connection would be ideal.
Direct Internet Connection
The easiest way to set up a web server would be to have a modem directly connected to your computer. This could be a WiFi modem, USB modem, Ethernet modem, etc. With a direct internet connection, you do not need to worry about configuring your router.
Shared Internet Connection
If you are sharing your internet connection with a router, you will need to have access to the router to update the port forwarding and firewall settings.
If your home or office is using internet provided by your landlord, you may not have access to your landlord's router. Please try Shane's Detect Multiple Routers tool to check if you are using 2 routers or more. Shane also has a great tutorial on how to set up 2 or more routers together by enabling the DMZ feature of your router.
I was in such a situation when I rented an apartment in Thailand. The apartment came with a network socket where I could connect my networking devices or computers to. I connected my own router to the network socket because I had more than 1 computer to share the internet connection. I had complete access to my own router but I could not access my landlord's router.
## New XAMPP security concept#<LocationMatch "^/(?i:(?:xampp|security|licenses|phpmyadmin|webalizer|server-status|server-info))"> Order allow,deny Allow from all ErrorDocument 403 /error/HTTP_XAMPP_FORBIDDEN.html.var</LocationMatch>
When the internet connection went down, as they often do in Thailand, I had to inform my landlord who would take anywhere from 30 minutes to a few days to fix. It was not a nice situation to be in if you need to have a stable internet connection running 24 hours a day.
If you're in a situation like this, it would not be advisable to run your own web server because you have little control over your internet connection and router.
Port Forwarding
In Chapter 6 and 8, we added port numbers to the web sites hosted on the Apache web server. The port numbers of your web sites have to be open and forwarded to the IP address of your computer.
Router Port Forwarding
If your internet connection is shared with a router, you need to forward the port numbers of the web sites you wish to share to the IP address of your computer. It is also highly recommended to add a static/fixed IP address to your computer at your router's LAN IP settings.
There are hundreds of different routers in the market today and it would be impossible to write a tutorial for everyone of them. Portforward.com has a fantastic archive of port forwarding tutorials of a large list of routers on their web site. If your router is not listed ontheir web site, try reading the user guide that came with your router.
In a nutshell, you need to configure 2 things in your router:
1. Port forwarding of the port numbers of the web sites you wish to share.2. The IP address and/or port number has to be added to the firewall of your router.
The second part was something that confused me for a long time. I added the port forwarding option in my router but I forgot to add it to the firewall. I was literally bangingmy head against the wall trying to figure out why my port forwarding was not working.
How to Install and Configure XAMPP on Your Windows PC
As you can see from my D-Link DIR-300 router port forwarding page, I have set up 2 ports, 8106 and 1234 to be forwarded to the IP address 192.168.0.2, which is my computer's fixed IP address on my LAN. This alone is not enough. You still need to add them to the firewall!
Your router firewall page should look different from mine unless you have the same router. You should check if your router has allowed the port number in its firewall. If you don't see it allowed, then it is most likely blocked.
Windows Firewall Port Forwarding
Windows Firewall was first introduced as part of Windows XP Service Pack 2. Before Windows XP SP 2, Windows XP came with a firewall called the Internet Connection Firewall, which was disabled by default. I will be covering Windows versions from Windows XP SP 2 onwards because they all have Windows Firewall enabled by default.
How to Install and Configure XAMPP on Your Windows PC
If you have a third party firewall installed on your Windows, then Windows firewall would be redundant. You would be better off disabling Windows firewall You need to decide which firewall you want to use to protect your Windows operating system. 2 firewalls is overkill.
In my opinion, you do not need a firewall installed on your Windows computer is permanently behind a router. All incoming ports on your router are closed by default unless you choose to open them yourself.
However, if you are using a laptop and you connect to wireless hotspots outside of your home or office, you should be using a firewall to protect your computer because without a router and a firewall, you could have some open ports that could be exploited by a hacker.
Windows 7
The Windows Firewall is located in the Control Panel of your Windows. I like to sort the items in the Control Panel by small icons so that I can see all the different items in it at a glance.
Simply click on the Windows Firewall icon to launch the Windows Firewall tool.
How to Install and Configure XAMPP on Your Windows PC
The screen shot above is my Windows Firewall screen. I am connected to a LAN with a router that is connected to a modem, which in turn is connected to the internet. That is why you see a “Not Connected” message for the “Public Networks”.
Disabling Windows Firewall
Please proceed to turn off the Windows Firewall if you're 100% sure you know what you're doing with your third party firewall or you are already behind a router.
Click on the “Turn Windows Firewall on or off” link on the left.
The “Home” and “Public network” settings are turned on by default.
How to Install and Configure XAMPP on Your Windows PC
message at the bottom right of your screen urging you to turn it on again immediately after you turn off Windows Firewall.
If you find the Action Center annoying like I do, youcould turn off the Windows Firewall alerts.
Launch the Action Center by clicking on the ActionCenter flag icon at the bottom of your screen and youshould see the “Open Action Center” link at the bottomof the message window. Alternatively, you couldlaunch it at the Control Panel by clicking on the Action Center icon.
Click on the “Change Action Center settings” link on the left.
This is my Action Center settings screen. I have unchecked a lot of options so yours may
How to Install and Configure XAMPP on Your Windows PC
not look like mine.
If you do not want the Action Center to bug you on your Windows Firewall status ever again...
• Uncheck the “Network firewall”option.
• Click on the “OK” button to save the changes.
Creating a TCP Port Forward
You only need to create a TCP port forward in the Windows Firewall if you choose to use it. If you have disabled Windows Firewall, please skip this section.
Once you have launched the Windows Firewall window, click on the “Advanced settings”link on the left.
How to Install and Configure XAMPP on Your Windows PC
• Check on the “Domain”, “Private” and “Public” options.
• Click on the “Next” button to continue.
• Enter a descriptive name into the “Name” field. To make it easy to remember what this port forward is for, I like to add “XAMPP” followed by the port number and protocol type.
• Click on the “Finish” button to save the port forward.
How to Install and Configure XAMPP on Your Windows PC
You should see your TCP inbound rule in the “Advanced Security” window.
Windows Vista
The Windows Firewall is located in the Control Panel of your Windows. Simply double click on the Windows Firewall icon to launch the Windows Firewall tool.
Disabling Windows Firewall
Please proceed to turn off the Windows Firewall if you're 100% sure you know what you're doing with your third party firewall or you are already behind a router.
Click on the “Turn Windows Firewall on or off” link on the left.
How to Install and Configure XAMPP on Your Windows PC
Creating a TCP Port Forward
You only need to create a TCP port forward in the Windows Firewall if you choose to use it. If you have disabled Windows Firewall, please skip this section.
Once you have launched the Windows Firewall window, click on the “Change settings” link on the right.
How to Install and Configure XAMPP on Your Windows PC
• Enter a descriptive name into the “Name” field. To make it easy to remember what this port forward is for, I like to add “XAMPP” followed by the port number and protocol type.
• Enter the port number of your web site into the “Port number” field.
• Check on the “TCP” option.
• Click on the “OK” button to save the port forward.
How to Install and Configure XAMPP on Your Windows PC
You should see your TCP port forward in the “Exceptions” list.
Windows XP
The Windows Firewall is located in the Control Panel of your Windows. Simply double click on the Windows Firewall icon to launch the Windows Firewall tool.
How to Install and Configure XAMPP on Your Windows PC
• Click on the “OK” button to save the changes.
Creating a TCP Port Forward
• Click on the “Exceptions” tab.
• Click on the “Add port” button.
• Enter a descriptive name into the “Name” field. To make it easy to remember what this port forward is for, I like to add “XAMPP” followed by the port number and protocol type.
How to Install and Configure XAMPP on Your Windows PC
• Enter the port number of your web site into the “Port number” field.
• Check on the “TCP” option.
• Click on the “OK” button to save the port forward.
You should see your TCP port forward in the “Exceptions” list.
Third Party Firewall Port Forwarding
You will need to refer to the user guide of your third party firewall to find out how to create port forwards as every software has a different way of creating port forwards.
Some of the popular firewalls in the market today are:
• ZoneAlarm• Armor2Net
Please note that some free firewalls may not provide you with the option to create forwards. If you cannot open a port in your firewall, you may want to temporarily disable it and run Windows Firewall instead.
How to Install and Configure XAMPP on Your Windows PC
Testing Your Port Forwarding Settings
• Go to http://www.CanYouSeeMe.org.
• Enter the port number of your web site into the “What Port?” field.
• Click on the “Check” button to check your port number.
Your port forward is working properly if you see a success message at the bottom of the page. If you don't see a success message, then you will need to check if you have done the previous steps correctly. If you are 100% sure you have done them correctly, check out Shane's Common Problems & Fixes for Port Forwarding to see if you can find a solution.
Dynamic IP Address
Unless you have paid for a static (fixed) IP address from your ISP, your internet connection's IP address will change from time to time depending on your ISP's policies.
You could use a Dynamic DNS service to connect a domain name to your IP address, which will allow you to have an easy-to-remember address to connect to your computer.
The 2 most popular Dynamic DNS services are No-IP.com and DynDNS.com. The free versions should be enough for most people. The paid versions come with your very own domain names while the free versions come with a list of sub domains for you to use.
There are 2 types of hosts that will work with the Apache web sites on your web server - DNS Host (A) and Port Redirects.
How to Install and Configure XAMPP on Your Windows PC
A DNS Host (A) connects a domain to your IP address. It can be used for any service on your computer. You could connect to a remote network camera, web server, game server or computer with a DNS Host (A).
A Port Redirect is very similar to a DNS Host (A) with an extra feature to redirect a port number. You could run a web server on a non-standard (80) port and users accessing your web site will never have to enter a port number in the URL.
Let's say you have created a DNS Host (A), samserver.zapto.org, that is connected to your internet IP address 123.456.789.888. Whenever you or anyone else wants to connect to your computer, they only need to enter samserver.zapto.org instead of your IP address 123.456.789.888.
If you've got a network camera on port 5858 and your web site on port 8988, you need to enter samserver.zapto.org:5858 and samserver.zapto.org: 8988 respectively.
A port redirect allows you to connect to the different services on your computer by helping you redirect to your desired port number.
I could create a port redirect called samcamera.zapto.org and configure it to forward to port5858. Connecting to samcamera.zapto.org would connect directly to 123.456.789.888:5858 without the need to enter the IP address or the DNS Host (A) like samserver.zapto.org:5858.
No-IP.com
No-IP.com comes with both free and paid services. The No-IP Free DNS is geared towards home users getting started with DNS. You are allowed to create up to 5 hosts on a set of domains provided by No-IP.com. The No-IP Free DNS should be sufficient for most users who want to run non-commercial services from the computer.
Creating a No-IP.com Free Account
• Go to http://www.noip.com.
• Click on the “Create Account” link on the right to create a free account.
How to Install and Configure XAMPP on Your Windows PC
• Click on the “Next” button to continue.
Click on the “Finish” button to complete the installation.
If you checked on the “Launch No-IP DUC” option during installation, you should see the No-IP window after the installation. Alternatively, you may launch the No-IP DUC from the No-IP program group.
The No-IP DUC is not configured to start automatically during Windows startup. To set theNo-IP DUC to start during Windows startup, click on the “Options” button.
How to Install and Configure XAMPP on Your Windows PC
• Check on the “Run on startup”or “Run as a system service” option to enable the No-IP DUC to start during Windows startup.
• It is also a good idea to check on the “Require password to restore window from system tray” field and enter a password to disallow other users from meddling with the No-IP settings if your computer is shared.
• Click on the “OK” button to save the changes.
Creating No-IP.com Hosts
After you have logged into your No-IP.com account, you should see the welcome screen above. Click on the “Add a host” link or button to continue.
How to Install and Configure XAMPP on Your Windows PC
Launch the No-IP DUC. You should see your list of hosts in the NO-IP window.
Check on any unchecked hosts to synchronise your IP address to the hosts.
DynDNS.com
DynDNS.com is very similar to No-IP.com. Like No-IP.com, it comes with a free dynamic DNS service with 5 free hosts and a couple of paid services. However, the free service does not come with port 80 redirects and the DynDNS update client has less options than the No-IP update client.
Creating a DynDNS.com Free Account
• Go to http://www.dyndns.com.
• Click on the “Join NOW” button on the top right to create a free account.
How to Install and Configure XAMPP on Your Windows PC
• Click on the “Install” button to continue.
• Check or uncheck the “Run DynDNS Updater” option.
• Click on the “Finish” button to complete the installation.
If you checked on the “Run DynDNS Updater” option during installation, you should see the DynDNS Updater window after the installation. Alternatively, you may launch the N DynDNS Updater from the DynDNS Updater program group.
How to Install and Configure XAMPP on Your Windows PC
The DynDNS Updater is not configured to start automatically during Windows startup. To set the DynDNS Updater to start during Windows startup, click on the “Advanced” link.
• Check on the “Start Updater with Windows” option to enable the DynDNS Updater to start on Windows startup.
• Click on the “OK” button to save the changes.
Creating DynDNS.com Hosts
After you have logged into your DynDNS.com account, you should see the welcome screen above. Click on the “Add Host Services” link to continue.
How to Install and Configure XAMPP on Your Windows PC
Launch the DynDNS Updater. You should see your list of hosts in the DynDNS Updater window.
• If the current status of your DynDNS Updater is not “Good”, click on the red icon on the bottom left to fix it. You should see a green “Good” icon after doing so.
• Check on your Dynamic DNS Hosts.
• Click on the “Apply” button to update your Dynamic DNS Hosts with your latest IP address.
How to Install and Configure XAMPP on Your Windows PC
Testing Your Dynamic DNS Hosts
You cannot test your dynamic DNS hosts in your browser if you are using the same internet connection as the hosts. You could test your hosts if you have access to another internet connection. For example, you could go to a place with wireless internet to try to access your hosts.
If this is not possible or inconvenient, you could ask a friend for help. I try to find a friend to help me test my hosts on my Windows Live Messenger. Simply copy and paste the URLs of the hosts to your friend and ask them if they see your web sites in their browsers.
Your web site's loading speed is dependent on your internet connection's upload speeds. Don't be surprised if your web sites load very slowly on your visitors' browsers. Most internet connection subscriptions were designed for fast downloads, not fast uploads.
This is how my XAMPP looks like through my friend's internet explorer. Notice the “No-IP.com” footer at the bottom of the page and “Vincent's XAMPP” in the tab's title. This was created with No-IP.com's Port 80 redirect with the URL masking and page title options enabled.