Sunday, November 2, 2014

Upgrades AppServ to Apache2.4 and php 5.6.2

   Since most php learners start under AppServ (well, at least in my social circle), they might build their projects under Appserv until someday they found AppServ are way too old version on php and mysql. Recently, as I tried to import some sdks, I found really frequently that my php version is old, and I can't import sdks under such an old version of php.

    As I upgraded my AppServ, I found it's kinda tricky and I want to write it as a guide. Hope other people who find this article can upgrade their php version painlessly.

    Suppose that the original AppServ located at D:\AppServ\ ; Apache is at D:\AppServ\Apache\

    1. Pre-works, Export all your databases and user information from phpmyadmin.
        Stop your Apache server and MySQL Service. You can find it in the startup>AppServ>Control Server By Sevice, just execute stop script as the administrator.


    2. Download the Apache 2.4, php 5.6.2 "thread safe", MySQL 5.6.21 and PhpMyAdmin 4.2. Notice that you need to download the corresponding version of your system structure. If your server is 32-bit then download x86 version, else if your server is 64-bit then download x64 version. In this article, I do the x64 version.
        PHP: http://windows.php.net/download/
        Apache: http://www.apachelounge.com/download/
        MySQL: https://dev.mysql.com/downloads/installer/
        PhpMyAdmin: http://www.phpmyadmin.net/home_page/downloads.php


    3. Change the name of the original Apache folder, so you can recover your server when the installation failed. And then extract the folder "Apache24" from "httpd-2.4.10-win64-VC11.zip" to the directory where the original Apache located. In this case, extracted Apache24 to D:\AppServ\.

         Find startup scripts at startup>AppServ>Control Server By Sevice, there are three scripts for original Apache, named "Apache Restart", "Apache Start" and "Apache Stop". Change the target to the new Apache directory and the arguments from Apache2.2 to Apache2.4 in the properties option.

        Now execute the script "Apache Start" as the administrator. After the console disappear, try to connect to http://127.0.0.1/; the browser shows "It works!", if the Apache works fine. Then you can stop your Apache server temporary.


    4. Change the name of the original php folder, so you can recover your server when the installation failed. And extract all stuff from "php-5.6.2-Win32-VC11-x64.zip" to "D:\AppServ\php5".

        Then you can find "php.ini-development" in the directory, D:\AppServ\php5\, which you just made. Change the file name "php.ini-development" to "php.ini". And edit that file, find the line "extension_dir", make it as extension_dir = "D:/AppServ\php5\ext". Remember to remove the semi-colon in the beginning of the line.


    5. Edit the file, D:\AppServ\Apache24\conf\httpd.conf. Search "LoadModule", append following lines:
    LoadFile D:/AppServ\php5\php5ts.dll
    LoadModule php5_module D:/AppServ\php5\php5apache2_4.dll
    PhpIniDir D:/AppServ\php5\php.ini
    addtype application/x-httpd-php .php .html


       Search DocumentRoot, change DocumentRoot "D:\AppServ\Apache24\htdocs" to DocumentRoot "D:\AppServ\www".

        Search DocumentIndex, change DocumentIndex index.html to DocumentIndex index.php index.html.

        And start your Apache again, browse http://127.0.0.1/phpinfo.php; the new version phpinfo shows if your php works fine.


    6. Change the original MySQL folder name, so you can recover your server when the installation failed.

        Execute "mysql-installer-community-5.5.40.1.msi" which you have downloaded. After Installed it, you will have MySQL Installer Community in your server which can be found in startup list.

        Execute MySQL Installer Community. Choose add, and install MySQL Server only. After the Next, customize your installation, select the path to the original MySQL directory. In my case, it is D:\AppServ\MySQL.


    7. After MySQL installation finished, change the original phpmyadmin folder name, so you can recover your server when the installation failed.

        And extract the folder "phpMyAdmin-4.2.10.1-all-languages" from "phpMyAdmin-4.2.10.1-all-languages.zip" to the directory where the original phpmyadmin located. In my case, it is D:\AppServ\www\.

        The extracted folder named "phpMyAdmin-4.2.10.1-all-languages", so don't forget to change it as "phpMyAdmin".


    8. Edit php.ini, search "extension=". As you can see, there are a lot of php extensions. You can give them a glance, de-comment those extensions you need indeed. If you are not sure which of them needs to be de-comment, just refer to the php.ini in C:\Windows\php.ini.

        In here, you will need to de-comment the lines
extension=php_mbstring.dll
extension=php_exif.dll      ; Must be after mbstring as it depends on it
extension=php_mysql.dll
extension=php_mysqli.dll

        So your php and mysql can cooperate well.


    9. After step 6, step 7 and step 8, execute the script "Apache Restart". And browse http://127.0.0.1/phpMyAdmin/, the new phpmyadmin interface shows if your mysql and phpmyadmin works fine.

        If your phpmyadmin works fine, the last step you need to do is import the databases and user information with phpmyadmin.

    After all these efforts, your AppServ is successfully upgraded. You are no more bounded with the old version php!


Cheers!


*Note: You got to upgrade php accompany with Apache, since the php later than 5.4 needs Apache 2.4. And the newer php version doesn't compatible with the old phpmyadmin, so the phpmyadmin upgrade are need indeed. Nevertheless, newer phpmyadmin needs newer MySQL, that's why we got to upgrade all components of the server.

[Reference]
http://www.cc.net.tw/2014/02/2622/
http://www.apachelounge.com/viewtopic.php?t=724