How to install PHP on Your own PC?

5/5 - (1 vote)

How to install PHP on Your own PC

To run PHP on Your own PC You have to:
install a web server
install PHP
install a database, such as MySQL


b) install XAMPP on Your PC
XAMPP is a completely free, open source package, used to install easily Apache distribution on Your PC containing MariaDB, PHP, and Perl.

Install XAMPP on Windows

Be careful: Windows 7 and Windows 8 gives the following warning:

“Important! Because an activated User Account Control (UAC) on your system some functions of XAMPP are possibly restricted. With UAC please avoid to intall XAMPP to C:\Program Files (missing write permissions). Or deactivate UAC with msconfig after this setup.”

This is a specific issue for Windows Vista, 7, 8.

I recommend to install XAMPP in a specified folder in Your root directory (not in “Program Files” directory) like C:\XAMPP.
But before you have the option to choose the folder you need to click on this warning message.

After You installed XAMPP, to start the Apache server, go to XAMPP directory and run as administrator “xampp-control.exe” file.
xampp control

then start Apache server and MySql
xampp start apache


Verify the Apache/MySQL/PHP Installation

On your browser, type “http://localhost” and it will directed to the apache server.
If You see the welcome page, it means that everything went well.


Set the password for MySQL users

Your configuration file contains settings (root with no password) that belong to the default MySQL privileged account.
Remember: you really should fix this security hole by setting a password for user ‘root’.

On your browser, type “http://localhost/phpmyadmin” to access the MySQL via PhpMyAdmin.

Select the “User accounts” tab and set password for user “root”, as follows:

1. Go to the privileges tab and click edit privileges for “root”.
phpmyadmin edit privileges

2. Then click on “Change password” button.
phpmyadmin change password
3. Change the password, retype it and then click “Go”.

After completing the above instructions you will notice that phpMyAdmin does not work anymore.
To fix this, you will need to edit the PHPmyAdmin configuration file.

4. Go to “” file located at “c:\XAMPP\phpMyAdmin/”.

Open this file in Your programming editor (such as notepad++ or and find the line:

$cfg[‘Servers’][$i][‘password’] = ”;

Write the password that you chose earlier:

$cfg[‘Servers’][$i][‘password’] = ‘YourPassword’;

and save the file! That’s all!


Write Your first “Hello world” PHP script

By default, the Apache’s document root directory is located at “c:\XAMPP\htdocs”.

Using your programming editor, write this simple PHP script called “hello.php” and save it under the “c:\xampp\htdocs” directory, as follows:

<!DOCTYPE html>
<h1>My first PHP page</h1>

echo "Hello World!";


To run this PHP script, start Your browser and type “http://localhost/hello.php”.
You should see “Hello world” on Your screen.


Change the default root directory for you .php files

By default the “c:\XAMPP\htdocs” directory will serve your .php files.
To change this: open “httpd.conf” file located at “c:\XAMPP\apache\conf” and replace the following lines:

DocumentRoot "C:/xampp/htdocs"
<Directory "C:/xampp/htdocs"> 


DocumentRoot "C:/NewFolder"
<Directory "C:/NewFolder"> 

From now all Your .php files should be placed in “YourNewFolder” directory!


Change Your configuration settings in php.ini

Write another PHP script called “phpinfo.php” to display the PHP settings, as follows:


Run the script by typing the “http://localhost/phpinfo.php” in Your browser.

See some of the most important settings:

Right at the top is the PHP version number.

display_errors directive

Display_errors directive tells you whether error messages are displayed on screen or not.

For development is recommended that Display_errors to be set on, otherwise if you have errors on php scripts you will see only a blank page.

For a live website, displaying errors can reveal information that could expose your website to malicious attacks, therefore it is recommended to set Display_errors to off.

Then the next thing to look at is:


That it’s a numeric value, which is set to 22527.

Changing configuration settings in php.ini

If you want to change the variables listed above, you need to edit the PHP configuration file, php.ini.

Sometimes there are special situations when You dont have the option to edit php.ini file, You can use these methods:
How to change PHP configuration settings without editing php.ini

The location of php.ini file depends on your server and it’s listed at Loaded Configuration File:

Open php.ini file in a text editor(Notepad++) and edit the lines that you want to change.

How to change the value of display_errors

Search in php.ini for “display_errors” and will get:

; display_errors
;   Default Value: On
;   Development Value: On
;   Production Value: Off

Lines that begin with semicolons, are comments, so it don’t matter.
Search again and the next line will be found:


Change value from On to Off and errors will not be displayed.

And don’t forget to restart your web server after making the changes.

Hello there!

I hope you find this post useful!

I'm Mihai, a programmer and online marketing specialist, very passionate about everything that means online marketing, focused on eCommerce.

If you have a collaboration proposal or need helps with your projects feel free to contact me. I will always be glad to help you!

subscribe youtube

Leave a Comment