Download
You can download the required installer via links given below:
- Apache for Windows: https://www.apachelounge.com/download/
- PHP 7 for Windows (select Thread Safe): https://windows.php.net/download/
- MariaDB for Windows: https://downloads.mariadb.org/
- FakeSMTP (needed for Windows) http://nilhcem.com/FakeSMTP/download.html
MariaDB
- Firstly install MariaDB server
- If you needed you can change port during installation process. If you changed it then you improve you must connection string in PHP.
Apache 2.4 server
Install the latest C++ Redistributable Visual Studio 2017: https://www.microsoft.com/en-in/download/details.aspx?id=48145
- Unzip downloaded Apache archive to the
C:\Apache24\
(or somewhere else) directory. After unzipping, go to the folder
C:\Apache24\conf\
and open thehttpd.conf
file by any text editor.-
In this file change this line
# ServerName www.example.com:80
with
httpd.conf
ServerName localhost
Find all occurrences of
AllowOverride None
and change them toAllowOverride All
Enable mod_rewrite by uncomment following line
#LoadModule rewrite_module modules/mod_rewrite.so
Register Apache service
- open console and go to Apache directory
cd Apache24/bin
- then type following command
httpd -k install
- now you can see Apache service in Services
Some PRO tips
Change your DocumentRoot
- You can change default directory where Apache will be looking for websites
DocumentRoot "L:/"
<Directory "L:/">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
Add custom virtual hosts w/ local domains
- You can also create virtual host with custom local domain for each your projects. Append following to
httpd.conf
file (for each project):
<VirtualHost 127.0.0.1:80>
ServerAdmin your.name@gmail.com
DocumentRoot "L:/MyProject"
ServerName www.myproject.loc
ServerAlias myproject.loc
ServerAlias www.myproject.lc
ServerAlias myproject.lc
ErrorLog "logs/myproject.log"
</VirtualHost>
- Then you must edit the
hosts
file, in Windows is located inC:\Windows\System32\drivers\etc
. In this file append following line127.0.0.1 www.myproject.loc myproject.loc www.myproject.lc myproject.lc
Change Apache default port
- You can change default port where Apache server will be listen
- just change
Listen 80
to e.g.Listen 8008
- and restart service
- just change
- From now you see your website on http://localhost:8008/
PHP
- Unzip downloaded PHP archive to the
C:\php7\
(or somewhere else) directory. - Rename or copy
php-ini-development.ini
tophp.ini
- Open
php.ini
and edit:- Find section Dynamic Extensions and uncomment extension which you want to load, here is listing good base of enabled extensions: bz2, curl, fileinfo, intl, imap, mbstring, mysqli, openssl, pdo_mysql, pdo_sqlite, sqlite3, xsl
- Then change SMTP port to
smtp_port = 2525
-
Add PHP in system environment variable.
- in cmd type
setx path "%PATH%, C:\php7" /M
- in cmd type
-
Open Apache configuration file (
c:\Apache24\conf\httpd.conf
) again- and append following lines:
PHPIniDir "C:/PHP7"
AddHandler application/x-httpd-php .php
LoadModule php7_module "C:/PHP7/php7apache2_4.dll"
- Then change DirectoryIndex from
index.html
to:
<IfModule dir_module>
DirectoryIndex index.php
</IfModule>
FakeSMTP
- FakeSMTP is Java application which simulate SMTP server for local developing on Windows.
- You can start it with following command:
start java -jar C:\sw\faceSMTP\fakeSMTP-2.0.jar --start-server --background --port 2525 --bind-address 127.0.0.1 --output-dir L:\_emails
- Or you can create command file (e.g.:
fakesmpt.cmd
) with following content:
@echo off
start java -jar C:\sw\faceSMTP\fakeSMTP-2.0.jar --start-server --background --port 2525 --bind-address 127.0.0.1 --output-dir L:\_emails
exit
Top comments (3)
Thanks, Antonin, I love the domain aspect with apache.
[UPDATE]
Try to check if PHP is installed successfully:
and you'll get the current version of PHP.
However, you might get extension errors:
This is due to fail extension_dir path. To fix this, comment out the
extension_dir
for windows inside php.ini file.You can CTRL F to find extension_dir line.
Trying to install php8, this needs to be changed:
LoadModule php7_module "{path to php 8}"
To:
LoadModule php_module "{path to php 8}"
Tell me about more from libmysql.dll...
In my opinion you must:
copy dll to the Apache bin directory
or
add to path of dll to the PATH
or
add a "LoadModule /libmysql.dll" row to the httpd.conf
else the Apache cannot find the neccessary dll and throw an error.