Tags

, , ,

How to install Apache, PHP, MySQL in Windows manually

STEP 1 Install Apache
Download Apache 2.4 binaries here at http://www.apachelounge.com/download/
e.g For 64 bit http://www.apachelounge.com/download/VC14/binaries/httpd-2.4.25-win64-VC14.zip

Extract the downloaded file in your drive C:

$ cd \Apache24\bin
$ httpd -k install (or if using Git bash use ./httpd)
$ httpd -k start

If you got an error that says “…error while loading shared libraries: VCRUNTIME140.dll: cannot open shared object file: No such file or directory”
We need to install the first the run-time Visual C++ Redistributable for Visual Studio 2015: vcredist_x64.exe(64bit), vcredist_x86.exe(32bit)
Go here to download the file https://www.microsoft.com/en-ph/download/details.aspx?id=48145

Next open your browser and type http://localhost/
You’ll see a message “It works!”

Problem:
Installing the ‘Apache2.4’ service
(OS 5)Access is denied. : AH00369: Failed to open the Windows service manager, perhaps you forgot to log in as Adminstrator?
Solution:
You should run the command prompt as administrator.
Find Start > All programs > Accessories > Command Prompt, right click, and select ‘Run as administrator’.

STEP 2 Install PHP
Go to http://windows.php.net/download/ and download the stable thread safe release. Choose x64 for 64-bit OS or x86 for 32-bit OS.
e.g. http://windows.php.net/downloads/releases/php-5.6.30-Win32-VC11-x64.zip

Note: Make sure that your Apache and PHP should matched with their bit either 64 or 32-bit.

STEP 3 Configure Apache and PHP
Extract the downloaded file in your drive C:
Edit the file httpd.conf from C:\Apache24\conf and add the ff. lines:

...
LoadModule php5_module "C:/php-5.6.30-Win32-VC11-x64/php5apache2_4.dll"
AddHandler application/x-httpd-php .php
PHPIniDir C:/php-5.6.30-Win32-VC11-x64
ServerName localhost
...
...

In the same file. Search for the line starting DirectoryIndex. Change it as follows:

DirectoryIndex index.php index.html

Now, navigate to C:\php-5.6.30-Win32-VC11-x64, and copy php.ini-development to php.ini. Edit this file, find the following lines and modify them as follows (all should exist already):

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

## Next, add or uncomment(remove the ; ) the extension_dir and its extension DLL files.

extension_dir = "C:\php-5.6.30-Win32-VC11-x64\ext"
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

## Enable the error reporting level for debugging purposes in DEV environment.
error_reporting: E_ALL

Everytime there’s a changes in the config we need to restart the server.
$ httpd -k restart

STEP 4 Test and debug
Navigate to C:\Apache24\htdocs and create a file called phpinfo.php
<!–?php phpinfo();
Then type this url in your browser: http://localhost/phpinfo.php you should see the PHP information.

STEP 5
Download mysql at https://dev.mysql.com/downloads/windows/
You can use the installer(.exe/.msi) version.

If you’re using the zip version then follow this steps.
1. Create a my.ini file inside the mysql root directory.
Sample config file looks like this:

[mysqld]
# set basedir to your installation path
basedir="/mysql-5.7.21-winx64"

# set datadir to the location of your data directory
datadir="/mysql-5.7.21-winx64/data"
port = 3306

server_id = 1
log_error = "mysql_error.log"
pid_file = "mysql.pid"

# Optional - Default Configuration
max_allowed_packet = 8M
key_buffer_size=16M

plugin_dir = "/mysql-5.7.21-winx64/lib/plugin/"

2. Next, initialize the mysql using default username “root” without a password.
$ mysqld –initialize-insecure

3. Next run the mysqld
$ mysqld or ./mysqld (if using a bash shell)

To shutdown the mysql server.
$ mysqladmin -u root shutdown or ./mysqladmin -u root shutdown (if using bash shell)

Download phpmyadmin using Composer.

$ composer create-project phpmyadmin/phpmyadmin --repository-url=https://www.phpmyadmin.net/packages.json --no-dev

If you want to setup a virtual host follow this steps:
Setup a virtual host

Advertisements