Page 1 of 1

Installing MySQL, Apache, Php and Composer on Windows - resume to not lose time

Posted: Wed Mar 24, 2021 7:08 pm
by axew3
MySQL:
get MySQL Community version for Windows and install following procedure:
https://dev.mysql.com/downloads/installer/

Apache, get one from here:
https://httpd.apache.org/docs/current/p ... .html#down
unzip into a folder, then open the http.conf and may setup the path to htdocs to be what you like or leave the default.
Test that it is working.
Open C:\Program Files (x86)\Apache Software Foundation\Apache2.4\bin\
and run ApacheMonitor.exe, start Apache, if all ok, point to http://localhost the browser to check that it is all working.

Php
if visual studio https://visualstudio.microsoft.com/
More recent versions of PHP are built with VC15 or VS16 (Visual Studio 2017 or 2019 compiler respectively) and include improvements in performance and stability.
- The VC15 and VS16 builds require to have the Visual C++ Redistributable for Visual Studio 2015-2019 x64 or x86 installed
has been installed as x64:
Php download https://windows.php.net/download/ (choose x64 Thread Safe or x32 Thread Safe, based on Visual studio install).
Php folder require to be installed/deployed into (for x64)
C:\Program Files

if as x32
into
C:\Program Files (x86)

The php.ini setting need to point to correct ext folder, so something like:
extension_dir = "C:\Program Files\Php8\ext"
to log php errors into a file:
;error_log = syslog
error_log = "C:\Program Files\Php8\errorslog.txt"
(do not know if the file do not exist, if it is automatically created, not tested, i created one errorslog.txt manually into C:\Program Files\Php8)

In Windows -> Control Panel -> System -> Advanced Settings -> Environment Variables -> System Variables -> Path
add the path to the Php folder at the end of the line, adding semi-colon before (used to separate different path values), like so:
;C:\Program Files\Php8

if on php8 or php7, Apache httpd.conf need to contain these lines, just after others modules declarations:

Code: Select all

#Php8
LoadModule php_module "C:\Program Files\Php8\php8apache2_4.dll"
PHPIniDir "C:\Program Files\Php8"
#Php7
#LoadModule php7_module "C:\Program Files\Php7\php7apache2_4.dll"
#PHPIniDir "C:\Program Files\Php7"

AddType application/x-httpd-php .php
use the one for Php7 or the one for Php8

Composer: (if you want)
To install composer and do not get error OCI.dll not found or others errors, this is how it look my actual php.ini about extensions (note disabled):

Code: Select all

extension=bz2
extension=curl
extension=ffi
extension=ftp
extension=fileinfo
extension=gd2
extension=gettext
extension=gmp
extension=intl
extension=imap
extension=ldap
extension=mbstring
extension=exif      ; Must be after mbstring as it depends on it
extension=mysqli
;extension=oci8_12c  ; Use with Oracle Database 12c Instant Client
extension=odbc
extension=openssl
;extension=pdo_firebird
extension=pdo_mysql
;extension=pdo_oci
extension=pdo_odbc
extension=pdo_pgsql
extension=pdo_sqlite
extension=pgsql
extension=shmop

To setup custom domain name or subdomains

Open file:
C:\Windows\System32\drivers\etc\hosts
with a text editor, and add something like this (change with your custom domain name):

Code: Select all

localhost  w3host.com
127.0.0.1  subdomain.w3host.com
save.

Then open:
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\httpd.conf
and activate virtual hosts removing the prepending #

Code: Select all

# Virtual hosts
Include conf/extra/httpd-vhosts.conf
So setup domain and subdomain into virtualhosts file:
C:\Program Files (x86)\Apache Software Foundation\Apache2.2\conf\extra\httpd-vhosts.conf
just on bottom, i will add for this example something like:

Code: Select all

#NameVirtualHost *:80
<VirtualHost *:80>
# ServerAdmin alias@example.com
 #DocumentRoot "C:\HTDOCS"
# ServerName w3host.com
# ErrorLog "logs/www.w3host.com-error_log"
# TransferLog "logs/localhost-access_log"
</VirtualHost>
<VirtualHost *:80>
# ServerAdmin alias@.example.com
 DocumentRoot "C:\HTDOCS\subdomain"
 ServerName subdomain.w3host.com
</VirtualHost>
Restart Apache.