Categories
guides

Manually Installing Apache/MySQL/PHP on Windows (DEV ONLY)

For Development Only

I’m not a security expert, but I try to be security conscious. This guide was created for the purpose of local development on my own computer, not to host any site that any other computer would connect to. There was no security precautions taken, and this should not be presumed to be a guide to setup a networked or publicly accessible server. That said…

Advantages

Manual installation allows you to cherry pick which versions you want to install, and even setup combinations like Apache 2.2 with PHP5, and Apache 2.4 with PHP7, then switching between them as you desire. I used this primarily for WordPress development, adjustments may need to be made if that isn’t your intent.

Downloads

  • Download desired MySQL version(s)
  • Download desired Apache version(s)
    (note Visual Studio C++ compatibility [VC##] and bit [x64 or x86], match with PHP)
  • Download desired PHP version(s), choose thread safe
    (note Visual Studio C++ compatibility [VC##] and bit [x64 or x86], match with Apache)
  • Download desired phpMyAdmin version(s)
    (MySQL <= 5.1 requires phpMyAdmin 4.0.10.20 or earlier)
  • Download OpenSSL package (Match x64 or x86)

Installing MySQL

Install MySQL using wizard, if installing multiple versions, consider naming service with version number.

Installing Apache

Unzip Apache, name folder appropriate to version, and place at C:\ (ie C:\24-VC11)

Installing PHP

Unzip PHP, name folder appropriate to version, and place at C:\ (ie C:\PHP5)

Configuration

Edit C:\[apacher folder].conf, add these lines for PHP5:

LoadModule php5_module "C:/PHP5/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir C:/PHP5

or these for PHP7

AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .php .html
LoadModule php7_module "c:/php7/php7apache2_4.dll"
PHPIniDir "c:/php7"

Modify DirectoryIndex to be index.php index.html Uncomment/Add Include conf/extra/httpd-vhosts.conf

Update DocumentRoot directive with appropriate path Update following <Directory> directive with appropriate path

Make sure these modules are enabled:

mod_alias
mod_authz_host
mod_deflate
mod_dir
mod_expires
mod_headers
mod_mime
mod_rewrite
mod_log_config
mod_autoindex
mod_negotiation
mod_setenvif

Edit conf/extra/httpd-vhosts.conf file to include:

<Directory "c:/www">
    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
</Directory>
<VirtualHost *:80>
    DocumentRoot /www/
    ServerName locahost
</VirtualHost>

Run elevated command prompt cd to C:[apache folder] httpd -k install -n [desired service name] httpd -k start -n [name chosen above] Verify it works by visiting http://localhost

In C:[php folder], copy php.ini-development to php.ini Update following properties to these values:

memory_limit = 256M
post_max_size = 128M
upload_max_filesize = 128M

Uncomment and set full path of extension_dir extension_dir = "c:/php55/ext"

Uncomment appropriate extensions, such as:

extension=php_curl.dll
extension=php_gd2.dll
extension=php_intl.dll
extension=php_mbstring.dll
extension=mysqli
extension=php_openssl.dll
extension=php_pdo_mysql.dll

extension=php_soap.dll
extension=php_xmlrpc.dll

Unzip OpenSSL package, find these files: – libeay32.dll – ssleay32.dll

Copy those to PHP folder Go to system settings, and edit system (not user) environment variables. Click “Path” and then “Edit”, add PHP folder (C:\PHP7, C:\PHP5) to list, and move that to the top to ensure these versions are used over others.

Installing phpMyAdmin

Unzip folder, and place in default folder (C: if you followed conf instructions above)

Testing

Make sure mysql and apache services are started/restarted Make a file containing a phpinfo(); call to test PHP.

Test MySQL with:

<?php
$servername = "localhost";
$username = "root";
$password = "root";

try {
$conn = new PDO("mysql:host=$servername;dbname=test", $username, $password);

// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    echo "Connected successfully"; 
 }
catch(PDOException $e) {
    echo "Connection failed: " . $e->getMessage();
}

Swapping What is Running

Ctrl Alt Esc to bring up “services”, stop service you don’t want before starting service you do (typically just MySQL and Apache, no services related to PHP)

By bo.

I'm @boyEatsSteak in a lot of places. I have been wanting 🍕 for weeks. I like gadgets and technology and keeping notes and tips for my future self since all I can remember is that I forget things.