我正在为我的客户接pipe一名前高科技员工的基本pipe理职责。 在CentOS服务器上,我有以下几点:
Apache,PHP和MySQL。 他已经安装了PHP,但没有configurationMySQL扩展(我假设,因为服务器只托pipe一个基于rails的网站)。
所以我需要重新configurationPHP来使用MySQL扩展。 这里是当前的PHPconfiguration(来自phphinfo();):
'./configure' '--build=i686-redhat-linux-gnu' '--host=i686-redhat-linux-gnu' '-- target=i386-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '-- bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '-- includedir=/usr/include' '--libdir=/usr/lib' '--libexecdir=/usr/libexec' '-- localstatedir=/var' '--sharedstatedir=/usr/com' '--mandir=/usr/share/man' '-- infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib' '--with-config- file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '-- disable-rpath' '--without-pear' '--with-bz2' '--with-curl' '--with-exec-dir=/usr/bin' '-- with-freetype-dir=/usr' '--with-png-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '-- with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with- png' '--with-pspell' '--with-expat-dir=/usr' '--with-pcre-regex=/usr' '--with-zlib' '-- with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--enable-track-vars' '--enable- trans-sid' '--enable-yp' '--enable-wddx' '--with-kerberos' '--enable-ucd-snmp-hack' '-- with-unixODBC=shared,/usr' '--enable-memory-limit' '--enable-shmop' '--enable-calendar' '-- enable-dbx' '--enable-dio' '--with-mime-magic=/usr/share/file/magic.mime' '--without- sqlite' '--with-libxml-dir=/usr' '--with-xml' '--with-system-tzdata' '--with- apxs2=/usr/sbin/apxs' '--without-mysql' '--without-gd' '--without-odbc' '--disable-dom' '-- disable-dba' '--without-unixODBC' '--disable-pdo' '--disable-xmlreader' '--disable- xmlwriter'
你可以看到他有–without-mysql在那里。
当你configurationPHP使用–with-mysql时,你必须指定mysql的path吗? 还是mysql的源? 或类似的东西? 像这样的东西:
--with-mysql=/usr/local/mysql
这个现有的设置的问题是,MySQL已经安装,除了我不知道它在哪里安装…我知道有/etc/init.d/mysqld。 我还发现了以下目录:
/ usr / lib / mysql / / usr / include / mysql / / usr / share / mysql /
任何人都可以在这里指出正确的方向吗? 我只是不知道在PHPconfiguration中使用–with-mysql的目录。
UPDATE
好吧,所以我得到了PHP重新configuration,并重新安装。 现在当我重新启动Apache时,我得到以下内容:
[warn] module php5_module is already loaded, skipping
这是因为PHP之前已经在服务器上运行? 我查看了httpd.conf,它只有一个php5_module实例正在被加载…
但是,现在查看phpinfo(); 它显示了我正在configuration/安装的新更新版本中使用的PHP。
另外,phpinfo(); 显示MySQL正在使用,但是当我试图安装说,Wordpress(它使用MySQL),WordPress的是给这个错误:
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
我现在应该在哪里看?
更新#2
至今仍然没有解决办法。 我已经通过PHP的configuration,包括Mysql和phpinfo(); (是的,我用一个file.php来查看这个)显示–with-mysql = shared,/ usr(根据下面的其他用户build议)。 然而,PHP仍然不认为MySQL扩展是在configuration中。
我只是不明白,你应该在–with-mysql =结尾放置什么path? 我有我find的以下目录:
/usr/bin/ contains: mysql (executable?) /usr/lib/mysql/ contains: libdbug.a libmyisammrg.a libmysqlclient_r.so libmysqlclient.so libmystrings.a mysqlbug libheap.a libmysqlclient.a libmysqlclient_r.so.15 libmysqlclient.so.15 libmysys.a mysql_config libmyisam.a libmysqlclient_r.a libmysqlclient_r.so.15.0.0 libmysqlclient.so.15.0.0 libvio.a /usr/include/mysql/ contains: chardefs.h keymaps.h my_config.h my_global.h mysql_com.h mysql_time.h readline.h sql_common.h tilde.h decimal.h m_ctype.h my_config_i386.h my_list.h mysqld_ername.h mysql_version.h rlmbutil.h sql_state.h typelib.h errmsg.h m_string.h my_dbug.h my_net.h mysqld_error.h my_sys.h rlprivate.h sslopt-case.h xmalloc.h history.h my_alloc.h my_dir.h my_no_pthread.h mysql_embed.h my_xml.h rlshell.h sslopt-longopts.h keycache.h my_attribute.h my_getopt.h my_pthread.h mysql.h raid.h rltypedefs.h sslopt-vars.h /usr/share/mysql/ contains: charsets english french italian my-innodb-heavy-4G.cnf mysql_fix_privilege_tables.sql norwegian romanian spanish czech errmsg.txt german japanese my-large.cnf mysql_system_tables_data.sql norwegian-ny russian swedish danish estonian greek korean my-medium.cnf mysql_system_tables.sql polish serbian ukrainian dutch fill_help_tables.sql hungarian my-huge.cnf my-small.cnf mysql_test_data_timezone.sql portuguese slovak
有帮助吗?
更新3
是的,我正在使用虚拟主机。 这是我的conf文件:
Listen 80 NameVirtualHost *:80 <VirtualHost *:80> ServerName thedomain.com ServerAlias www.thedomain.com DocumentRoot /u1/thedomain.com/public RailsEnv production </VirtualHost> <VirtualHost *:80> ServerName subdomain.thedomain.com DocumentRoot /u1/subdomain.thedomain.com/public </VirtualHost>
我正在尝试在子域上设置基本的Wordpress安装。 我仍然收到这个错误:
Your PHP installation appears to be missing the MySQL extension which is required by WordPress.
解决了
我刚刚添加–with-mysql(没有path)到PHPconfiguration并重新安装它,PHP只是从它自己的明显发现它需要从MySQL。 感谢大家的见解。
除非mysql安装在非标准的位置,否则你应该只能指定–with-mysql没有path。 你也可以用–with-mysqli来获得新的改进的mysql接口。
UPDATE
你正在使用虚拟主机? 你可以检查它。 只有一个PHP实例允许一个Apacheconfiguration树(对于一个Apache进程)。 在不同的虚拟主机中声明几个PHP实例不会生效。
关于你的更新:Apache的警告告诉你,php5的apache模块已经被添加到configuration中的某个地方。 如果你通过你的configuration,更重要的是包括其他configuration文件,你会看到如下所示:
#PHP Stuff AddModule mod_php5.c
在不止一个地方。 不要担心,这不是一个重要的错误,你可以忽略它(或grep通过你的configuration文件,grep -ir'mod_php5'/etc/httpd.d/*)。
至于–with-mysql的path,在我的情况下,mysql二进制文件可以在/ usr / local / bin / my *和/ usr / local / sbin / my *中find,所以我的–with-mysql行可以在这里可以看到:
'./configure' '--with-pear' '--disable-cli' '--with-apache=/usr/src/apache_1.3.41' '--with-mysql=/usr/local' '--enable-safe-mode'
(这只是一个例子,它不一定对你的设置是正确的)。 在你的情况下,我会尝试–with-mysql = / usr / share / mysql(你给出的选项似乎最有可能是正确的。 )
如果你已经安装了pecl和php,你可以使用pecl来安装mysql / mysqli而不用重新编译其他东西。 我通常使用他们的类似cpan的shell,但是我被告知只能执行“pecl install mysql”和“pecl install mysqli”如果使用pecl,则可以将mysql.so和mysqli.so添加为extension = lines在你的php.ini中,确保你的extension_dir是正确的。 然而,你这样做的方式,MySQL支持应该被编译成PHP它是自己的,使任何补充到php.ini不必要的。
最后 – 从个人经验来看,如果你继续搞乱重新编译php,并且开始出现奇怪的链接器错误(或者一般的怪异问题),请先备份你的Makefile / config.h,然后先做一个make clean。 这将清除所有的中介对象文件。
呃,还有一个注意事项 – 如果你使用php -i从命令行得到你的phpinfo();做一个phpinfo.phptesting文件,因为cli和apache模块可以有不同的php.ini文件。
现在我已经完成了这个后续工作,但我不确定它是否能够真正解决您的问题,但是它可能会有所帮助。
上面的configurationstring与PHP5 CentOS / RHEL PHP包不太相似,所以我假设PHP已经手动configuration并安装在机器上。
对于最近的CentOS / RHEL机器来说,PHP的configuration脚本的下列标志就足够了:
--with-mysql=shared,/usr
(正如在官方的CentOS / RHEL PHP包中使用的)。
您将需要mysql和mysql-devel包来成功编译,并使用MySQL库。
作为参考:在完全使用软件包pipe理的CentOS / RHEL系统上,以下将安装PHP和MySQL扩展:
yum install php php-mysql
Lockie
前几天我写了关于在Linux上编译PHP的文章: http : //users.livejournal.com/__hedin/182480.html
对不起,但它在俄罗斯(我现在不能翻译它)。 您可以改用Google Translate。
总之,你应该在x64 Fedora上使用这个选项:
-with-mysql = / usr / bin -with-libdir = lib64
在make && make install之后检查libphp5.so是否出现在你的apache模块目录中