Home Download Ubuntu

Make executable php script in terminal

In terminal is a good ideea to make some script files that will ease your job and run some applications by calling their name. These scripts have to be executable.

Usually a bash file will look something like this:

sudo /usr/local/bin/your_program

And after making it executable, we can run it by calling it's name:

sudo chmod +x /etc/init.d/our_script

With php scripts it's the same, but instead of +x option for the chmod command, you will need to use chmod 755:

sudo chmod 755 hello.php

Example of php script that will run in terminal:


echo "Hello world!\n";


Save it as hello.php. Run it by:



Post a Comment