Archive for the ‘LAMP’ Category

Filed Under (Articles, LAMP) by Srikanta on February-18-2008
How to intall WAMP5 for PHP,Apache,Mysql,Phpmyadmin & SQLitemanager
Step 1 : To install PHP + PECL,Apache,SQLitemanager,MySQL,Phpmyadmin all at once, instead of downlaoding all these individually, you can just download one file from WAMPSERVER.com named, WAMP5(size: 21 MB). The link to download is http://www.wampserver.com/en/download.php
This server works on windows Xp and later versions operating system.
Step2:Now goto the link provided above and download wamp5 from it.
Step3:After downloading it,double click on it(Icon shown below)
0.jpg
You’ll see a window with welcome message and next and cancel buttons
1.jpgClick on next.
Step4:21.jpgRead the agreement and if its right for you then click on the radio button next to "I accept the agreement." Click on next.
step5:31.jpgSelect your destination location.click on next.
Step6:41.jpgSelect the destination for the program’s shotcuts.By default it saves it in start menu folder.click on next.
Step7:51.jpgOn checking this check box your wamp server will start with your PC if not checked then everytime when you start your PC you have to double click on the shortcuts.Click on next.
Step8:61.jpgNow click on install. this will start installing all your files on their specified locations.
Step9:71.jpgIt will ask for the folder where you wish to keep all your PHP files.By default WWW is selected
Step10:81.jpgNow it will ask you to provide the SMTP server to be used by PHP.By default its localhost.click on next.
Step11:91.jpgNow it will ask for your default Email ID.Whenever you’ll send any mail from this server this Email ID will be in ‘From:’ column.
Step12:101.jpgNow it will ask for your prefered browser.Setup will show your systems default browser,if you want to keep it then click on ‘Yes’ else ‘No’ and select the .exe of your prefered browser.
Step13:111.jpgNow the last window will show ‘Finish’ button and a check box next to ‘Launch WAMP5 now’.If you want to run the WAMP5 now then check it else uncheck it.
Step14:After finishing the setup you can see in your system tray(Near Clock) a semicircle with filled center121.jpg.If the colour of the semicircle is white then its working correct.If the color is yellow then either Apache or Mysql is not running on your system.If the color is red then none of them are running on your PC.If any of the services are not working then first close all similar applications and then restart WAMP5.For example,if you are running IIS on your PC then it will not run Apache on your PC,so stop the IIS server and then restart WAMP5.
Step15:On clicking the semicircle you’ll see a pop up menu.In this menu the last option is ‘Put Online’.14.jpgThis will make your server public.And the filled semicircle will now turn into a white filled semicircle.131.jpg Now your WAMP5 is ready to use.
When using WAMP5, store all your PHP files in a folder in ‘:\wamp\WWW’ and when you want to browse your files as webpages then open your browser and type in address bar ‘localhost‘.This will open an index page.index.jpg In that, under ‘Your Projects‘, you’ll see your folder,on clicking it will shaw the list of your PHP files. Now click on your file. It will be shown as a webpage.


Filed Under (LAMP, PHP Code Samples, Technology Junk) by Anoop on July-6-2007
Code (php)

<?
function getLocaltime($GMT,$dst){
        if(preg_match('/-/i',$GMT))
        {
                $sign = "-";
        }
        else
        {
                $sign = "+";
        }

        $h = round((float)$GMT,2);

        $dst = "true";

        if ($dst)
                {
                $daylight_saving = date('I');
                if ($daylight_saving)
                                {
                   if ($sign == "-"){ $h=$h-1}
                   else { $h=$h+1; }
                }
        }

        // FIND DIFFERENCE FROM GMT
        $hm = $h * 60;
        $ms = $hm * 60;

        // SET CURRENT TIME
        if ($sign == "-"){ $timestamp = time()-($ms); }
        else { $timestamp = time()+($ms); }

        // SAMPLE OUTPUT
        $gmdate = gmdate("F d, Y - g:i A", $timestamp);
        return $gmdate;
}

echo ' Server Time: '.date("F d, Y - g:i A",time());;

echo " || GMT Time: " . gmdate("F d Y - g:i A", time());

echo ' ||  Localtime: '.getLocaltime('+5.5',0);

?>
 


Filed Under (Articles, LAMP) by Anoop on May-17-2007

We have already discussed, how to install apache and php on windows. Now in this post we are going to tell you that how can you install and configure mysql and server to make it work.

Download
Package(win32 binary, non-installer version) : Select mysql-noinstall-4.1.21-win32.zip

Our Configuration

  • %SYSTEMROOT% : Win2000 -> C:\WINNT, WinXP -> C:\Windows
  • Install to : C:\www\mysql (or wherever you want to install, only for advance users)

Setup

  • Unpack as C:\www\mysql-4.1.21
  • Rename directory C:\www\mysql-4.1.21 to C:\www\mysql
  • Copy MySQL configuration file C:\www\mysql\my-medium.ini (or your choice of one of the other included my-*.ini files) to your %SYSTEMROOT% directory
  • Rename file %SYSTEMROOT%\my-medium.ini (or the copied over my-*.ini file) to my.ini
  • Edit %SYSTEMROOT%\my.ini
  1. Under Sections "[client]" and "[mysqld]", edit…
    socket = C:/www/tmp/mysql.sock
  2. Under Section "[mysqld]", insert…
    basedir = C:/www/mysql/
    datadir = C:/www/mysql/data/

MySQL Server Binaries

MySQL ships with a number of server binaries to choose from. For standard/typical use and functionality, the preference is for server binary ‘mysqld-nt’. Server binaries with the ‘-nt’ suffix should only be used under Windows NT/2000/XP/2003.

  • mysql-debug.exe : Compiled with full debugging and automatic memory allocation checking, symbolic links, and InnoDB and BDB transactional tables.
  • mysqld.exe : Support for InnoDB transactional tables.
  • mysqld-nt.exe : Support for named pipes.
  • mysqld-max.exe : Support for symbolic links, and InnoDB and BDB transactional tables.
  • mysqld-max-nt.exe : Support for symbolic links, InnoDB and BDB transactional tables, and named pipes.

Startup

MySQL can be installed as a Service (automatic or manual start-up) or started as a standalone console application. The MySQL server can be configured to listen (and communicate) on all interfaces (0.0.0.0), the loopback (127.0.0.1), or any other address. The MySQL server can also be configured to skip networking (TCP/IP) and/or connect via named-pipes (sockets).

Install the MySQL process as a Service.

[Default] Listen on all interfaces (0.0.0.0)…
C:\www\mysql\bin> mysqld-max-nt

–install
[automatic start (but not this first time)]
Or
–install-manual
[manual start only]

Other options (edit my.ini), section ‘[mysqld]‘, insert…
Listen on loopback only (127.0.0.1)…
bind-address=127.0.0.1
Do not use TCP/IP (IP addresses and ports) for connections, use named-pipes…
bind-address=localhost
skip-networking
enable-named-pipe
[Note option socket=C:/www/tmp/mysql.sock (default is 'socket=MySQL' for mysql and php) under sections '[client]‘ and ‘[mysqld]‘; Make sure the specifed dir exists; Make sure to fill php.ini options mysql[i].default_socket = C:/www/tmp/mysql.sock and mysql[i].default_host = localhost; Use mysql[i]_connect(’localhost:/www/tmp/mysql.sock’, ‘user’, ‘password’)]

Start the MySQL Service…
…> NET START MySQL

Start MySQL as a standalone console application. C:\www\mysql\bin> mysqld-max-nt –standalone –console
[option '--standalone': Dummy option to start as a standalone server; can be omitted and have the same effect]
[option '--console': Write error output on screen (as opposed to error log)]
Other command line arguments… –bind-address=127.0.0.1
[Note that any IP address can be specified]
–skip-networking –enable-named-pipe –socket=mysql.sock
[option '--skip-networking': do not use TCP/IP -- only valid for localhost]
[option '--enable-named-pipe': allows connections to other NT machines without being dependant on a specific network layer (TCP/IP or IPX)]
[option '--socket=...': name of nt-pipe/socket to use for option '--enable-named-pipe']

Cleanup

Create a password for the ‘root’ mysql account…

C:\www\mysql\bin> mysqladmin -u root password set-root-password-here
Delete all insecure users… Access the MySQL prompt… C:\www\mysql\bin> mysql -u root -p

Display all databases, accounts, and access controls to individual databases…

mysql> SHOW DATABASES;
mysql> SELECT User, Host, Password FROM mysql.user;
mysql> SELECT Host, Db, User, Select_priv FROM mysql.db;

Remove all initial accounts except ‘root@localhost’; remove ‘test’ database and privileges set…

mysql> DELETE FROM mysql.user WHERE User=”;
[Remove anonymous users]

mysql> DELETE FROM mysql.user WHERE User=’root’ AND Host != ‘localhost’;
[Remove remote root]

mysql> DROP DATABASE test;
[Remove test database]

mysql> DELETE FROM mysql.db WHERE Db = ‘test’ OR Db = ‘test\\_%’;
[Remove privileges on test database]

mysql> FLUSH PRIVILEGES;
Exit. mysql> quit;

Note: Cleanup only if you are a advance user. Any extra modification can result in the mysql startup failer. Because mysql also consists of additional information with itself. Cleanup processor is not a neccassory task.

Running MySQL

All commands are run from the command line and directory C:\www\mysql\bin (unless the mentioned dir is under the PATH)

Enter the command-line interface…
> mysql -u root -p

Stop the MySQL Service (one of two ways)…
> NET STOP MySQL
> mysqladmin -u root -p shutdown

Uninstall the MySQL Service…
> mysqld-max-nt –remove

Shutdown the standalone console MySQL application (one of two ways)…
> mysqladmin -u root -p shutdown [Note that this is done from another cmd.exe window]
Ctrl-C under the cmd.exe window it was started from

Help

All commands are run from the command line and directory C:\www\mysql\bin (unless the mentioned dir is under the PATH)
Display the MySQL command-line interface (shell) options…
> mysql –help

Display mysql-max-nt options…
> mysqld-max-nt –help

Display MySQL version information…
> mysqladmin -V

See what values a running MySQL server is using…
> mysqladmin -u <user> -p<password> variables

Display information…
> mysqladmin -u <user> -p<password> version status proc

Update password for MySQL user ‘root’ (from the MySQL shell)…
mysql> UPDATE mysql.user SET Password=PASSWORD(’root-password’) WHERE User=’root’;
mysql> FLUSH PRIVILEGES;

Source : http://www.devside.net



Filed Under (Articles, LAMP) by Anoop on May-12-2007

Step 1 - Download the Latest stable snapshot version.

Although this is a ‘Stable’ snapshot - it is still a snapshot and not a recommended release for production purposes. I am providing this tutorial because all stable production release versions from 5.1.x and below do not work with the latest stable release of Apache 2.2.2.

Go to http://snaps.php.net/ and download the latest stable Win32 Package. This tutorial assumes you will want to install the latest version 5 snapshot build which at the time of writing is 5.2. For this tutorial I used the snapshot built on 29th June 2006. You should use the latest snapshot dated the same day as you download it.

Click on the latest version ‘ php5.2 (zip) ‘ to download  the file named ‘ php5.2-win32-2006xxxxxx.zip ‘ - 8.4MB, save it to your hard drive in a suitable temporary location. (In case of re-installs being necessary I have a permanent location called ‘Master Programs’ where I download to and extract from there). [xxxxxx being the date of the latest version]

Step 2 - Install PHP

Following on from our previous related tutorial on Apache, extract/copy all files and sub-folders to ‘C:\Apache2\php5′ - if you extract elsewhere e.g - ‘D:\PHP5\’ , please remember to substitute this file path in any future references.

Note: PHP5 Installation is slightly different to PHP4 installations. You can find install.txt in PHP4 directory which will help you to install PHP 4 very easilly. The php5 install.txt has this to say :-

Upgrading from a previous PHP version: Previous editions of the manual suggest moving various ini and DLL files into your SYSTEM (i.e. C:\WINDOWS) folder and while this simplifies the installation procedure it makes upgrading difficult. We advise you remove all of these files (like php.ini and PHP related DLLs from the Windows SYSTEM folder) before moving on with a new PHP installation. Be sure to backup these files as you might break the entire system. The old php.ini might be useful in setting up the new PHP as well. And as you’ll soon learn, the preferred method for installing PHP is to keep all PHP related files in one directory and have this directory available to your systems PATH.

Locate C:\Apache2\php5\phi.ini-recommended and make a copy of this file, rename it to php.ini and make sure it is saved in the same folder.

 

Step 3 - Configure PHP 5.2-dev for Apache 2.2.2

Edit your newly copied php.ini in notepad and scroll down to the ‘Paths and Directories’ section.

  • Replace doc_root=
    with doc_root= “c:\apache2\apache2\htdocs” ——–> Change file path accordingly if needed to whatever your Apache Servers document_root is. (In httpd.conf)

Save and Close php.ini.

Step 4 - Configure Apache 2.2.2 for PHP 5.2-dev

————–
Edit your Apache config file ‘httpd.conf’

Locate all the LoadModule entries near the top of the file and just below them add :-

# For PHP 5 do something like this:
LoadModule php5_module “d:/PHP5/php5apache2_2.dll”
# configure the path to php.ini
PHPIniDir “D:/PHP5″
AddType application/x-httpd-php .php

Ensure the path to the php5apache2_2.dll and to the PHP directory reflect your setup, not neccessarily what I have above. Note that the dll we want here is called php5apache2_2.dll and not the php5apache2.dll that earlier versions of PHP came with.

The rest of ‘httpd.conf’ should be ok if the earlier tut was followed, so Save and Close this file then ‘Stop and Start’ or ‘Restart’ the Apache Server service.

Ok, so lets get testing!

Step 5 - Testing your Installation.

Open Notepad (or whatever) and paste the following code into it:-

<?php phpinfo(); ?>

and save the file as phpinfo.php Open your browser and go to ‘ http:\\localhost\phpinfo.php ‘ With a bit of luck you should have a screen full of Server related information and variables.

php_52_1.jpg

If not, something has gone wrong with the installation somewhere, It is usually a simple config error or path related problem and nothing serious. Thanks for listening, the next article in this series of Articles is to install and configure mySQL for use with Apache 2.2.2 and PHP 5.2-dev.

Important Note: This tutorial recommends and uses php.ini-recommended as a starting point when learning PHP. It has a lot of ’safe’ features & settings by default. In particular the ’short_open_tags’ setting is off meaning you can not open a PHP tag with just a <? but you must you the full <?php to start off any PHP code segments.