How To Set A PHP Path In Linux?

How can we set PHP path in linux?
Ans : When you install PHP and host some .php files on webserver your web server will not detect it. This is because your Apache server does not know how to interprit PHP files? And and where is php located? To eleminate this issue we have to set the php path in main php configuration file php.ini located in your machine. As the linux is open source and the location of this file differs from different flavors, so better option is to search for php.ini file as shown below.

find / -iname php.ini

or some common locations for Redhat and Ubuntu are shown below

For Redhat flavors


For Ubuntu Flavors


To search for include_path and uncomment that before changes.

;include_path = “.:/usr/share/php”

After changes.

include_path = “.:/usr/share/php”

Now save and exit the file. And you have to restart the apache server to detect this settings.

For Redhat

#service httpd restart

For Ubuntu

/etc/init.d/apache2 restart

Now start coding in PHP and enjoy the php scripting.