Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ahmadshuami/807d7f885f41bf83523f064418046633 to your computer and use it in GitHub Desktop.
Save ahmadshuami/807d7f885f41bf83523f064418046633 to your computer and use it in GitHub Desktop.
## Apache for Windows
- Download and install Apache
- Download at https://www.apachelounge.com
= Download and install vc_redist_x64
= Download httpd-2.4.55-win64-VS17.zip
- Unzip httpd-2.4.55-win64-VS17.zip
- Copy Apache24 folder to C drive
- Open cmd prompt as Administrator
- Go to the C:\Apache24\bin directory
= Enter httpd.exe -k install
= Open Task Manager, go to Services, Look for Apache2.4, then restart the service
= Open your browser, enter localhost
## PHP for Windows
- Download and install PHP
- Download at https://windows.php.net
= Download PHP 8.1 (8.1.*)
=> Make sure the version is VS16 x64 Thread Safe (e.g : php-8.1.15-Win32-vs16-x64.zip)
- Unzip php-8.1.15-Win32-vs16-x64.zip
- Copy extracted folder to C:/Php-8-1-5 (Rename your folder accordingly)
- Rename php.ini-development to php.ini
- Edit the system environment variables
= Search for System Environment Variables
= Select Environment Variables > Edit Path
= Add C:\Php-8-1-5
- Open Task Manager, go to Services, Look for Apache2.4, then restart the service
## Configurations
# Apache
- Open httpd.conf (in C:\Apache24\conf\)
= uncomment load module
--------------------------------------------------------------------------
LoadModule rewrite_module modules/mod_rewrite.so
--------------------------------------------------------------------------
= update ServerName\
--------------------------------------------------------------------------
ServerName mysite.local
--------------------------------------------------------------------------
= update DocumentRoot and Directory accordingly (up to you)
--------------------------------------------------------------------------
DocumentRoot "D:/MyApps"
<Directory "D:/MyApps">
--------------------------------------------------------------------------
= update AllowOverride None
--------------------------------------------------------------------------
AllowOverride All
--------------------------------------------------------------------------
= add index.php in DirectoryIndex
= Add the settings below at the end of the file
--------------------------------------------------------------------------
PHPIniDir "C:/Php-8-1-15"
AddHandler application/x-httpd-php .php
LoadModule php_module "C:/Php-8-1-15/php8apache2_4.dll"
--------------------------------------------------------------------------
# PHP
- Open php.ini (in C:\Php-8-1-15)
- Find and edit the files as below
----------------------------------------------------------------------------------
post_max_size = 20M
extension_dir = "C:\Php-8-1-15\ext"
upload_max_filesize = 20M
extension=openssl
zend_extension=opcache
# extension=php_imagick.dll (must have php imagick first)
cgi.fix_pathinfo=0
opcache.enable=1
----------------------------------------------------------------------------------
- Uncomment below setting (at least)
----------------------------------------------------------------------------------
extension=bz2
extension=curl
extension=fileinfo
extension=gd
extension=gettext
extension=gmp
extension=intl
extension=mbstring
extension=exif
extension=mysqli
extension=openssl
extension=pdo_mysql
extension=pdo_pgsql
extension=pgsql
extension=xsl
----------------------------------------------------------------------------------
- Open Task Manager, go to Services, Look for Apache2.4, then restart the service
## What Next
- Create a new file and save as info.php in D:/MyApps directory
----------------------------------------------------------------------------------
<?php echo phpinfo();
----------------------------------------------------------------------------------
- Open your browser and enter localhost/info.php
## Virtual Hosts
- Open httpd.conf (in C:\Apache24\conf\)
= uncomment virtual hosts
--------------------------------------------------------------------------
Include conf/extra/httpd-vhosts.conf
--------------------------------------------------------------------------
- Open httpd-vhosts.conf (in C:\Apache24\conf\extra\)
- Edit the file
----------------------------------------------------------------------------------
<VirtualHost *:80>
ServerAdmin admin@admin.com
DocumentRoot "D:/MyApps"
ServerName mysite.local
ErrorLog "logs/mysite-error.log"
CustomLog "logs/mysite-access.log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin admin@admin.com
DocumentRoot "D:/MyApps"
ServerName sistem001.local
ErrorLog "logs/sistem001-error.log"
CustomLog "logs/sistem001-access.log" common
</VirtualHost>
----------------------------------------------------------------------------------
- Open Task Manager, go to Services, Look for Apache2.4, then restart the service
- Open Notepad as Administrator
- Open hosts file (in C:\Windows\System32\drivers\etc\)
- Add your servername
----------------------------------------------------------------------------------
127.0.0.1 localhost
127.0.0.1 mysite.local
127.0.0.1 sistem001.local
----------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment