To open an interactive php shell, just type in a terminal:

php -a

As for opening a file, just:

php filename.php
Answer from animaletdesequia on askubuntu.com
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ how-to-run-a-php-application-on-ubuntu-localhost
How to Run a PHP Application on Ubuntu Localhost? - GeeksforGeeks
July 23, 2025 - Step 3: Now, we can execute the PHP program on ubuntu, We need to replace the default apache page with our PHP page. To do that run the below command. sudo mv /var/www/html/index.html /var/www/html/index.back ยท Step 4: Now write your PHP Script to execute using the below command. ... After entering the above command the notepad will be opened with the file name index.php, Write your script in that file.
๐ŸŒ
Allaboutlinux
allaboutlinux.eu โ€บ how-to-run-php-on-ubuntu
How to run PHP on Ubuntu | allaboutlinux.eu
How to run PHP on Ubuntu. First of all you will need a web-server to host our PHP pages. In this tutorial I ll use Apache2. You can install Apache2 from the Terminal by using: ... when the installation is finished, Apache is up and running and you can test that by pointing your web browser at http://localhost/ The default page will come up with a message โ€œit worksโ€ and some more info.This html file is located under your local file system in folder /var/www/html/
๐ŸŒ
Ubuntu
manpages.ubuntu.com โ€บ manpages โ€บ trusty โ€บ man1 โ€บ php5.1.html
Ubuntu Manpage: php - PHP Command Line Interface 'CLI'
By using the -S option where addr:port point to a local address and port PHP will listen to HTTP requests on that address and port and serve files from the current working directory or the docroot passed by the -t option. If none of -r -f -B -R -F -E or -S is present but a single parameter ...
๐ŸŒ
Ubuntu
ubuntu.com โ€บ server โ€บ docs โ€บ how-to โ€บ web-services โ€บ install-php
How to install and configure PHP - Ubuntu Server documentation
December 11, 2025 - If you have installed the php-cli package, you can run PHP scripts at a terminal prompt. By default, when libapache2-mod-php is installed, the Apache2 web server is configured to run PHP scripts using this module.
๐ŸŒ
TecMint
tecmint.com โ€บ home โ€บ php โ€บ how to use and execute php codes in linux command line โ€“ part 1
How to Use and Execute PHP Codes in Linux Command Line - Part 1
July 13, 2015 - 4. You can run a PHP script simply as, if it is a shell script. First Create a PHP sample script in your current working directory. # echo -e '#!/usr/bin/php\n<?php phpinfo(); ?>' > phpscript.php ยท Notice we used #!/usr/bin/php in the first line of this PHP script as we use to do in shell script (/bin/bash). The first line #!/usr/bin/php tells the Linux Command-Line to parse this script file to PHP Interpreter.
Find elsewhere
๐ŸŒ
YouTube
youtube.com โ€บ rocking support
How to run php program in ubuntu part 1 - YouTube
How to run php program in ubuntu16.04, How to run php web application in lamp server and how to connect database and create database in phpmyadmin.
Published ย  July 18, 2017
Views ย  28K
๐ŸŒ
Sololearn
sololearn.com โ€บ en โ€บ Discuss โ€บ 120711 โ€บ how-to-run-php-in-linux-ubuntu
How to run php in linux ubuntu? | Sololearn: Learn to code for FREE!
March 14, 2017 - Use xampp. it's free, and easy to install in Ubuntu. after installation, type this command in terminal: sudo /opt/lampp/lampp start now you can start appache and MySQL using GUI. you have to save your PHP files inside: /opt/lampp/htdocs then ...
๐ŸŒ
YouTube
youtube.com โ€บ watch
how to run php code on ubuntu, how to run php on linux, setup web development environment ubuntu - YouTube
how to run php code on ubuntu, how to run php on linux, setup web development environment ubuntuCommand: Sudo touch filenameIn this php linux tutorial i will...
Published ย  May 9, 2021
๐ŸŒ
Mycomputertips
mycomputertips.co.uk โ€บ 201
Running .php scripts from the terminal using Ubuntu, PHP7
May 9, 2021 - #!/usr/bin/php -q <?php echo "Welcome ... to My Computer Tips So that you can run .php scrips from the terminal, we need to make the file executable....
๐ŸŒ
ServerHub
serverhub.com โ€บ home โ€บ learn how to install, configure, & run php on ubuntu server
Learn How to Install, Configure, & Run PHP on Ubuntu Server
November 1, 2023 - Before doing the PHP install on Ubuntu task, you need to update package lists on your server. Open a terminal and enter the following command: ... To modify the PHP settings, you can edit the php.ini file located in the /etc/php/[PHP_VERSION}apache2/directory.
๐ŸŒ
PHP
php.net โ€บ manual โ€บ en โ€บ features.commandline.usage.php
PHP: Usage - Manual
To run the above script on Unix, it must be made executable, and called simply as script.php echothis or script.php -h. On Windows, a batch file similar to the following can be created for this task:
๐ŸŒ
Medium
medium.com โ€บ @arunpragashap โ€บ install-apache-server-in-ubuntu-and-run-a-php-file-7e5630376e96
Install Apache Server in Ubuntu and Run a PHP file. | by Arunpragash | Medium
July 29, 2023 - After changing the content save the file ctrl + s and exit from the file using ctrl + x. Now visit the browser and refresh the page the content will be changed. For execute a php we need to install a php in our ubuntu so run this command
๐ŸŒ
Ubuntu Forums
ubuntuforums.org โ€บ showthread.php
How do i run a .php file
January 7, 2026 - The meeting point for the Ubuntu community.
๐ŸŒ
GeeksforGeeks
geeksforgeeks.org โ€บ php โ€บ how-to-execute-php-code-using-command-line
How to Execute PHP Code using Command Line? - GeeksforGeeks
... To run PHP code interactively, use the -a option. ... If you need to run a PHP script in the background (e.g., for long-running processes), append & to the command: ... This will run the script in the background and free up the terminal.
Published ย  July 12, 2025