Building an environment without XAMPP on Windows

I usually use the portable version of XAMPP on Windows. Previously, I used to install the portable version of XAMPP for each PHP version separately, but since I don’t use the MySQL (MariaDB) or Perl (Strawberry Perl) bundled with XAMPP and instead install them separately, only Apache is launched from XAMPP.

However, with each PHP version upgrade, it became cumbersome to unzip and arrange XAMPP, leading to an accumulation of unused files and inconvenience in transferring or switching configurations. Moreover, recently, new PHP versions have been released less frequently.

Therefore, I researched and tried to see if a similar method could be applied on Windows, like using FastCGI to switch PHP versions as done on Ubuntu. As a result, I was able to achieve it, so this time I would like to share that method.

Installing Apache

Download Apache
https://www.apachelounge.com/download/

Copy the unzipped ZIP file to the folder where you want to run Apache.
(e.g. C:\localserver)

Initial configuration of Apache

If you have expanded to C:\localserver\Apache24, edit C:\localserver\Apache24\conf\httpd.conf.

Virtual host configuration

httpd.conf

Edit conf/extra/httpd-vhosts.conf to configure virtual hosts
(e.g. add localhost)

Enable HTTPS connections

httpd.conf

If Apache does not start, check if there are any certificate-related files in the specified folder.

Enable PHP

Download the Thread Safe version of PHP in ZIP, unzip and extract to your location.
(e.g. C:\localserver\php8.2)

conf/extra/httpd-php.conf and create,

Add and save the file.

In httpd.conf

Add.

Install multiple versions of PHP and switching on each virtual host

Setting up multiple versions requires ‘mod_fcgid (FastCGI ASF module)’, download from Apache Lounge.
https://www.apachelounge.com/download

mod_fcgid
FastCGI ASF module
[mod_fcgid] mod_fcgid-2.3.10-win64-VS17.zip

Unzip the downloaded module ZIP package. Enter the mod_fcgid-* (* is details such as version) folder. Open the mod_fcgid folder and copy the mod_fcgid.so file to your Apache module directory, such as C:∕localserver∕Apache24∕modules.

Open httpd.conf and

Enable the FastCGI module.

VirtualHost configuration: for each virtual host, add a setting specifying the PHP version to be used. This is added to each VirtualHost section in the conf file.

FastCGI configuration: configure FastCGI settings. Start a FastCGI process for each PHP version and configure it to accept requests on the respective port.

コメント

タイトルとURLをコピーしました