PHP 7 Beginner Tutorial Tutorial

Install PHP 7 and Apache in Ubuntu

Following are the steps to download Apache and PHP 7 in Ubuntu.

  • Open Terminal using Ctrl+Alt+T
  • First, we are going to download the latest version of repositories Execute “sudo apt-get update” in terminal.
  • Now, Install apache2 using “sudo apt-get install apache2” command. Execute it in the terminal.

Note: We are using sudo to execute the command. It will ask you for your regular user’s password to verify your actions. Also for installing apace2 command will tell you which package it plans to install and how much extra disk space install will take up. Press Y and hit Enter to continue, the installation for apache2.

Note: This article is only for creating a practice environment. Installation steps for production need more configuration.

  • Now we are ready to install PHP. Execute “sudo apt-get install php”. For installing php command will tell you which package it plans to install and how much extra disk space install will take up. Press Y and hit Enter to continue, the installation for PHP.
  • Now we are going to change the default directory for apache2 so we can use it for our testing. Execute “sudo nano /etc/apache2/apache2.conf”. This command is going to open apache2.conf file in nano editor. Replace “/var/www/” with “/home/ubuntuvm1710/Documents/PHP7Tutorial”. Here ubuntuvm1710 is my logged in username. You must need to change it based on your username.
  • Next, we are going to execute “sudo nano /etc/apache2/sites-available/000-default.conf”. This command is going to open 000-default.conf file in nano editor. Change DocumentRoot based on above steps. For us it is “/home/ubuntuvm1710/Documents/PHP7Tutorial”.
  • Finally, restart apache “sudo systemctl restart apache2”
  • Create a folder named “PHP7Tutorial” in your Documents folder.
  • Now open your favorite editor and paste <?php echo “Hello, vLemonn!”;  ?> it in the new document and save it with name index.php in PHP7Tutorial.
  • In browser again visit localhost, If everything is fine we are able to see Hello, vLemonn! in the browser.

Note: Above steps are only for PHP Basics Tutorial Practice environment. For production you need to perform more steps which we skipped in this article to make it more simpeler for beginners.

 

0 Comments
Leave A Comment

Please login to post your valuable comments.

share