PHP Startup

Starting up PHP you need a Code Editor, a local server environment that supports PHP, and a web browser installed.

Installing PHP requires you to have a web server installed on your system, to better utilize the power of PHP, the web server must have support for at least one database.

So far, the most popular local server environment is XAMPP. Although, there are alternatives like WAMP, EasyPHP, MAMP, and more.

Installing XAMPP on Windows

  • Visit Xampp Download Page to download XAMPP.
  • After downloading XAMPP, run the executable file ending with .exe to start the installation, then click Next.
  • Select components you might want to install.
  • Choose a folder to install XAMPP.
  • Wait for the installation to finish.
  • Once done with the installation, click Finish.
  • Start the XAMPP Panel and start the PHP server.

Installing XAMPP on MacOS

  • Visit Xampp Download Page to download XAMPP for MacOS.
  • Start by installing the .dmg file, then click Next.
  • Select the components you might want to install.
  • Choose a folder to install XAMPP.
  • Wait for the installation to finish.
  • Once done with the installation, click Finish.
  • Start the XAMPP Panel and start the PHP server.

Installing XAMPP on Linux 

  • Open the terminal and run the command chmod +x xampp-linux-x64-7.4.16-0-installer.run to make the file executable.
  • Run the command ls -l xampp-linux-x64-8.0.3-0-installer.run to verify that the file is executable.
  • To run the command with root privileges type sudo ./xampp-linux-x64-7.4.16-0-installer.run
  • Click Next
  • Select components you might want to install.
  • Choose a location for the XAMPP installation.
  • Wait for the installation to finish.
  • After the installation, click Finish.
  • To start the XAMPP Panel run sudo /opt/lampp/lampp start.
You may need to change the file name: xampp-linux-x64-7.4.16-0-installer.run in your commands, depends on the XAMP version you have downloaded

Test The XAMP Installation

Open your web browser and run http://localhost to verify that the installation was successful.

Run a Code

To run a PHP code, first confirm if XAMPP services are running on your computer, you are required to start the Apache service to run PHP. Create a new file with the .php extension inside the htdocs directory inside the XAMPP created directory after the installation. Type in the following code:

<?php
    echo 'It Works!!';
?>

  Do It Yourself