KwikSteps

StepsHow to setup PHP on Bash on Ubuntu on windows

by

PHP can be installed and run easily on windows after the Windows 10 Anniversary Update which includes Bash on Ubuntu on Windows feature. In order to install PHP, you will first need to install the Apache server. If you haven’t done so by now, please follow the following tutorial under the requirements below.

Article Image

Requirements

  • Windows 10 64-bit
  • Windows 10 Anniversary Update
  • Bash on Ubuntu on Windows feature
  • Apache server

If you are not running the Windows 10 Anniversary Update or Windows 10 Creator Update, please follow one of the following tutorials:

If you are running Windows 10 Anniversary Update but haven’t installed the Bash on Ubuntu on Windows feature, please follow the following tutorial:

If haven’t installed the Apache Server yet, please the following tutorial:

Tools and commands used

  • Bash on Ubuntu on Windows shell
  • apt-get shell command
  • service shell command
  • nano editor
  • Browser

You can also check the following tutorials:

Step 1: Run the Bash on Ubuntu on Windows shell

To do this, click on start (or press the Windows key) and type “Bash on Ubuntu on Windows” then click on it to start using the shell.
If you are not running bash as root, please type:

su root

If prompted to enter the password, please do so.

Step 2: Download and install php using apt-get

You need to use the Linux command apt-get in order to install php or any other package.

apt-get install php5 libapache2-mod-php5 php5-mcrypt

When asked to continue, type “Y” and hit enter.

Step 3: Create index.php and phpinfo.php files

Go the www folder located at:

/var/www/html

Or the location of your www directory.
Create a php file by typing:

nano index.php

In the editor type the following:

<!DOCTYPE html>
<html>
<head>
<title><?php echo “Hello php Title”; ?></title>
</head>
<body>
<h1>><?php echo “Hello php header”; ?></h1>
</body>
</html>

Press Ctrl+O and hit enter to save the file. Press Ctrl+x to exit the editor.
Create another file to show the php information as follow:

nano phpinfo.php

In your editor type the following:

<?php
phpinfo();
?>

Press Ctrl+O and hit enter to save the file. Press Ctrl+x to exit the editor.

Step 4: Test the php files

Make sure the Apache server is running by typing the following:

service apache2 status

If the apache server is not running, type the following:

service apache2 start

To test and check the php information, start your browser and point to the following address:

http://localhost/phpinfo.php

To run your index.php file, start your browser and point to the following address:

http://localhost/
Comments (0)
Load comments
Post your comment
*Name:
Email:
*Comment:
Post Comment
logo203X28
Copyright © 2017
KwikSteps
- All Rights Reserved.
Thank you!
Namecheap.com