User Tools

Site Tools


php:php-apache-on-windows

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
php:php-apache-on-windows [2015/12/23 07:30] – [step by step install] adminphp:php-apache-on-windows [2022/10/29 16:15] (current) – external edit 127.0.0.1
Line 2: Line 2:
 ===== Install php, apache on windows ===== ===== Install php, apache on windows =====
 ==== prepare environment for installing ==== ==== prepare environment for installing ====
-prepare environment for running PHP if you only download package which only contain PHP command lines, not PHP package installer. You need to install **Visual C++ Redistributable for Visual Studio**(one of versions 2010,2012,2013,2015). +prepare environment for running PHP if you only download package which only contain PHP command lines, not PHP package installer. You need to install **Visual C++ Redistributable for Visual Studio**(one of versions 2010,2012,2013,2015) from https://www.microsoft.com/en-us/download/details.aspx?id=49984
  
 And you must use the same version visuall studio for building PHP and Apache(Because you run PHP as PHP-apache module which is built from PHP): And you must use the same version visuall studio for building PHP and Apache(Because you run PHP as PHP-apache module which is built from PHP):
Line 10: Line 10:
   * vs2013   * vs2013
   * vs2015   * vs2015
-==== step by step install ==== +==== Basic Steps to install ==== 
-  - Step1: Install PHP package for **thread safe** (thread safe version **contain apache2 module**) with extra options +(PHP 5.6 and Apache 2.4 compiled with VC11) 
-  - Step2:Install Apache version base on **apache2 module** which contain in PHP package from http://www.apachelounge.com/download/<code>+  - Install Visual C++ Redistributable for Visual Studio 2012(VC11) http://www.microsoft.com/en-us/download/details.aspx?id=30679# 
 +  - Install PHP package for **thread safe** (thread safe version **contain apache2 module**) with extra options 
 +  - Install Apache version base on **apache2 module** which contain in PHP package from http://www.apachelounge.com/download/<code>
 apache_2.2.14-win32-x86-no_ssl.msi apache_2.2.14-win32-x86-no_ssl.msi
 Network Domain: home-vn.com.vn Network Domain: home-vn.com.vn
 </code> </code>
-  - Step3: test apache by go to link http://192.168.1.3/ => output:<code>+  - Test apache by go to link http://192.168.1.3/ => output:<code>
 => It works! => It works!
 </code> </code>
-  - Step4: Change configure of httpd.conf for calling PHP as module<code>+  - Change configure of httpd.conf for calling PHP as module<code>
 AddType application/x-httpd-php .php AddType application/x-httpd-php .php
 DirectoryIndex index.php index.htm index.html DirectoryIndex index.php index.htm index.html
Line 25: Line 27:
 LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll" LoadModule php5_module "C:/Program Files/PHP/php5apache2_2.dll"
 </code> </code>
-  - step5: Change config of php.ini for loading modules which connecting to MySQL server(**must change extension_dir**):<code>+  - Change config of php.ini for loading modules which connecting to MySQL server(**must change extension_dir**):<code>
 extension_dir = "C:\Program Files (x86)\php-5.4.40\ext" extension_dir = "C:\Program Files (x86)\php-5.4.40\ext"
 [PHP_MYSQLI] [PHP_MYSQLI]
Line 32: Line 34:
 extension=php_pdo_mysql.dll extension=php_pdo_mysql.dll
 </code> </code>
-  - Step6: create phpinfo.php for checking modules which loaded by PHP:<code php>+  - Create phpinfo.php for checking modules which loaded by PHP:<code php>
 <?php <?php
 phpinfo(); phpinfo();
 ?> ?>
 </code>And check by go to http://192.168.1.3/phpinfo.php </code>And check by go to http://192.168.1.3/phpinfo.php
-  - Step7: Modify httpd.conf to enable mod rewrite:<code>+  - Modify httpd.conf to enable mod rewrite:<code>
 LoadModule rewrite_module modules/mod_rewrite.so LoadModule rewrite_module modules/mod_rewrite.so
 </code> </code>
 +==== Install Apache from binary directory ====
 +  - Step1: Download Apache binary from http://www.apachelounge.com/download/(Base on OS 64bits or 32bits)
 +  - Step2: Extract download file to drive C on windows. For example:c:\Apache24
 +  - Step3: Change **ServerRoot** config in **httpd.conf** If you extract Apache binary to another directory:<code>
 +ServerRoot "c:/Apache24"
 +</code>
 +  - Step4: Install httpd as an service:<code>
 +httpd.exe -k install
 +</code>After install, you can check service name in services.msc and see it. And to uninstall<code>
 +httpd.exe -k uninstall
 +</code>
 +  - Step5: Run to test httpd:<code>
 +httpd.exe
 +</code>
 +==== Config virtual host on Apache ====
 +  - Step1: Edit httpd.conf to add new config file for virtual host:<code bash>
 +# Virtual hosts
 +Include conf/extra/httpd-vhosts.conf
 +Include conf/vhosts/*.conf
 +</code>
 +  - Step2: create file **conf/vhosts/home.conf** to include config other virtual hosts<code bash>
 +<VirtualHost *:80>
 +    DocumentRoot "E:/web/dacsan-opencart"
 + ServerName dacsan.babies.vn
 + DirectoryIndex index.php index.html index.htm
 + <Directory E:/web/dacsan-opencart>
 +        Options Indexes FollowSymLinks MultiViews
 +        AllowOverride all
 +        Order Deny,Allow
 +        Allow from all
 +    </Directory>
 + SetEnv APPLICATION_ENV development
 + ErrorLog "logs/dacsan-opencart-error.log"
 + CustomLog "logs/dacsan-opencart-access.log" common
 +</VirtualHost>
 +<VirtualHost *:80>
 +  DocumentRoot "E:/web/baotam"
 + ServerName baotam.vn
 + DirectoryIndex index.php index.html index.htm
 + <Directory E:/web/baotam>
 +        Options Indexes FollowSymLinks MultiViews
 +        AllowOverride all
 +        Order Deny,Allow
 +        Allow from all
 +    </Directory>
 + SetEnv APPLICATION_ENV development
 + ErrorLog "logs/baotam-error.log"
 + CustomLog "logs/baotam-access.log" common
 +</VirtualHost>
 +</code>
 +==== Some errors and fix ====
 +  - Error 1:<code>[authz_core:error] client denied by server configuration
 +</code> => Fix follow tutorial in link: http://httpd.apache.org/docs/2.4/upgrading.html#access.In this example, to config all requests are allowed:
 +    * 2.2 configuration:<code bash>
 +Order allow,deny
 +Allow from all
 +</code>
 +    * 2.4 configuration:<code bash>
 +Require all granted
 +</code>
 +  - Error2:Can't load php_curl.dll when config loading it in php.ini(in PHP5.6 64bits on windows 7) => copy 3 files: **libssh2.dll, ssleay32.dll, libeay32.dll** to directory **c:\windows\system32**
 ===== Install XAMPP ===== ===== Install XAMPP =====
 refer: https://www.apachefriends.org/index.html refer: https://www.apachefriends.org/index.html
php/php-apache-on-windows.1450855822.txt.gz · Last modified: 2022/10/29 16:15 (external edit)