Sharing PHP Code among domains on a shared hosting account with GoDaddy
Contrary to what the GoDaddy Technical Support team tells everyone… you CAN (yes, you can) share code between multiple domains on a shared hosting account with GoDaddy!!!
Basically, I am sharing with you my work around for fact that we’re not allowed to create symlinks in the sub folders (which hold the content of the other domains (secondary, non-primary domains)) of our unlimited shared hosting account.
You can complete this work around in 3 easy steps!
- In the root directory of your unlimited hosting account, create a php5.ini file which is a copy of the already given php.ini file
- Add this line to your php5.ini file:
include_path = ".:/usr/local/php5/lib/php:/home/content/s/a/m/sample/html/shared_code" - Place some code in your shared_code directory and you are done!
You will be able to access the classes and any scripts you have in that directory by including the file with no path. This means your includes will look like this:
include ("SharedClass.php");
(You can also change your fopen status in your php.ini file, but you can use cURL to work around any other fopen issues holding you up)
NOTE: This solution assumes that you are running a Linux server (not Windows) and are using PHP 5 (although this solution may work for PHP 4 on Linux if you make the changes to the php.ini file and not the php5.ini file)