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

Monday, September 22, 2014

project "Shoot" -- library to visualize your tree structure

    Hi there, it has been a long while since last blog I post. Well, forgive me, it was heat break. But I really did something, I will show them. Just be patient :)

----


    Shoot was a small project I wrote to help me visualize some assignments from my data structure class. It have been stay in my disk for a while. Recently, I think maybe it's a good idea to publish it so other students can easily visualize their works. Cuz I really did a search to find if there a easy way to draw my tree structure when I was in course. Unfortunately, I didn't find one, so I made one.



    Originally this project was developed in pure C language, not C++. But I think object-oriented is much better for this project. Because I can define some virtual function and call them directly.

    This project doesn't really takes much my time, most CSS/Javascript are done when I was in course. Interestingly, my internet breaks during developing. And I can't find any reference for some bugs, Fortunately, At the day after, the internet was fixed. So I can finish it.

----

    Here is the link to "Shoot".

    To use this project, you have to inherit your own node class from shoot::TreeNode. And then you need to implements your own queue/heap/tree structure, and some virtual methods in shoot::TreeNode. Including sibling(), child(), hasSibling(), hasChild(), getData().
    Here is some detail I wrote on github before:
            YourTreeNode *sibling() : no argument, return the pointer of this node's next sibling. If there is no next sibling you can return NULL instead.
            YourTreeNode *child() : no argument, return the pointer of this node's first child. If it don't have any child you can return NULL instead.
            bool hasSibling() : no argument, return a boolean that if this node has next sibling. If it is the last sibling in this generation, return false. Otherwise, return true.
            bool hasChild() : no argument, return a boolean that if this node has any child. If it is the leaf node, return false. Else cases, return true.

    Once you finish these methods, the visualize feature is done. All you have to do is call YourTreeNode->generate(filename) .
    But you gonna notice that "shoot.hd" shall be in the same directory as your .exe is. And it needs the internet to access jquery, if you want to make it works offline,  just download jquery from jquery.com/download to the same directory as "shoot.hd" is. And modify the link source at the first line in "shoot.hd".

----

    If you don't know how to import and compile this project correctly, here are the instructions.
        1. Don't forget to include "shoot.h" in your cpp.
        2. After you finished your code, compile the program with "shoot.o"
            ( g++ -o example.out example.cpp shoot.o)
        3. Check if "shoot.hd" is in the same directory as exe is.

----

    Sincerely hope this project and guidance really help you. :)