为什么80%的码农都做不了架构师?>>>
前面以为搭建的差不多了,结果后面出现些问题,继续罗列在这里:)
1、如何调试php代码?
修改/etc/php.ini,使 display_errors = On 和 error_reporting = E_ALL,如果不想打印无关信息,可以使 error_reporting = E_ALL & ~E_NOTICE。
重启Apache:service httpd restart
如果找不到php.ini,可以在 从零开始建站-1 中的最后部分的 index.php 中找到 Configuration File (php.ini) Path。
2、php连接mysql出现找不到函数的问题
在前面所用的index.php里的phpinfo()中我没有发现mysql的扩展,经过各种搜之后,发现问题的所在:
我用的是redhat5.5的系统,以rpm的方式安装的mysql,安装的位置不在/usr/local/mysql下;而编译php时选项--with-mysql=path_of_mysql,我试过好几次,如
--with-mysql=/usr/share/mysql //这是实际的mysql安装位置,configure报错
--with-mysql=/usr //安装通过,但在php中连接mysql的时候报找不到mysql_connect()的错误
于是木有办法,只好使用源码重新安装mysql。具体的安装方法自行搜索。这里附上百度文库的一个教程。另:mysql5.5之后使用cmake编译,用了一把,发现真的不错,过几天把我的DFC改用cmake,不用automake了,那个太麻烦了,不好跨平台。最方便的是有一个配置编译和安装的进度百分比提示。
安装mysql的时候可能会出现下面的问题:
问题:MySQL:/usr/sbin/mysqld: unknown option '--skip-locking'
[root@mail ~]# /etc/init.d/mysql-cluster restart
MySQL server PID file could not be found! [FAILED]
Starting MySQL...................................The server quit without updating PID file (/usr/local/mysqlc/data/mail.up05.com.pid). [FAILED]
[root@mail ~]# vim /usr/local/mysqlc/data/mail.up05.com.err
120531 9:20:36 [ERROR] /usr/local/mysqlc/bin/mysqld: unknown option '--skip-locking'
120531 9:20:36 [ERROR] Aborting
解决办法:
取消/etc/my.cnf 配置文件中 --skip-locking 这个参数就可以了。
源码安装完毕后,再重新编译安装一把php,其中的--with-mysql=/usr/local/mysql。
这还不是芥末日,还需要安装php-mysql等等,好在我的虚拟机能联网,yum install php-mysql,下载安装几兆大小的若干文件即可。
现在再打开index.php就可以找到mysql的相关扩展了:
好啦,现在可以正常连接数据库并存取数据了:)
3、在哪里找rpm包?
在这里:http://rpm.pbone.net/index.php3
4、几个常用命令
增加服务的自启动:
[root@localhost firstlog]# cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
[root@localhost firstlog]# chkconfig --add mysqld
[root@localhost firstlog]# chkconfig --level 35 mysqld on
redhat下查看版本:
[root@localhost firstlog]# lsb_release -a
LSB Version: :core-3.1-ia32:core-3.1-noarch:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: RedHatEnterpriseServer
Description: Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Release: 5.5
Codename: Tikanga
[root@localhost firstlog]# uname -a
Linux localhost.localdomain 2.6.18-194.el5 #1 SMP Tue Mar 16 21:52:43 EDT 2010 i686 i686 i386 GNU/Linux
[root@localhost firstlog]# cat /proc/version
Linux version 2.6.18-194.el5 (mockbuild@x86-007.build.bos.redhat.com) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-48)) #1 SMP Tue Mar 16 21:52:43 EDT 2010