php cli

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lukemack

    #1

    php cli

    hi,

    can anyone tell me how to configure php cli with mysql support? i;ve
    tried adding defaul username, password and host in /etc/php5/cli/
    php.ini but this didnt work.

    php-m does not list mysql.

    php version is 5.1.6 running on Ubuntu 6.10 with Apache/2.0.55

    many thanks,

    lukemack.

  • Carl Pearson

    #2
    Re: php cli

    lukemack wrote:
    hi,
    >
    can anyone tell me how to configure php cli with mysql support? i;ve
    tried adding defaul username, password and host in /etc/php5/cli/
    php.ini but this didnt work.
    >
    php-m does not list mysql.
    >
    php version is 5.1.6 running on Ubuntu 6.10 with Apache/2.0.55
    >
    many thanks,
    >
    lukemack.
    >
    PHP doesn't know where the ini file is when run from the cli, so your
    MySQL (or any other) extension is never getting loaded.

    Try:
    php -c /path/to/php.ini

    Note this doesn't have to be the same one that Apache uses.

    Comment

    • =?UTF-8?B?SXbDoW4gU8OhbmNoZXogT3J0ZWdh?=

      #3
      Re: php cli

      -----BEGIN PGP SIGNED MESSAGE-----
      Hash: SHA1

      Carl Pearson wrote:
      PHP doesn't know where the ini file is when run from the cli,
      Yes, it does:


      ivan@littlespar k:~$ echo "<?php phpinfo(); ?>" | php5 | grep ini

      Configuration File (php.ini) Path =/etc/php5/cli/php.ini
      Scan this dir for additional .ini files =/etc/php5/cli/conf.d
      additional .ini files parsed =/etc/php5/cli/conf.d/curl.ini,
      /etc/php5/cli/conf.d/gd.ini,
      /etc/php5/cli/conf.d/ldap.ini,
      /etc/php5/cli/conf.d/mysql.ini,
      /etc/php5/cli/conf.d/mysqli.ini,
      /etc/php5/cli/conf.d/odbc.ini,
      /etc/php5/cli/conf.d/pdo.ini,
      /etc/php5/cli/conf.d/pdo_mysql.ini,
      /etc/php5/cli/conf.d/pdo_odbc.ini,
      /etc/php5/cli/conf.d/pdo_sqlite.ini,
      /etc/php5/cli/conf.d/sqlite.ini



      So you have to make sure that /etc/php5/cli/php.ini loads the mysql.so
      extension.


      - --
      - ----------------------------------
      Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-


      Proudly running Debian Linux with 2.6.17-1-686 kernel, KDE3.5.3, and PHP
      5.2.0-8 generating this signature.
      Uptime: 23:41:51 up 1 day, 10 min, 1 user, load average: 0.10, 0.11, 0.09

      -----BEGIN PGP SIGNATURE-----
      Version: GnuPG v1.4.6 (GNU/Linux)

      iD8DBQFFu9VwR56 dWuhgxGgRAs55AK CqL3uefV8RY/cuy9Y0m0iF0CEwD wCfc94z
      OmCucl+TBTyirDe CZpGb9W0=
      =aeQv
      -----END PGP SIGNATURE-----

      Comment

      • lukemack

        #4
        Re: php cli

        thanks - i edited php.ini to load mysql.ini and it works now.

        thanks for your help,

        lukemack.

        On 27 Jan, 22:42, Iván Sánchez Ortega <ivansanche...@ rroba--
        escomposlinux.p unto.netwrote:
        -----BEGIN PGP SIGNED MESSAGE-----
        Hash: SHA1
        >
        Carl Pearson wrote:
        PHP doesn't know where the ini file is when run from the cli,Yes, it does:
        >
        ivan@littlespar k:~$ echo "<?php phpinfo(); ?>" | php5 | grep ini
        >
        Configuration File (php.ini) Path =/etc/php5/cli/php.ini
        Scan this dir for additional .ini files =/etc/php5/cli/conf.d
        additional .ini files parsed =/etc/php5/cli/conf.d/curl.ini,
        /etc/php5/cli/conf.d/gd.ini,
        /etc/php5/cli/conf.d/ldap.ini,
        /etc/php5/cli/conf.d/mysql.ini,
        /etc/php5/cli/conf.d/mysqli.ini,
        /etc/php5/cli/conf.d/odbc.ini,
        /etc/php5/cli/conf.d/pdo.ini,
        /etc/php5/cli/conf.d/pdo_mysql.ini,
        /etc/php5/cli/conf.d/pdo_odbc.ini,
        /etc/php5/cli/conf.d/pdo_sqlite.ini,
        /etc/php5/cli/conf.d/sqlite.ini
        >
        So you have to make sure that /etc/php5/cli/php.ini loads the mysql.so
        extension.
        >
        - --
        - ----------------------------------
        Iván Sánchez Ortega -ivansanchez-algarroba-escomposlinux-punto-org-
        >

        Proudly running Debian Linux with 2.6.17-1-686 kernel, KDE3.5.3, and PHP
        5.2.0-8 generating this signature.
        Uptime: 23:41:51 up 1 day, 10 min, 1 user, load average: 0.10, 0.11, 0.09
        >
        -----BEGIN PGP SIGNATURE-----
        Version: GnuPG v1.4.6 (GNU/Linux)
        >
        iD8DBQFFu9VwR56 dWuhgxGgRAs55AK CqL3uefV8RY/cuy9Y0m0iF0CEwD wCfc94z
        OmCucl+TBTyirDe CZpGb9W0=
        =aeQv
        -----END PGP SIGNATURE-----

        Comment

        • Carl Pearson

          #5
          Re: php cli

          lukemack wrote:
          thanks - i edited php.ini to load mysql.ini and it works now.
          Uhm, MySQL wasn't working in Apache either? You never mentioned that.

          MySQL should have already been loading in php, you were talking about
          CLI usage like it was giving you different behavior, so I was thinking
          it was a path problem (php not finding the ini). Sorry for the
          misunderstandin g.

          Comment

          • lukemack

            #6
            Re: php cli

            i was talking about cli only. slight typo there - should have said
            mysql.so in the php.ini in the cli folder. i did mean cli
            functionality only - mysqsl was working fine in apache.

            On 28 Jan, 15:01, Carl Pearson <jman_spam_trap _....@gmail.com wrote:
            lukemack wrote:
            thanks - i edited php.ini to load mysql.ini and it works now.Uhm, MySQL wasn't working in Apache either? You never mentioned that.
            >
            MySQL should have already been loading in php, you were talking about
            CLI usage like it was giving you different behavior, so I was thinking
            it was a path problem (php not finding the ini). Sorry for the
            misunderstandin g.

            Comment

            Working...