加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > Linux > 正文

linux – 为现有的MySQL安装配置PHP

发布时间:2020-12-14 02:56:36 所属栏目:Linux 来源:网络整理
导读:我正在为我的客户接管一名前技术员工的基本管理职责.在CentOS服务器上,我有以下内容: Apache,PHP和MySQL.他安装了PHP,但没有配置MySQL扩展(我假设因为服务器只托管一个基于rails的网站). 所以我需要重新配置PHP以使用MySQL扩展.这是当前的PHP配置(来自phphi
我正在为我的客户接管一名前技术员工的基本管理职责.在CentOS服务器上,我有以下内容:

Apache,PHP和MySQL.他安装了PHP,但没有配置MySQL扩展(我假设因为服务器只托管一个基于rails的网站).

所以我需要重新配置PHP以使用MySQL扩展.这是当前的PHP配置(来自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.

当你配置PHP使用–with-mysql时,你必须指定mysql的路径吗?还是mysql源码?或类似的东西?像这样的东西:

--with-mysql=/usr/local/mysql

这个现有设置的问题是MySQL已经安装,除了我不知道它安装在哪里…我知道有/etc/init.d/mysqld.我还找到了以下目录:

/usr/lib中/ MySQL的/
在/ usr /包括/ MySQL的/
的/ usr /共享/ MySQL的/

任何人都能指出我在正确的方向吗?我只是不知道在PHP配置中使用什么目录–with-mysql.

UPDATE

好的,所以我重新配置并重新安装并安装了PHP.现在,当我重新启动Apache时,我得到以下内容:

[warn] module php5_module is already loaded,skipping

这是因为php之前已经在服务器上运行了吗?我查看了httpd.conf,它只有一个php5_module实例加载…

但是,现在查看phpinfo();它显示了我刚刚配置/安装的新更新版本中使用的PHP.

另外,phpinfo();将mysql显示为正在使用,但是当我尝试安装say,Wordpress(使用MySQL)时,Wordpress会出现此错误:

Your PHP installation appears to be missing the MySQL extension which is required by WordPress.

我现在应该在哪里看?

更新#2

目前还没有解决方案.我已经完成了PHP的配置,包括Mysql和phpinfo(); (是的,我正在使用file.php查看此内容)显示–with-mysql = shared,/ usr(根据下面的其他用户建议). PHP仍然没有将MySQL扩展识别为在配置中.

我只是不明白你应该在-with-mysql =的末尾放置什么路径?我找到了以下目录:

/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.

解决了

我刚刚在PHP配置中添加了–with-mysql(没有路径)并重新安装它,PHP显然已经从MySQL自己发现了它所需要的东西.感谢大家的见解.

解决方法

除非mysql安装在非标准位置,否则您应该只能指定没有路径的–with-mysql.您可能还需要–with-mysqli来获得新改进的mysql界面.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读