How do I install Apache with PHP support and the MySQL server on Windows without using any ready-to-use packages like WAMPServer or XAMPP ?
Active6 months ago
user256743
2 Answers
First, I recommend you read the Platform Specific Notes of Apache for Windows - it explains some Windows-specific features like running as a service that you don't have on other OSes and you probably have never used before.
How to Install and Configure Apache 2 on Windows by Christopher Heng, thesitewizard.com. Many webmasters choose to install a copy of the Apache web server on their machines so that they can test their PHP and Perl scripts before they upload it to their 'live' websites. This allows them to fix any problems on their site before it actually affects their website's visitors.
As mentioned in these platform specific notes, Apache doesn't provide binaries for Windows, however they have links to several third-party sites that provide binaries, for example Apache Lounge.
From that website, we can download either the 32-Bit version (win32) or the 64-Bit one (Win64) - if your OS is 64-Bit you should always try to install 64-Bit versions of software, but note that you'll need to use 64-Bit modules as well, that means if you only have a 32-Bit module then download the 32-Bit Apache.
Here's the version that I used when writing this : Apache 2.4.10 Win64. The latest version when this answer was last updated: Apache 2.4.38 Win64 (look at the edit date at the bottom of the post).
Once downloaded, just extract the
Apache24 folder to the root of your hard drive, so that you have a path like C:Apache24bin .
Open a command line window (Windows+R and type
cmd then press Enter), change directory into C:Apache24bin and run httpd.exe , normally it shouldn't print any errors.
If you get an error dialog stating that
MSVCR110.dll is missing on your system, you'll need to install the Visual C++ Redistributable for Visual Studio 2012 - as always, when prompted, select the appropriate bit-version : vcredist_x86.exe for 32-Bit systems and vcredist_x64.exe for 64-Bit ones.
If you get an error saying that it can't bind to port 80, check if another application uses that port - also Skype is known to use ports 80 and 443 by default; uncheck 'Use port 80 and 443 as alternatives for incoming connections' in its advanced connection settings, restart Skype to apply the changes, and then you should be able to start Apache without issues.
A warning like
Could not reliably determine the server's fully qualified domain name can be ignored for now.
Windows Firewall may prompt you to allow Apache to communicate on specific networks, I recommend you use the default settings : allow it on home and work networks, but not on public/untrusted networks.
Then, open a browser and browse to
http://localhost , if you see a page saying It works ! then it means your Apache installation is working.
You can now stop the currently running Apache by pressing Ctrl+C in the command prompt.
If you got a warning about not being able to determine the system's fully qualified domain name, fix it by editing
C:Apache24confhttpd.conf and editing the ServerName variable (it should be already there in a comment, just uncomment it and change it) :
Replace
<yourhostname> with either the system's host name or localhost .
Finally, if you want to run the server automatically when the system starts (even if nobody logs in), you'll need to run it as a service - in a new elevated (as an administrator) command prompt, type :
That's it, now you have a new service in Services (Windows+R then type 'services.msc' then press Enter) named 'Apache2.4' that you can control just like any other Windows service.
Restricting Apache access to
|
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |