How To Set Up A Php Site On Your P.c

Status
Not open for further replies.

Creative-Eye

Broken In
hai guys is there any php expert


please help me
i want to test my php site on my p.c can you tell me How can i create a sql database
please
.....
subinson
 

crashuniverse

In the zone
1. go in cPanel and click MYSQL databases tab.
2. first of all create a user with all privileges.
3. then create a database name.

U see u r done. If u follow the steps, u ll find cPanel self explanatory. An ebook on php will help u further learning of PHP. And i m always there ;-)
 

Retro

Journeyman
Creative-Eye said:
hai guys is there any php expert
please help me
i want to test my php site on my p.c can you tell me How can i create a sql database
please
.....
subinson
I typed this to email my friend but you can use this.

PHP and MySQL are usually associated with Linux. However, most developers use windows for practical purposes and this tutorial will help those people to easily install PHP and MySQL in your Windows operating system without having any trouble and also without using pre-made scripts like XAMPP.

The first step in installation is to download the packages for PHP, Apache and MySQL from the official sites.

* Apache : www.apache.org
* PHP : www.php.net
* MySQL : www.mysql.com

Installing Apache

Installing apache is easy if you download the Microsoft Installer (.msi) package. Just click on the setup file and run the installation wizard. Click on 'next', agree to the basic conditions and click 'next' again. Now, you'll see 'Server Information window'. Enter localhost for both the Network Domain and Server Name. As for the administrator's email address, you can enter anything you want.

Click the Next button and choose Typical installation. Click Next one more time and choose where you want to install Apache ( I installed it in the default location C:\Program Files\Apache Group ). Click the Next button and then the Install button to complete the installation process.

Now restart your computer once. You will see the Apache icon in the taskbar (right side bottom bar). Every time you load Windows, Apache will automatically be loaded. Now, every time you want to try out PHP or Apache or MySQL codes, you must have the Apache console running. So just before you try them out Go to
"Start >> Program Files >> Apache HTTP Server 2.0.52 >> Control Apache Server >> Start Apache in Console". To see if your Apache installation was successful, open up you browser and type *localhost in the address bar. You should see page containing the list of the files in the htdocs folder like "apache_pb.gif, apache_pb.png, index.html.ca" and many other files one below the other. If you see this page, it means that you have successfully installed Apache.

Apache has many settings for the files which are stored in a file called httpd.conf in the conf folder of the Apache directory. Now we will look at some of those settings and also see how to change them. One configuration you may want to change is the directory index option. This is the file that Apache will show by default when we open a directory. For example, if you type *pokedrome.com, by default the index.php file will be opened. You can modify this value by opening the configuration (httpd.conf) file. To open the file, click on the "Start >> Program Files >> Apache HTTP Server 2.0.52 >> Configure Apache Server >> Edit the httpd.conf Configuration file". You can use good 'ol notepad to edit the configuration file.

Now, search the text "DirectoryIndex" using the search feature. You will mostly see this code
"DirectoryIndex index.html index.php". This means that whenever you request a directory like *localhost, Apache will look first for the index.html file in that directory and if it is not found, will open the index.php. If both the files are not found, it will open a error file. Now you can change it to any code like "DirectoryIndex index.php main.html" . You can add as much file names as you want after the index.php to open if the default files are not present. Also, if you want "main.php" to be opened by default, you can give it before "index.html" in the code.

By default Apache's document root is set to the htdocs directory. That is, all the PHP or HTML files which should be processed by Apache and viewed through a browser should be kept in the htdocs folder in the Apache directory. But we can easily change that to any directory we want.

For example, if you want to put all your PHP or HTML files in the D Drive, search for this code in the httpd.conf file: DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs".

Change it to: DocumentRoot "D:/". Similarly you can change it to any location you want.

After every change you make to the configuration file, save it, close it and restart Apache. Close the Apache icon in the taskbar and also the Apache Console DOS File and re-open both of them for the changes to take effect. Now, that's one over and 2 more to go.
Installing PHP

Installing PHP is really easy but a bit tricky! If you miss even one of these instructions, you will find that nothing works. So follow what I say carefully. Firstly, extract the PHP Package you downloaded in a folder called php in the directory where you installed Apache (C:\Program Files\Apache Group\Apache2). You can actually install it anywhere you want but this is mostly for convenience. Now open the PHP Directory, copy the file called "php.ini-dist" and paste it in your C:\Windows directory or in whichever directory you installed Windows. Rename it to "php.ini". This is the main configuration file for PHP and is very important for PHP codes to run properly. Also make sure that 2 important DLL files php5ts.dll and php5apache2.dll are present in your main PHP Directory.
Modifying Apache Configuration

Now that you've installed PHP, you need to tell Apache about PHP's location so that it can run PHP. Open the httpd.conf file again and follow the following instructions accurately without modifying anything in it.

First, search for the code "LoadModule" in the configuration file. You will see many codes starting with "LoadModule". Without modifying any of these, copy these 2 lines from here and paste it at the end of those codes.

LoadFile "C:\Program Files\Apache Group\Apache2\php\php5ts.dll"
LoadModule php5_module "C:\Program Files\Apache Group\Apache2\php\php5apache2.dll"

Next, search for the code: "AddType ". You will probably see a single code starting with AddType. At it's end add this code exactly as give.

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

The first 2 'load' lines tell PHP about the 2 most important DLL files required for PHP to run properly. It tells Apache to load these 2 files everytime Apache starts. The third line tells Apache that every file that ends with .php should be processed as a PHP file.

Now, everything required for running PHP has successfully been completed. To test this, open notepad or any other HTML Editor you use and type this code in it and save it as firsttest.php in the htdocs folder in the Apache directory.:

<?php
phpinfo();
?>

phpinfo() is a basic PHP function which will show lots of information about PHP and your server configuration. Type *localhost/firsttest.php on your browser's address bar and if everything works well you should see a page containing basic information about PHP and your computer too.

If that did not work and you see only a empty browser window, it means that you have wrongly performed one of the steps given above. Please read the steps above carefully again and try repeating the instructions.
Installing MySQL

First extract the package you downloaded anywhere you want, then run setup.exe. Complete the installations as you did for Apache and for convenience purpose install PHP in the default directory C:\mysql.

Open a DOS window and go to C:\mysql\bin and then run mysqld-nt --console , you should see some messages like these :
C:\mysql\bin>mysqld-nt --console
InnoDB: The first specified data file .\ibdata1 did not exist:
InnoDB: a new database to be created!
040807 10:54:09 InnoDB: Setting file .\ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
040807 10:54:11 InnoDB: Log file .\ib_logfile0 did not exist: new to be created

InnoDB: Setting log file .\ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
040807 10:54:12 InnoDB: Log file .\ib_logfile1 did not exist: new to be created

InnoDB: Setting log file .\ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
040807 10:54:31 InnoDB: Started
mysqld-nt: ready for connections.
Version: '4.0.18-nt' socket: '' port: 3306

Now let's install MySQL as a Service. The process is simple just type mysqld-nt --install to install the service and net start mysql to run the service. But make sure to shutdown the server first using mysqladmin -u root shutdown.

C:\mysql\bin>mysqladmin -u root shutdown

C:\mysql\bin>mysqld-nt --install
Service successfully installed.

C:\mysql\bin>net start mysql

The MySQL service was started successfully.

Now open another DOS window and type C:\mysql\bin\mysql. If your installation is successful you will see the MySQL client running with this message:
C:\mysql\bin>mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.0.18-nt.
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

Type mysql>exit to Quit MySQL client.

Well, that's all folks. You have successfully installed Apache, PHP and MySQL. Hope you have fun creating great scripts using these languages.

If you think this is too much, then simply download XAMPP which is 26 MB and automatically installs all 3 for you.

Feel free to ask me if you need anyother help regarding PHP.
 

Retro

Journeyman
Creative-Eye said:
hai guys is there any php expert
please help me
i want to test my php site on my p.c can you tell me How can i create a sql database
please
.....
subinson
I typed this to email my friend but you can use this.

PHP and MySQL are usually associated with Linux. However, most developers use windows for practical purposes and this tutorial will help those people to easily install PHP and MySQL in your Windows operating system without having any trouble and also without using pre-made scripts like XAMPP.

The first step in installation is to download the packages for PHP, Apache and MySQL from the official sites.

* Apache : www.apache.org
* PHP : www.php.net
* MySQL : www.mysql.com

Installing Apache

Installing apache is easy if you download the Microsoft Installer (.msi) package. Just click on the setup file and run the installation wizard. Click on 'next', agree to the basic conditions and click 'next' again. Now, you'll see 'Server Information window'. Enter localhost for both the Network Domain and Server Name. As for the administrator's email address, you can enter anything you want.

Click the Next button and choose Typical installation. Click Next one more time and choose where you want to install Apache ( I installed it in the default location C:\Program Files\Apache Group ). Click the Next button and then the Install button to complete the installation process.

Now restart your computer once. You will see the Apache icon in the taskbar (right side bottom bar). Every time you load Windows, Apache will automatically be loaded. Now, every time you want to try out PHP or Apache or MySQL codes, you must have the Apache console running. So just before you try them out Go to
"Start >> Program Files >> Apache HTTP Server 2.0.52 >> Control Apache Server >> Start Apache in Console". To see if your Apache installation was successful, open up you browser and type *localhost in the address bar. You should see page containing the list of the files in the htdocs folder like "apache_pb.gif, apache_pb.png, index.html.ca" and many other files one below the other. If you see this page, it means that you have successfully installed Apache.

Apache has many settings for the files which are stored in a file called httpd.conf in the conf folder of the Apache directory. Now we will look at some of those settings and also see how to change them. One configuration you may want to change is the directory index option. This is the file that Apache will show by default when we open a directory. For example, if you type *pokedrome.com, by default the index.php file will be opened. You can modify this value by opening the configuration (httpd.conf) file. To open the file, click on the "Start >> Program Files >> Apache HTTP Server 2.0.52 >> Configure Apache Server >> Edit the httpd.conf Configuration file". You can use good 'ol notepad to edit the configuration file.

Now, search the text "DirectoryIndex" using the search feature. You will mostly see this code
"DirectoryIndex index.html index.php". This means that whenever you request a directory like *localhost, Apache will look first for the index.html file in that directory and if it is not found, will open the index.php. If both the files are not found, it will open a error file. Now you can change it to any code like "DirectoryIndex index.php main.html" . You can add as much file names as you want after the index.php to open if the default files are not present. Also, if you want "main.php" to be opened by default, you can give it before "index.html" in the code.

By default Apache's document root is set to the htdocs directory. That is, all the PHP or HTML files which should be processed by Apache and viewed through a browser should be kept in the htdocs folder in the Apache directory. But we can easily change that to any directory we want.

For example, if you want to put all your PHP or HTML files in the D Drive, search for this code in the httpd.conf file: DocumentRoot "C:/Program Files/Apache Group/Apache2/htdocs".

Change it to: DocumentRoot "D:/". Similarly you can change it to any location you want.

After every change you make to the configuration file, save it, close it and restart Apache. Close the Apache icon in the taskbar and also the Apache Console DOS File and re-open both of them for the changes to take effect. Now, that's one over and 2 more to go.
Installing PHP

Installing PHP is really easy but a bit tricky! If you miss even one of these instructions, you will find that nothing works. So follow what I say carefully. Firstly, extract the PHP Package you downloaded in a folder called php in the directory where you installed Apache (C:\Program Files\Apache Group\Apache2). You can actually install it anywhere you want but this is mostly for convenience. Now open the PHP Directory, copy the file called "php.ini-dist" and paste it in your C:\Windows directory or in whichever directory you installed Windows. Rename it to "php.ini". This is the main configuration file for PHP and is very important for PHP codes to run properly. Also make sure that 2 important DLL files php5ts.dll and php5apache2.dll are present in your main PHP Directory.
Modifying Apache Configuration

Now that you've installed PHP, you need to tell Apache about PHP's location so that it can run PHP. Open the httpd.conf file again and follow the following instructions accurately without modifying anything in it.

First, search for the code "LoadModule" in the configuration file. You will see many codes starting with "LoadModule". Without modifying any of these, copy these 2 lines from here and paste it at the end of those codes.

LoadFile "C:\Program Files\Apache Group\Apache2\php\php5ts.dll"
LoadModule php5_module "C:\Program Files\Apache Group\Apache2\php\php5apache2.dll"

Next, search for the code: "AddType ". You will probably see a single code starting with AddType. At it's end add this code exactly as give.

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

The first 2 'load' lines tell PHP about the 2 most important DLL files required for PHP to run properly. It tells Apache to load these 2 files everytime Apache starts. The third line tells Apache that every file that ends with .php should be processed as a PHP file.

Now, everything required for running PHP has successfully been completed. To test this, open notepad or any other HTML Editor you use and type this code in it and save it as firsttest.php in the htdocs folder in the Apache directory.:

<?php
phpinfo();
?>

phpinfo() is a basic PHP function which will show lots of information about PHP and your server configuration. Type *localhost/firsttest.php on your browser's address bar and if everything works well you should see a page containing basic information about PHP and your computer too.

If that did not work and you see only a empty browser window, it means that you have wrongly performed one of the steps given above. Please read the steps above carefully again and try repeating the instructions.
Installing MySQL

First extract the package you downloaded anywhere you want, then run setup.exe. Complete the installations as you did for Apache and for convenience purpose install PHP in the default directory C:\mysql.

Open a DOS window and go to C:\mysql\bin and then run mysqld-nt --console , you should see some messages like these :
C:\mysql\bin>mysqld-nt --console
InnoDB: The first specified data file .\ibdata1 did not exist:
InnoDB: a new database to be created!
040807 10:54:09 InnoDB: Setting file .\ibdata1 size to 10 MB
InnoDB: Database physically writes the file full: wait...
040807 10:54:11 InnoDB: Log file .\ib_logfile0 did not exist: new to be created

InnoDB: Setting log file .\ib_logfile0 size to 5 MB
InnoDB: Database physically writes the file full: wait...
040807 10:54:12 InnoDB: Log file .\ib_logfile1 did not exist: new to be created

InnoDB: Setting log file .\ib_logfile1 size to 5 MB
InnoDB: Database physically writes the file full: wait...
InnoDB: Doublewrite buffer not found: creating new
InnoDB: Doublewrite buffer created
InnoDB: Creating foreign key constraint system tables
InnoDB: Foreign key constraint system tables created
040807 10:54:31 InnoDB: Started
mysqld-nt: ready for connections.
Version: '4.0.18-nt' socket: '' port: 3306

Now let's install MySQL as a Service. The process is simple just type mysqld-nt --install to install the service and net start mysql to run the service. But make sure to shutdown the server first using mysqladmin -u root shutdown.

C:\mysql\bin>mysqladmin -u root shutdown

C:\mysql\bin>mysqld-nt --install
Service successfully installed.

C:\mysql\bin>net start mysql

The MySQL service was started successfully.

Now open another DOS window and type C:\mysql\bin\mysql. If your installation is successful you will see the MySQL client running with this message:
C:\mysql\bin>mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 4.0.18-nt.
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

Type mysql>exit to Quit MySQL client.

Well, that's all folks. You have successfully installed Apache, PHP and MySQL. Hope you have fun creating great scripts using these languages.

If you think this is too much, then simply download XAMPP which is 26 MB and automatically installs all 3 for you.

Feel free to ask me if you need anyother help regarding PHP.
 

Deep

Version 2.0
check this out...

Ihave written tutorial on it:

*www.thinkdigit.com/forum/viewtopic.php?t=15502

Deep
 
Status
Not open for further replies.
Top Bottom