This tutorials is for beginner who want to start learning PHP Web Development . In this tutorial , I will describe from scratch onhow to create a php file, Install local server and execute it on browser . Well, PHP is a server side scripting language ,So it require a server to execute . We can purchase online server but for local development without internet ,we need local server .
There are lots of local server available to download free from internet like XAMPP, WAMPP, LAMP, MAMP . Here
XAMPP and WAMP for window operating system.I have also create a video tutorial watch below . We will be using XAMPP because it is more powerful than WAMPP . Download XAMPP from here https://www.apachefriends.org/download.html .Here recommended PHP version to download is 5.6.x . After downloading just double click to install like any other software . While on installation process ,select installation directory to non window directory .
Means if window installed in C:drive ,better install XAMPP on other drive like D or E if you have . This is because our XAMPP contains our lots of local project that may contains images, audio, video file . These files can heavy .So, to prevent drive space issue ,we recommend to install on non window installed drive .
Complete the XAMPP installation process .After you have to open it's control panel to start Apache and Mysql . Click on start on right side of apache and mysql .
Sometime apache does not start due to port 80 already used by other application on your system or may some other issue . Try below if you facing error to start apache or skip if you did not have any issue on starting apache and mysql .
- Right click on xampp control panel ,choose 'Run as administrator' then try starting apache .
We try this because apache need proper privileges to start it
- If you have already skype installed on your system, It already uses port 80 . To change it's setting follow below
- Open skype 'Tools' menu
- click 'Options'-> Advanced -> Connection
- Uncheck there 'use port 80 and 443 for additional incoming connections'
- If still you can not start apache , download this small software : 'Tcpview' to find port usage application
execute this software and find there on list which other application running 'http' or 'httpd' .
If you find any other software using these 'http' or 'httpd' , uninstall this .
Now ,after successful apache and mysql starts, you have to access local server root directory i.e suppose your xampp installed on D: driver .
Your local server root directory is D:/xampp/htdocs .
Here inside 'htdocs' you have to create your project folder then put/create php files inside this .
Suppose we created a folder 'my_project' inside htdocs .
Now create a PHP file . You can create like creating any text file or can create from PHP editor . We recommend Dreamweaver . Dreamweaver is considered best PHP, HTML editor .
If you want to directly create blank php file without any editor , you must have enabled file extension show .
To enable this on window 7
- Open any drive (C , D or any ). Click on 'Organize' , you can find it on left top side of this window .
- Click 'Folder and Search options'
- Then select 'view' tab
- now uncheck there 'Hide extension for known file type '
Now you can create php file directly like creating text file . To do so just right click ->new->Text document
After rename file and extension ex hello.php
Create a php file inside newly created folder under 'htdocs' folder
ex :
write below inside this file
Now ,Lets execute this file on browser . Open your browser type below
https://localhost/my_project/hello.php
If everything ok and you xampp's apache, mysql running , you should see below text there
Welcome , this is my first php output
Consider here on url https://localhost access htdocs folder , then you just have to type folder name along with file name .
For more PHP tutorial browse our PHP tutorials , We also provide advance level eCommerce project based PHP Training.