PHP Installation for Windows Users: Follow the steps to install PHP on the Windows operating system.
- Step 1: First, we have to download PHP from it’s official website. We have to download the .zip file from the respective section depending upon on our system architecture(x86 or x64).
- Step 2: Extract the .zip file to your preferred location. It is recommended to choose the Boot Drive(C Drive) inside a folder named php (ie. C:\php).
- Step 3: Now we have to add the folder (C:\php) to the Environment Variable Path so that it becomes accessible from the command line. To do so, we have to right click on My Computer or This PC icon, then Choose Properties from the context menu. Then click the Advanced system settings link, and then click Environment Variables. In the section System Variables, we have to find the PATH environment variable and then select and Edit it. If the PATH environment variable does not exist, we have to click New. In the Edit System Variable (or New System Variable) window, we have to specify the value of the PATH environment variable (C:\php or the location of our extracted php files). After that, we have to click OK and close all remaining windows by clicking OK.
PHP Installation for Linux Users:
- Linux users can install php using the following command.
apt-get install php5-common libapache2-mod-php5 php5-cli
It will install php with apache server. For more information click here.
- Mac users can install php using the following command.
curl -s https://php-osx.liip.ch/install.sh | bash -s 7.3
It will install php in your system. For more information click here.
- Open terminal or command line window.
- Goto the specified folder or directory where php files are present.
- Then we can run php code code using the following command:
- We can also start server for testing the php code using the command line by the following command:
php -S localhost:port -t your_folder/
- How to execute TypeScript file using command line?
- Command Line Arguments in Golang
- Command Line Argument in Scala
- XSS Prevention : Without Writing Single Line of Code
- How to read command line arguments in Node.js ?
- How to Download YouTube Videos in Linux Command Line?
- Checking Disk Space in Linux Using Command-Line
- How to read a file line by line using node.js ?
- How to execute AngularJS controller function on page load ?
- Find time taken to execute the tasks in A based on the order of execution in B
- Self Destructing Code in C
- HTML | <code> Tag
- R - Line Graphs
PHP Installation for Mac Users:
After installation of PHP, we are ready to run PHP code through command line. You just follow the steps to run PHP program using command line.
Note: While using the PHP built-in server, the name of the PHP file inside the root folder must be index.php, and all other PHP files can be hyperlinked through the main index page.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.