Archive

Archive for the ‘development’ Category

Install MCrypt for PHP on Windows

November 18th, 2010 3 comments

There are many sites around explaining how to install MCrypt for windows but none seem very straight forward.
I have PHP installed on a windows development machine and I need MCrypt installed.

The default installation might not have mcrypt or you might have missed it shomehow…

If that happens all you need to do it

  1. Go to the php download website and download the windows binary package, (not the installer).
  2. Unzip the file in a folder, (it should create a folder called something like php-5.x.yy-Win32, depending on the version number of php you got.
  3. In that folder there should be a file called “libmcrypt.dll”, copy the file to your php extension folder, (see below if you don’t know where that is).
  4. In that folder there should also be another folder called “ext”, open it and copy the file “php_mcrypt.dll” to your php extension folder.
  5. edit your php.ini file, (see below if you don’t know where that is), and add the line:

    ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;

    extension=php_mcrypt.dll

    Look for other “
    extension=…” to find where to add this line.
  6. Restart your web server, with Apache for example click on the icon on the task bar and select ‘restart’.

Where are my php extensions?

Normally they are located in your program files directory, something like “C:\Program Files\PHP\“, if you are using a non english version of Windows then the name might be different.

If it is not there then create a phpinfo.php test file and look for the path in the various variables, (look for the variables extension_dir as well as PHPRC).

Where is my php.ini file?

Same as above, normally they are located in your program files directory, something like “C:\Program Files\PHP\“, if you are using a non english version of Windows then the name might be different.

If it is not there then create a phpinfo.php test file and look for the path in the various variables, (look for the value “Loaded Configuration File).

What should my phpinfo.php file look like?

Open a blank file with your favourite text editor and type.

<?php
phpinfo();
?>

Save the file as phpinfo.php in your web folder and it should show you all the information you need about your php installation.

Categories: development Tags: , , , , ,

Install, Apache, php and MySQL on Windows

November 11th, 2010 Comments off


The other day I was looking for a tutorial to install Apache, php and MySQL on Windows and I wasn’t really able to find anything that cover most basic issues.
I don’t want to replace my current webserver, (IIS), I want to install Apache next to

Basic notes before we start.

  1. You must be the Administrator on the machine.
  2. This is not a how-to install a website on a server, this is how to install a website on your own development machine, (so some server security settings will be ignored).
  3. It is best to fist follow all the steps as I have listed them and then make changes that fit your needs.
  4. Each step has a ‘test’ to make sure it works, if it did not then don’t go any further, it will only make things worse. Installing PHP will not magically make Apache work.
  5. On an English version of Windows all programs are installed in the c:\program files\ directory, but it it called something else in other languages, (the variable is %programfiles%).
    If you are using a 64 bit machine then the folder is different for 86 bit applications.
    By default the installed will direct you to the program files folder, just pay attention to where that folder is.
  6. I used port number 8001, you can choose another number if you want, (but not 80 or 8080 just yet).
  7. If you have some weird and wonderful firewall you might want to turn it off during the installation, turn it back one once you know it is working. If it does not work with the firewall then you know what needs to be fixed.
  8. Turn off your Anti-virus as well if you don’t think it is clever enough to recognize Apache, PHP or MySQL.
  9. Make a note of all the folders you install things in. Don’t just blindly press ‘next’, ‘next’, …

1) Install Apache

Go to the Apache website and download the latest version, don’t get the ‘Alpha’ or ‘Beta’ version but rather get the one labelled, “the best available version’. I got version  2.2.17, (without crypto).

  1. Run the install and accept all the basic settings.
  2. in Apache folder, (c:\Program Files\Apache Software Foundation\Apache2.2\), look for the http.conf file and edit it, (it is a normal text file).
    1. Change the Listen value:

      #
      # Change this to Listen on specific IP addresses as shown below to
      # prevent Apache from glomming onto all bound IP addresses.
      #
      #Listen 12.34.56.78:80
      Listen 8001

    2. And the change the ServerName value:

      # If your host doesn’t have a registered DNS name, enter its IP address here.
      #
      #ServerName <somedomain>:80

      ServerName localhost:8001
  3. Double click on the Apache icon on the task bar, that will bring up the ‘Apache service monitor’
    The server is running, (if you don’t have IIS installed), or not running, (if there was an issue with IIS).
  4. Select the [Start] or [Restart] button, it should then start ok …
    If it does not start there is a problem, double check the settings. If you are certain that the settings are correct try another port. Instead of 9001 for example, try 8001 or something like that.
  5. Open your web browser and navigate to http://localhost:8001/ you should get a simple message “It works!!!
  6. Change the location of your website to something more developer  friendly.
    in C:\Program Files\Apache Software Foundation\Apache2.2\conf\http.conf change:

    # documents. By default, all requests are taken from this directory, but
    # symbolic links and aliases may be used to point to other locations.
    #
    DocumentRoot “c:/website”

    #
    # This should be changed to whatever you set DocumentRoot to.
    #
    <Directory “c:/website”>
  7. Don’t add a ‘/’ at the end of the path, so don’t write ‘<Directory “c:/website/“>
  8. Create a folder c:/website/, don’t put any files or anything in it.
  9. Restart the Apache server again, (on the task bar, select the apache server, “Open Apache Monitor”, select [Start] or [Restart], it should then start ok…).
  10. Open your web browser and navigate to http://localhost:8001/ you should get a message “Index of /

2) Install PHP

Go to the php.net website and download the latest stable version. Get the windows installer, I got version 5.2.14.

  1. Run the install and accept all the default settings.
  2. During the install you will be prompted to select a server, select Apache 2.2
  3. It will then ask you for the location of the Apache configuration file, select “C:\Program Files\Apache Software Foundation\Apache2.2\http.conf
  4. After the install, double check that the Apache configuration file was updated properly.
    In C:\Program Files\Apache Software Foundation\Apache2.2\http.conf at the end of the file the php installer will have added

    #BEGIN PHP INSTALLER EDITS – REMOVE ONLY ON UNINSTALL
    PHPIniDir “C:/Program Files/PHP/”
    LoadModule php5_module “C:/Program Files/PHP/php5apache2_2.dll”
    #END PHP INSTALLER EDITS – REMOVE ONLY ON UNINSTALL
  5. Edit the php.ini file to display all errors. By default the file is located in “C:/Program Files/PHP/
    Replace, “display_errors = Off” with “display_errors = On“.

    ; To output errors to STDERR with CGI/CLI:
    ;display_errors = “stderr”
    ;
    ; Default
    ;
    display_errors = On
  6. One more time, restart the Apache server, (see above).

2.1) Create a php test file.

  1. Open a blank document
  2. <?php
    echo “Hello from my website”
    ?>
  3. Save the document as “index.php” in your website root folder, (c:/website)
  4. go to http://localhost:8001/index.php
  5. You should see “Hello from my website
    1. If you see the code () then it means you did not restart the Apache service
    2. if you see nothing there might be a type in your code.
    3. Make sure that you have nothing before ”<?php’ and after ‘?>’

2.2 ) Make index.php the default

  1. In Apache configuration file, (“C:\Program Files\Apache Software Foundation\Apache2.2\conf”), Update DirectoryIndex and add add index.php

    #
    # DirectoryIndex: sets the file that Apache will serve if a directory
    # is requested.
    #
    <IfModule dir_module>
    DirectoryIndex index.html index.php
  2. The order is important, if you have both, index.html and index.php in your website then index.html will be displayed.
  3. Restart the Apache server, “Open Apache Monitor”, select [Start] or [Restart], it should then start ok…
  4. Go to http://localhost:8001/ and you should see “Hello from my website
    1. if you see “Index of /” you didn’t restart the Apache service
    2. if you don’t see “Hello from my website” or “Index of /“, do you have an index.html file that is showing?

3) Install MySQL

Go to the MySQL website and download the latest stable version. Get the windows installer, I got version 5.1.52 You can get version 32bit or 64bit. Get the recommended, ‘Essential’  download.

For version 5.2, (and earlier), you also need to download mysql extension (PHP 5.2.0).

  1. Do the typical install and accept all settings.
  2. The last step is to configure

3.1) Configure the MySQL server now.

Select the following, (mostly default), options

  1. Detailed configuration.
  2. Developer machine.
  3. Multifunctional database
  4. Select/Edit “c:\website\data\” rather than the default, (this is easier to locate and/or port to another machine).
  5. DSS/OLAP server instance configuration.
  6. port number 3306.
  7. Best support for Multilingualism, (you will need it at some stage and it does not harm even if you think you won’t need it).
  8. Service name “MySQL”.
  9. Set the root password, (and write it down!). Even for development it is good practice to use a strong password.
  10. Press the ‘Execute …’, (takes a bit of time). You should get no errors.

If you get an error on the last step it is almost because of a security issue, (a Windows/Firewall/Anti virus issue).

3.2 Tell PHP about MySQL.

In the old days PHP would install the MySQL extension by default, in 5.x that changed and you had to download it. In 5.3 it is bundled again.
Either way, make sure that PHP knows how to work with PHP, the following steps might already be done for you by the installer(s), if it is don’t overwrite the settings.

  1. Unzip the mysql extension you downloaded earlier, (http://dev.mysql.com/downloads/mysql/) and copy them to your php directory.
    By default located in c:\program files\php\
    There should be 2 files, libmysql.dll and php_mysql.dll, copy them both.
    If the files already exist, do not overwrite those files.
  2. Edit your php.ini file (By default located in c:\program files\php\php.ini)
    Add the mysql extensions.

    ;;;;;;;;;;;;;;;;;;;;;;
    ; Dynamic Extensions ;
    ;;;;;;;;;;;;;;;;;;;;;;

    extension=php_mysql.dll
  3. On the task bar, select the Apache server, “Open Apache Monitor”, select [Start] or [Restart], it should then start ok…
    1. If Apache does not restart, , did you copy both dlls or just one?
    2. Did you get the right files, (on the download site, did you get the right MySQL version and right php version)?
    3. Did you download the mysqli extension or the mysql extension, (note the extra ‘i’)?

3.3 Create a mysql/php test files.

  1. Open/create a new, empty file.
  2. Type the following
    <?php
    // Report all PHP errors (see changelog)
    error_reporting(E_ALL);

    $con = mysql_connect(‘localhost’,’root’,’<yourpassword>‘);


    if (!$con)
    {
    die(‘Could not connect: ‘ . mysql_error());
    }
    echo “Connected to database!!”;
    ?>

  3. Save the file “c:\website\connect.php
  4. Go to your site and check that you are connected to your MySQL database
    http://localhost:8001/connect.php

    1. If you get ‘Could not connect’, did you put the right user name and password, (replace <yourpassword>)?
    2. If you see nothing at all check your php.ini file to display errors, (see above).
    3. If you see “Call to undefined function mysql_connect()” check your php.ini file for mysql settings. If they look ok, restart Apache again and make sure it has no errors.

Concusion

This should be it, your web server should be up and running, you can now restart your firewall, check that the website is still running, then restart your anti virus.

Once all this is running you can play with various settings, remember that you, (almost always), need to restart Apache once you made a change to the http.conf or php.ini files.

Categories: development Tags: , , ,

Adding crash report information to Courseplanner

May 28th, 2010 Comments off

I finally got around adding a proper crash report to Courseplanner, I do get a couple of reports every months and every time I am faced with the same problem of not having enough information. Thankfully it does not happen very often, but when it does I need to gather as much information as possible.

I am looking at CrashRpt, I used that piece of software a while ago, (when they were on Codeproject) and I was quite happy with it.
Because it is open source and written it C++, it makes it very easy to incorporate in Courseplanner.

I am also looking at other kinds of Crash handling software, especially Google and Firefox, not because I think they are better, but simply because I would be foolish to ignore such big names.

One of the most attractive option they have is the possibility to send the report directly to the website, in the past users were reluctant to send an email, or, in worse cases the emails would be trapped in some spam filter.

I also created a privacy policy page, it basically says that I have no plans to pass any information to any third party. Currently the policy is limited to the crash report, but at some stage I will have to update it to include registration and the forum.

I am planning on releasing it to the beta team later today, (my ftp server is down for some reason).

Installing Wine on ubuntu

April 20th, 2010 Comments off

I was playing around with using Courseplanner on an old unix machine of mine.  Of course you cannot just run a windows application on a ubuntu machine, but thankfully Wine allows you to run such applications.

But be warned a lot of issues have been reported, Wine does not work 100% all the time.
So, before I venture down the road of installing Courseplanner on my ubuntu machine I need to venture down the road of installing Wine.

Start the terminal server (Applications > Accessories > Terminal).
At the command prompt, type

sudo apt-get install wine
[sudo] password for username:

Enter your password, and then wait for the relevant packages to be downloaded, (only 19Mb but for me it took a bit of time for some reason).

When this is done… there is nothing else to do, you can type…

wine –version

To get the version number, but to be fair, this won’t help you much 🙂

Next I need to install Coursplanner…

The “Hello Dolly” of piger

November 25th, 2009 Comments off

I created a small c++ plugin to show the basic architecture of the piger plugin.
WordPress has a very simple plugin that they called ‘Hello Dolly’, this plugin does not really do much apart from randomly displaying a lyric from “Hello Dolly

First things first, download the latest source code of the plugin and we will talk about each files in a bit more details.

The file type:
The file is nothing more than a DLL with an ‘.amp’ extension. So when you create your plugin make sure that the output file has a ‘.amp’ extension.

The files to include:
You need to include 2 files, a header(h) file and a library(.lib) file.
Read more…

Categories: development Tags:

New Piger fourm

November 18th, 2009 Comments off

I finally got around to creating a new forum for Piger, the main purpose of Piger is to make my life easier :). I hate using my keyboard more than I have to, and I hate having to do the same thing over and over again.

So a while ago, (a year ago I think), I created a small tool that simply takes your keyboard input and runs a pre-programmed script accordingly, it can be anything, from launching calculator to login into your favourite website using another browser that your favourite one.

You can write your scripts in LUA, C++, Python, or even DOS (batch).

Note, by default the tool does not write scripts for you, it comes with a few basic scripts but nothing too exiting. So please use the forums if you have any scripting questions.

Categories: development Tags:

Install Ubuntu 9 on Virtual PC 2007 – part trois

September 22nd, 2009 1 comment


There is one last problem with the Ubuntu install, when you update the Kernel it will remove the noreplace-paravirt vga=771 that you added.

This is probably because Ubuntu assumes you made a mistake. Whatever the reason you need to update the menu.lst file.

First of all lets make sure that you read all the previous articles so we are all talking about the same thing.

  1. Install Ubuntu 9 on Virtual PC 2007.
  2. Update the menu.lst after install.
  3. Update the menu.lst again after updating the kernel.

From time to time Ubuntu will update various software, (or you can do it your self,  System > Administration > Update Manager. Any one of those update might be a brand new kernel update, in that case you will need to edit the menu all over again.

  1. Open the terminal , (‘Applications>Accessories>Terminal’)
  2. At the cursor type ‘gksudo gedit /boot/grub/menu.lst‘, (without the quotes), press enter.
  3. Enter your password if you have to.
  4. Look for the first boot option
  5. look for the entry that mentions Kernel’.
  6. Add ‘noreplace-paravirt‘ at the end of it.
  7. Save the file
  8. Close the editor.
  9. Tell Ubuntu that you changed the file:
  10. Reboot and everything should be back to normal … until you update again.

NB: If you cannot boot at all, (because your screen is black or throwing some errors), simply follow the same instructions in the first article on booting up Ubuntu.

NB2: If you still have a question, feel free to go to the forum and I’ll try to help as much as I can.

Back in the flying seat

August 23rd, 2009 3 comments
Courseplanner tracking a waypoint

Courseplanner tracking a waypoint

I finally managed to get back to flying a little over the week-end, I am working on some new features for Courseplanner, namely the ability to turn into a waypoint, (or past a waypoint depending on the one you want to visit).

All the coding is done, I am just testing with various aircraft if everything works as expected. With all the small aircraft, (Cessna, Mooney and so on), it works well, but it is another story for the heavies. It is just very hard to remain on course without having some wild turns in order to remain on course.

I also added some small features to see where the automatic flight management of Courseplanner is aiming.

But all in all it is fun to get back to flying again.

Install Ubuntu 9 on Virtual PC 2007 – part deux

July 4th, 2009 10 comments

Ok, so you installed Ubuntu 9.04 on Virtual PC 2007, and it now asks you to reboot, (or you already tried to reboot, cursed me, and came back here to see if you missed something).
If you are lucky, everything works fine, if not you cannot see anything or you get a bunch of errors. This is because, once again, Ubuntu is trying to guess your virtual screen resolution and it is guessing it wrong.

So you need to edit the ‘boot’ file once and for all so that from now on it boots into the right screen.

You need to do 2 things, first you need to edit the boot, one more time to get into Ubuntu and then you will need to update the boot file so that you no longer have to do this again.

So, reboot Ubuntu, when you see something like ‘grub loading…‘, press esc and you will see a menu.

Select the first line, it will say something along the lines of ‘Ubuntu 9.0.4, Kernel …’. The other lines should say almost the same with extra words like, ‘Recovery mode‘ and ‘memtest86+‘ don’t choose those.
Press ‘e’ to edit the boot commands.

Select the line that says something like “Kernel …“, (normally the first one, but sometimes the second line).
Press ‘e’ again, (to edit that line).
At the end of that line simply add

or

Press ‘enter‘.
Press ‘b’ to start the boot sequence.

Now you are back in business, Ununtu is up and running again.
The last thing you need to do is make sure the changes you just did are saved so you don’t have to do the same thing over and over.

So, once Ubuntu is up and running select the menu option, ‘Applications>Accessories>Terminal’ and you should get a white window with a blinking cursor.
Next to that cursor type the following, ‘gksudo gedit /boot/grub/menu.lst‘, press enter, give your password.

At the end of the line that says ‘Kernel‘ add ‘noreplace-paravirt‘, (without the quotes of course).
Save the file.
Close the editor

Back at the command prompt simply update the grub, (in other words tell Ubuntu that you changed the file).

And that’s all, you can now reboot into your Virtual PC Ubuntu and all should be fine.

Note: If like me you are lazy and you don’t want to type everything, simply copy the text, place your cursor where you want the text to go and in Virtual PC select ‘Edit>Paste‘ and it will ‘type’ everything for you.

<Edit>Have a look at the third post to help you handle updates.

modprobe s

Install Ubuntu 9 on Virtual PC 2007

July 3rd, 2009 26 comments


I have been using Virtual PC to test reported problems, as a windows developer we only ever had to use Virtual PC for Windows OS, (Vista, XP and so on), but now I wanted to use it to install Ubuntu. If you don’t know what Ubuntu is, Wikipedia has a nice little article about it, basically it is a Linux operating system that has all the pretty desktop feature that most of us Windows users have grown to love.

This is what I used to install Ubuntu on my virtual server.

  • Virtual PC2007 sp1, (get it here).
  • Ubuntu Alternate CD, (get it here).

Create a virtual machine with enough resource, I chose 1024Mb of memory and 30Gb disk space. I think the minimum requirement is 256Mb of memory or something like that but if you can spare 1Gb of memory, use it .

Start the virtual machine and go to CD->Capture ISO image…, (you might need to reset the virtual machine afterwards if, like me, you are not quick enough).

When Ubuntu start it should pickup your ‘CD/ISO image’, you then choose your language
At this point if you try to do the install it will not work, this is because the install program does not ‘guess’ what your video mode is, (after all it is a virtual machine, so you cannot blame Ubuntu for guessing wrong).
So you need to tell it what to use.

To do that when you see the Install Ubuntu menu, (make sure that it is highlighted) . Press F6 and then press esc again to close the menu, (I know, I know there are other ways of doing it, but this way is good enough).

You will see a new line at the bottom that will say ‘Boot Options‘ at move your cursor, (with the arrows), to the end of the line. It should say something like “… quiet —“, delete that and replace it with “ noreplace-paravirt vga=791” and press enter to start the install.
The rest of the install should be fairly straight forward.

A couple of notes:

Select ‘No’ when asked to setup the keyboad, it will then ask you what country you are in and what country your keyboard comes from, otherwise Ubuntu will ask you to test your keyboad.

Be careful when choosing a username and password, remember that this is all case sensitive and the username must start lower case.

I chose not to encrypt the directory.

That’s it, enjoy Ubuntu 9.0.4.

<edit>Please have a look at the 2nd part, there are still some more tweaks needed to get your Ubuntu to work as expected.

www.microsoft.com/windows/virtualpc/
Categories: development Tags: ,