[Solved] Mysql cannot connect error after compiling php

Discussion in 'Install/Configuration' started by tdunford, Feb 14, 2012.

  1. tdunford

    tdunford New Member

    Hello, I've been trying everything that I've read to do over the last few days and nothing has worked. I was able to install and compile php with litespeed successfully, but I just can't seem to get MySql to connect. I made sure to configure --with-mysql and I made sure that the socket = /var/lib/mysql/mysql.sock is the right location and specified in php.ini and my.conf. Also, when I login to phpmyadmin, I get this error: Cannot load mysql extension. Please check your PHP configuration.

    Also, php info does not show a mysql module, though I see that mysql is working as I am able to "service mysqld restart" and it stops and starts fine. Even verified from "top" command. I do not have Cpanel. The only control panel that I'm using is Webmin and I don't even think there's an extension that makes Litespeed compatible. I am running CentOS and I compiled PHP v3.5.8 with APC and it compiled successfully.

    What I can't figure out is that the very first time that I did a php compile and I opened my website, it loaded fine. Then I went to add the apc.so extension in the php.ini file, and then I started getting the cannot load mysql error. Don't know if that caused it or not, but I did remove the apc.so and mysql error still exists.

    Any help would be very much appreciated because I have tried everything for several days now. Thanks.
  2. webizen

    webizen New Member

    check lsphp to see if mysql extension is included.
  3. tdunford

    tdunford New Member

    Here is the result: /usr/local/lsws/fcgi-bin/lsphp5 -i | grep mysql
    PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/mysql.so' - /usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/pdo.so' - /usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/pdo.so: cannot open shared object file: No such file or directory in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/pdo_sqlite.so' - /usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/pdo_sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/sqlite.so' - /usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/pdo_mysql.so' - /usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0PHP Warning: PHP Startup: Unable to load dynamic library '/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/msql.so' - /usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/msql.so: cannot open shared object file: No such file or directory in Unknown on line 0PHP Warning: Unknown: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'America/Los_Angeles' for 'PST/-8.0/no DST' instead in Unknown on line 0Configure Command => './configure' '--prefix=/usr/local/lsws/lsphp5' '--with-mysqli' '--with-zlib' '--with-gd' '--enable-shmop' '--enable-track-vars' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-magic-quotes' '--enable-mbstring' '--with-iconv' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--enable-simplexml' '--with-libdir=lib64' '--enable-suhosin' '--with-litespeed'
    mysql
    MYSQL_SOCKET => /var/lib/mysql/mysql.sock
    MYSQL_INCLUDE => -I/usr/include/mysql
    MYSQL_LIBS => -L/usr/lib64/mysql -lmysqlclient
    mysql.allow_local_infile => On => On
    mysql.allow_persistent => On => On
    mysql.connect_timeout => 120 => 120
    mysql.default_host => no value => no value
    mysql.default_password => no value => no value
    mysql.default_port => no value => no value
    mysql.default_socket => /var/lib/mysql/mysql.sock => /var/lib/mysql/mysql.sock
    mysql.default_user => no value => no value
    mysql.max_links => Unlimited => Unlimited
    mysql.max_persistent => Unlimited => Unlimited
    mysql.trace_mode => Off => Off
    mysqli
    MYSQLI_SOCKET => /var/lib/mysql/mysql.sock
    mysqli.allow_local_infile => On => On
    mysqli.allow_persistent => On => On
    mysqli.default_host => no value => no value
    mysqli.default_port => no value => no value
    mysqli.default_pw => no value => no value
    mysqli.default_socket => /var/lib/mysql/mysql.sock => /var/lib/mysql/mysql.sock
    mysqli.default_user => no value => no value
    mysqli.max_links => Unlimited => Unlimited
    mysqli.max_persistent => Unlimited => Unlimited
    mysqli.reconnect => Off => Off

    Now what?
  4. tdunford

    tdunford New Member

    And here are the contents of my php.ini file:

    PHP.INI CONTENTS:
    allow_call_time_pass_reference = Off
    allow_url_fopen = On
    allow_url_include = Off
    asp_tags = Off
    auto_append_file =
    auto_globals_jit = On
    auto_prepend_file =
    bcmath.scale = 0
    default_mimetype = "text/html"
    default_socket_timeout = 120
    define_syslog_variables = Off
    disable_classes =
    disable_functions =
    display_errors = Off
    display_startup_errors = Off
    doc_root =
    enable_dl = On
    engine = On
    error_reporting = E_ALL
    expose_php = On
    extension_dir="/usr/local/lsws/lsphp5/lib/php/extensions/no-debug-non-zts-20090626/"
    extension=apc.so
    extension=msql.so
    extension=pdo.so
    extension=pdo_mysql.so
    extension=pdo_sqlite.so
    extension=sqlite.so
    file_uploads = On
    ifx.allow_persistent = On
    ifx.blobinfile = 0
    ifx.byteasvarchar = 0
    ifx.charasvarchar = 0
    ifx.default_host =
    ifx.default_password =
    ifx.default_user =
    ifx.max_links = -1
    ifx.max_persistent = -1
    ifx.nullformat = 0
    ifx.textasvarchar = 0
    ignore_repeated_errors = Off
    ignore_repeated_source = Off
    implicit_flush = Off
    include_path = ""./var/lib/php"
    include_path = ".:/usr/local/lsws/lsphp5/lib/php"
    log_errors = On
    log_errors_max_len = 1024
    magic_quotes_gpc = Off
    magic_quotes_runtime = Off
    magic_quotes_sybase = Off
    max_execution_time = 30000000
    max_input_time = 3000000
    memory_limit = 480M
    msql.allow_persistent = On
    msql.max_links = -1
    msql.max_persistent = -1
    mssql.allow_persistent = On
    mssql.compatability_mode = Off
    mssql.max_links = -1
    mssql.max_persistent = -1
    mssql.min_error_severity = 10
    mssql.min_message_severity = 10
    mssql.secure_connection = Off
    mysql.allow_persistent = On
    mysql.connect_timeout = 120
    mysql.default_host =
    mysql.default_password =
    mysql.default_port =
    mysql.default_socket =
    mysql.default_user =
    mysql.max_links = -1
    mysql.max_persistent = -1
    mysql.trace_mode = Off
    mysqli.default_host =
    mysqli.default_port =
    mysqli.default_pw =
    mysqli.default_socket =
    mysqli.default_user =
    mysqli.max_links = -1
    mysqli.reconnect = Off
    odbc.allow_persistent = On
    odbc.check_persistent = On
    odbc.defaultbinmode = 1
    odbc.defaultlrl = 4096
    odbc.max_links = -1
    odbc.max_persistent = -1
    open_basedir = Off
    output_buffering = 4096
    output_handler = ob_gzhandler
    pgsql.allow_persistent = On
    pgsql.auto_reset_persistent = Off
    pgsql.ignore_notice = 0
    pgsql.log_notice = 0
    pgsql.max_links = -1
    pgsql.max_persistent = -1
    post_max_size = 1000M
    precision = 14
    register_argc_argv = Off
    register_globals = Off
    register_long_arrays = Off
    report_memleaks = On
    safe_mode = Off
    safe_mode_allowed_env_vars = PHP_
    safe_mode_exec_dir =
    safe_mode_gid = Off
    safe_mode_include_dir =
    safe_mode_protected_env_vars = LD_LIBRARY_PATH
    sendmail_path = /usr/sbin/sendmail -t -i
    serialize_precision = 100
    session.auto_start = 0
    session.bug_compat_42 = 0
    session.bug_compat_warn = 1
    session.cache_expire = 180
    session.cache_limiter = nocache
    session.cookie_domain =
    session.cookie_httponly =
    session.cookie_lifetime = 0
    session.cookie_path = /
    session.entropy_file =
    session.entropy_length = 0
    session.gc_divisor = 1000
    session.gc_maxlifetime = 1440
    session.gc_probability = 1
    session.hash_bits_per_character = 5
    session.hash_function = 0
    session.name = PHPSESSID
    session.referer_check =
    session.save_handler = files
    session.save_path = "/var/lib/php/session"
    session.serialize_handler = php
    session.use_cookies = 1
    session.use_trans_sid = 0
    short_open_tag = On
    SMTP = localhost
    smtp_port = 25
    soap.wsdl_cache_dir="/tmp"
    soap.wsdl_cache_enabled=1
    soap.wsdl_cache_ttl=86400
    socket = /var/lib/mysql/mysql.sock
    sql.safe_mode = Off
    sybase.allow_persistent = On
    sybase.compatability_mode = Off
    sybase.max_links = -1
    sybase.max_persistent = -1
    sybase.min_error_severity = 10
    sybase.min_message_severity = 10
    sybct.allow_persistent = On
    sybct.max_links = -1
    sybct.max_persistent = -1
    sybct.min_client_severity = 10
    sybct.min_server_severity = 10
    tidy.clean_output = Off
    track_errors = Off
    unserialize_callback_func=
    upload_max_filesize = 20M
    url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
    user_dir =
    variables_order = "EGPCS"
    y2k_compliance = On
    zend.ze1_compatibility_mode = Off
    zlib.output_compression = Off

    Does anything need to be changed in order to improve functionality and/or performance? Any help or suggestions would be appreciated. Thanks.
  5. webizen

    webizen New Member

    comment out the line below in php.ini
    Last edited: Feb 14, 2012
  6. tdunford

    tdunford New Member

    And here are the contents of my my.conf file:

    MY.CONF CONTENTS:
    big-tables
    connect_timeout = 1200
    datadir = /var/lib/mysql
    default-storage-engine = InnoDB
    interactive_timeout = 1200
    join_buffer_size = 32M
    key_buffer = 4096M
    log=mysql.log
    log-error=/var/log/mysqld.log
    log-slow-queries = /var/log/mysqlslowqueries.log
    long_query_time = 1
    max_allowed_packet = 256M
    max_connections = 2500
    max_heap_table_size = 512M
    myisam_sort_buffer_size = 1024M
    open_files_limit = 16344
    pid-file=/var/run/mysqld/mysqld.pid
    query_cache_limit = 512M
    query_cache_size = 2048M
    query_cache_type = 1
    read_buffer_size = 32M
    read_rnd_buffer_size = 32M
    skip-grant-tables
    socket = /var/lib/mysql/mysql.sock
    sort_buffer_size = 32M
    symbolic-links=0
    table_cache = 36272
    thread_cache = 8192
    thread_cache_size = 1024
    thread_concurrency = 16
    tmp_table_size = 1024M
    user=mysql
    wait_timeout = 3000

    Also, along with the mysql issue I'm currently facing, I have a very large Joomla site and on this same site is a Magento store with 150,000 SKU's, so any performance optimizations to the above php.ini and my.conf file would be appreciated as I need all the help that I can get to increase speed due to the extremely large catalog. Thanks for any help you guys can provide.
  7. tdunford

    tdunford New Member

    Thank you. Will this solve my problem?
  8. tdunford

    tdunford New Member

    I've commented out those lines in my php.ini file and restarted litespeed, apache, and mysql but the problem still remains. What should I do next?
  9. tdunford

    tdunford New Member

    Also, should this line be in the php after compiling with litespeed:

    include_path = ""./var/lib/php"

    because this is also there:
    include_path = ".:/usr/local/lsws/lsphp5/lib/php"

    ?
  10. webizen

    webizen New Member

    you have litespeed and apache running in parallel?
  11. tdunford

    tdunford New Member

    I thought that was how it was supposed to be. I'll turn off apache and see if that solves the problem. Nope, problem remains. So I am not supposed to run apache alongside litespeed? As mentioned above, I have a very large magento store, so my ultimate goal here is to do whatever is necessary to increase speed and performance, so whatever you recommend I'll do as this is all new to me. Thanks.
  12. webizen

    webizen New Member

    it is ok to run apache and litespeed in parallel (on different ports) to make sure litespeed functions well before take over. you should build matching php in lsws first. according to your build command, mysql is built in php as static extension (--with-mysql=/usr), there is no need to put 'extension=mysql.so' in php.ini which triggers warning/error message as you reported earlier.

    since those lines are commented, the error messages you reported should be gone. you should check /usr/local/lsws/logs/error.log and see any further error message regarding mysql connection failure.

    regarding performance tuning/improvement, you should order Hourly Support (https://store.litespeedtech.com/store/cart.php?gid=5).
    Last edited: Feb 14, 2012
  13. tdunford

    tdunford New Member

    Here's some additional information if it helps:
    usr/local/lsws/fcgi-bin/lsphp5 -i
    PHP: syntax error, unexpected '=' in /usr/local/lsws/lsphp5/lib/php.ini on line 156
    phpinfo()
    PHP Version => 5.3.8

    Configure Command => './configure' '--prefix=/usr/local/lsws/lsphp5' '--with-mysqli' '--with-zlib' '--with-gd' '--enable-shmop' '--enable-track-vars' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-magic-quotes' '--enable-mbstring' '--with-iconv' '--with-mysql=/usr' '--with-mysql-sock=/var/lib/mysql/mysql.sock' '--enable-simplexml' '--with-libdir=lib64' '--enable-suhosin' '--with-litespeed'
    Server API => LiteSpeed V5.5
    Virtual Directory Support => disabled
    Configuration File (php.ini) Path => /usr/local/lsws/lsphp5/lib
    Loaded Configuration File => /usr/local/lsws/lsphp5/lib/php.ini
    Scan this dir for additional .ini files => (none)
    Additional .ini files parsed => (none)
    PHP API => 20090626
    PHP Extension => 20090626
    Zend Extension => 220090626
    Zend Extension Build => API220090626,NTS
    PHP Extension Build => API20090626,NTS
    Debug Build => no
    Thread Safety => disabled
    Zend Memory Manager => enabled
    Zend Multibyte Support => disabled
    IPv6 Support => enabled
    Registered PHP Streams => compress.zlib, php, file, glob, data, http, ftp, phar
    Registered Stream Socket Transports => tcp, udp, unix, udg
    Registered Stream Filters => zlib.*, convert.iconv.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk

    mysql

    MySQL Support => enabled
    Active Persistent Links => 0
    Active Links => 0
    Client API version => 5.5.20
    MYSQL_MODULE_TYPE => external
    MYSQL_SOCKET => /var/lib/mysql/mysql.sock
    MYSQL_INCLUDE => -I/usr/include/mysql
    MYSQL_LIBS => -L/usr/lib64/mysql -lmysqlclient

    Directive => Local Value => Master Value
    mysql.allow_local_infile => On => On
    mysql.allow_persistent => On => On
    mysql.connect_timeout => 60 => 60
    mysql.default_host => no value => no value
    mysql.default_password => no value => no value
    mysql.default_port => no value => no value
    mysql.default_socket => /var/lib/mysql/mysql.sock => /var/lib/mysql/mysql.sock
    mysql.default_user => no value => no value
    mysql.max_links => Unlimited => Unlimited
    mysql.max_persistent => Unlimited => Unlimited
    mysql.trace_mode => Off => Off

    mysqli

    MysqlI Support => enabled
    Client API library version => 5.5.20
    Active Persistent Links => 0
    Inactive Persistent Links => 0
    Active Links => 0
    Client API header version => 5.5.20
    MYSQLI_SOCKET => /var/lib/mysql/mysql.sock

    Directive => Local Value => Master Value
    mysqli.allow_local_infile => On => On
    mysqli.allow_persistent => On => On
    mysqli.default_host => no value => no value
    mysqli.default_port => 3306 => 3306
    mysqli.default_pw => no value => no value
    mysqli.default_socket => /var/lib/mysql/mysql.sock => /var/lib/mysql/mysql.sock
    mysqli.default_user => no value => no value
    mysqli.max_links => Unlimited => Unlimited
    mysqli.max_persistent => Unlimited => Unlimited
    mysqli.reconnect => Off => Off
  14. tdunford

    tdunford New Member

    After making the changes, this is the error that I get when I try to access my home page: Database Error: Unable to connect to the database:The MySQL adapter "mysql" is not available.

    And this is the error I get when I try to access phpmyadmin: Cannot load mysql extension. Please check your PHP configuration.

    Suggestions?
  15. webizen

    webizen New Member

    is the error from apache or litespeed (on different port)?
  16. tdunford

    tdunford New Member

    The unable to connect error is when I try to access the development site's home page while running litespeed, with and without apache running. And the second error is on the phpmyadmin login page.

    Info on Port 80: netstat -antlp | grep 80
    tcp 0 0 0.0.0.0:8088 0.0.0.0:* LISTEN 26177/litespeed (ls
    tcp 0 0 0.0.0.0:7080 0.0.0.0:* LISTEN 26177/litespeed (ls
    tcp 0 0 :::80 :::* LIST

    Also, I do have the following on httpd.conf (not sure if it's relevant or not):
    Listen 80
    NameVirtualHost *:80
  17. tdunford

    tdunford New Member

    For anyone who is experiencing a similar problem, I solved it by locating all connections on Port 80 by using

    lsof -i tcp:80

    ...from SSH terminal. Then kill all of those connections using

    kill -9 <pid number>

    Then I stopped apache

    service httpd stop

    Then I did a graceful restart of Litespeed from the Litespeed control panel. Now it works perfectly and I was able to login to phpmyadmin and Litespeed is registering on php info and all looks good.

Share This Page