OSX - can't find my php.ini

2019-07-29 04:01发布

问题:

I recently updated my OSX to mavericks, i kind of got apache and phpmyadmin to work too.

problem is, when i edit the php.ini.default no changes were made when i check in phpinfo(); (restarted Apache of course)

the version in phpinfo() is the same as below

$ php -v
PHP 5.4.17 (cli) (built: Aug 25 2013 02:03:38) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

but when i check for my configuration file, the loaded configuration file doesn't show.

$ php -i | grep 'Configuration File'
Configuration File (php.ini) Path => /etc
Loaded Configuration File => (none)

to open my php.ini.deault i used this command

sudo nano /private/etc/php.ini.default

not sure if this might help, but here is a list of files in the /private/etc/ folder

$ ls
AFP.conf                nanorc
afpovertcp.cfg              networks
aliases                 newsyslog.conf
aliases.db              newsyslog.d
apache2                 nfs.conf
asl                 notify.conf
asl.conf                ntp-restrict.conf
authorization.deprecated        ntp.conf
auto_home               ntp_opendirectory.conf
auto_master             openldap
autofs.conf             pam.d
bashrc                  passwd
com.apple.screensharing.agent.launchd   paths
csh.cshrc               paths.d
csh.login               periodic
csh.logout              pf.anchors
cups                    pf.conf
defaults                pf.os
dnsextd.conf                php-fpm.conf.default
efax.rc                 php.ini-5.2-previous
emond.d                 php.ini.default
find.codes              php.ini.default-5.2-previous
fstab.hd                postfix
ftpd.conf               ppp
ftpd.conf.default           profile
ftpusers                protocols
gettytab                racoon
group                   rc.common
hostconfig              rc.imaging
hostconfig~orig             rc.netboot
hosts                   resolv.conf
hosts.equiv             rmtab
hosts~orig              rpc
ip6addrctl.conf             rtadvd.conf
irbrc                   security
kern_loader.conf            services
krb5.keytab             shells
localtime               snmp
locate.rc               ssh_config
mach_init.d             ssh_config~orig
mach_init_per_login_session.d       sshd_config
mach_init_per_user.d            sshd_config~previous
mail.rc                 sudoers
man.conf                syslog.conf
manpaths                ttys
manpaths.d              xtab
master.passwd               zshenv
moduli

what am i missing? and where is the php.ini that is being used?

UPDATE:

renamed php.ini.default to php.ini and got this errors.

$ php -v
PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20100525/php_pdo_mysql.dll' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20100525/php_pdo_mysql.dll, 9): image not found in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php/extensions/no-debug-non-zts-20100525/php_pdo_mysql.dll' - dlopen(/usr/lib/php/extensions/no-debug-non-zts-20100525/php_pdo_mysql.dll, 9): image not found in Unknown on line 0
PHP 5.4.17 (cli) (built: Aug 25 2013 02:03:38) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

回答1:

copy php.ini.default to php.ini instead of moving it

modify php.ini

restart apache and you should be good



回答2:

Even with sudo, it'll warn you that it's a read-only file. If you're using vi, save the file with

 :w!

FWIW, if you're looking to enable postgresql, there's a great answer here.