Setup XAMPP with http2/SSL on localhost
Introduction
XAMPP is the most popular PHP development environment for Windows; today, I will show you how to set up XAMPP with http2/SSL on localhost.
Prerequisites
- A Windows PC
- Basic knowledge of PHP stack
Download XAMPP
Download the latest version of XAMPP at https://www.apachefriends.org/download.html, then install/extract it to a local folder, e.g. D:\xampp
.
Configure MySQL
Edit the D:\xampp\mysql\bin\my.ini
file and add the following lines below the [mysqld]
section:
default-storage-engine=innodb
character-set-server=utf8
Next, change max_allowed_packet
to 10M
and innodb_log_file_size
to 50M
like below:
max_allowed_packet = 10M
innodb_log_file_size = 50M
Configure Apache
Assume that we put our projects in D:\Projects
, so we add that directory in httpd.conf
, open D:\xampp\apache\conf\httpd.conf
, and add the following:
<Directory "D:/Projects">
Options Indexes FollowSymLinks Includes ExecCGI
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Then edit the block <Directory />
like below:
<Directory />
AllowOverride all
Require all granted
</Directory>
Configure PHP
We first made adjustments to the php.ini
file by uncommenting these lines:
extension=php_openssl.dll
extension=php_intl.dll
Next, change some values:
expose_php = Off
upload_max_filesize = 20M
post_max_size = 80M
memory_limit=256M
max_execution_time=300
max_input_time=600
Finally, add this line before Dynamic Extensions:
openssl.cafile="\xampp\perl\vendor\lib\Mozilla\CA\cacert.pem";
Use VirtualHost
Open D:\xampp\apache\conf\extra\httpd-vhosts.conf
and add the following:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot "D:/xampp/htdocs"
ServerName localhost
</VirtualHost>
You can add more VirtualHost for your projects
Enable HTTP2
Open D:\xampp\apache\conf\httpd.conf
and uncomment:
LoadModule http2_module modules/mod_http2.so
Then add the following line:
Protocols h2 h2c http/1.1
Finally, open D:\xampp\apache\conf\extra\httpd-ssl.conf
and edit the SSLCipherSuite
like below:
SSLCipherSuite ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256
MISC
For Long name display, we can add .htaccess
in htdocs, the .htaccess's content:
Options +Indexes
IndexOptions FancyIndexing FoldersFirst NameWidth=* DescriptionWidth=*
You can also make phpMyAdmin expiration time longer by adding this line to D:\xampp\phpMyAdmin\config.inc.php
file:
$cfg['Servers'][$i]['LoginCookieValidity'] = 360000;
Last but not least, add PATH Environment Variable
in Windows:
D:\xampp\php
D:\xampp\mysql\bin
Conclusion
Your local XAMPP development environment is up and running; happy coding!