Archive for the ‘LAMP’ Category
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); ?> 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 Our Configuration
Setup
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.
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. Other options (edit my.ini), section ‘[mysqld]‘, insert… Start the MySQL Service… Start MySQL as a standalone console application. C:\www\mysql\bin> mysqld-max-nt –standalone –console Cleanup Create a password for the ‘root’ mysql account… Display all databases, accounts, and access controls to individual databases… Remove all initial accounts except ‘root@localhost’; remove ‘test’ database and privileges set… mysql> DELETE FROM mysql.user WHERE User=”; mysql> DELETE FROM mysql.user WHERE User=’root’ AND Host != ‘localhost’; mysql> DROP DATABASE test; mysql> DELETE FROM mysql.db WHERE Db = ‘test’ OR Db = ‘test\\_%’; mysql> FLUSH PRIVILEGES; 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… Stop the MySQL Service (one of two ways)… Uninstall the MySQL Service… Shutdown the standalone console MySQL application (one of two ways)… Help All commands are run from the command line and directory C:\www\mysql\bin (unless the mentioned dir is under the PATH) Display mysql-max-nt options… Display MySQL version information… See what values a running MySQL server is using… Display information… Update password for MySQL user ‘root’ (from the MySQL shell)… Source : http://www.devside.net 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.
Save and Close php.ini. Step 4 - Configure Apache 2.2.2 for PHP 5.2-dev ————– Locate all the LoadModule entries near the top of the file and just below them add :- # For PHP 5 do something like this: 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. 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. |
|