Since you're getting the error Fatal error: Call to undefined function mysql_connect()
, that means that the MySQL extension is not being loaded by PHP. This is configured in your php.ini file.
To find the location of your php.ini file, create a php file and in it paste the following.
<?php phpinfo(); ?>
On the page (near the top) you will have an entry labelled Loaded Configuration File. Check this file that has been loaded is actually the one that you expect it to load. Personally, mine loads from C:/php/php.ini
, but if I recall correctly when I was initially setting it all up, it was trying to read from C:/Windows/php.ini
(which didn't exist) so was using defaults for everything, which didn't include some of the extra modules I wanted.
Open that file with your favourite text editor and in there should be several lines beginning extension=xxxxx.dll
.
Look through the list of modules and check that extension=php_mysql.dll
is listed and the first character of the line is not a semi-colon (;
). If it's not listed, just add it to the list - if it has the semi-colon at the beginning of the line, remove the semi-colon and save the file.
You should also check the value of extension_dir
, and also verify this path exists on the filesystem. This should be something similar to c:/php/ext
.
Once you've made changes to the php.ini file, you will need to restart Apache so the configuration file is re-read.
Once you've restarted Apache, refresh your phpinfo page and check that it has sections listed for MySQL.
You might also want to check if C:\php
is included in your PATH environment variable.
If you're still having issues, try firing up a command line and cd to C:\php and type php -v
. This will output the PHP version, but will often spit out more error messages than are shown when loading a web page
You have to start apache with that environment variable set. Setting the variable in /etc/profile.d/php.sh
only sets it for the PHP executable itself, which is not used by mod_php5.
I just went through this rigamarole. Setting the variable with SetEnv won't work, either, as it's defined after mod_php5 is loaded.
In CentOS 6.5, I found that editing /etc/sysconfig/httpd
allows you to set and export additional environment variables for the apache process itself. So try adding it there:
export PHP_INI_SCAN_DIR="/usr/local/lib/php/custom"
Best Answer
I found the solution. It's the same problem like mcrypt described here: https://askubuntu.com/questions/362082/php-is-not-working-well-on-ubuntu-13-10-and-mcrypt-is-missing-in-phpmyadmin
to get ssh2 running you have to move the ssh2.ini from /etc/php/conf.d/ssh2.ini to /ect/php/mods-available/ Then run php5enmod ssh2 and restart apache2