详解 Qt 数据库环境配置

移动开发
本文介绍的是Qt数据库环境配置,以前接触的都是VS2008、VS2005等,多的不说了,先来看内容。

本文介绍的是Qt 数据库环境配置,环境配置:Qt 4.2.3 + ZendOptimizer + mbstring + mcrypt + GD库 。

一、安装RedHat Linux Array.0

安装系统时请务必安装开发工具包和KDE开发工具包,WWW服务器和SQL服务器不要安装,否则可能会出现未知的错误。

二、确定linux系统是否安装gcc编译器

&#6527Array;&#6527Array;首先,服务器GCC要有,不然什么都不能做.可以用gcc -v来查看是否安装了GCC,

#gcc -v  
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2.3/specs  
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
      --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking
       --with-system-zlib --enable-__cxa_atexit --host=i386-redhat-linux  
Thread model: posix  
gcc version 3.2.3 20030502 (Red Hat Linux 3.2.3-34) 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

有以上类似信息说明已有GCC,如果你没有,请先拿安装光盘装好它。

三、请下载以下所有的东西

httpd-2.2.4.tar.gz  
MySQL-client-5.0.37-0.i386.rpm  
MySQL-server-5.0.37-0.i386.rpm  
MySQL-devel-5.0.37-0.i386.rpm  
php-5.2.1.tar.gz  
ZendOptimizer-3.2.4-linux-glibc21-i386.tar.gz  
gd-2.0.28.tar.gz  
libxml2-2.6.11.tar.gz  
zlib-1.2.1.tar.gz  
jpegsrc.v6b.tar.gz  
libpng-1.2.5.tar.gz  
xpm-3.4k-2.i386.rpm  
gd-devel-1.8.4-11.i386.rpm  
libmcrypt-2.5.7.tar.gz  
qt-x11-opensource-src-4.2.3.tar.gz 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.

可能你的电脑不需要这么多.但***都下载吧.不过,可能你看到这贴子的时候会有以上软件新的版本下载了.看着办吧.

开始装吧>>>>>>>>>>>>>>>>>>>>>>>>>

推荐一个下载软件包的网址:http://www.filewatcher.com/

四、安装MYSQL 服务器

#rpm -ivh MySQL-server-5.0.37-0.i386.rpm  
#rpm -ivh MySQL-client-5.0.16-0.i386.rpm  
#rpm -ivh MySQL-devel-5.0.16-0.i386.rpm(没有它不能安装php5.2.1) 
  • 1.
  • 2.
  • 3.

安装好后试试能不能用

#mysql  
Welcome to the MySQL monitor. Commands end with ; or \g.  
Your MySQL connection id is 27651 to server version: 4.0.20-standard  
Type ’help;’ or ’\h’ for help. Type ’\c’ to clear the buffer. 
  • 1.
  • 2.
  • 3.
  • 4.

说明OK,请自己改mysql的密码SET PASSWORD=PASSWORD(’密码’);

五、安装GD库基本包

#rpm -ivh gd-devel-1.8.4-11.i386.rpm 
  • 1.

六、安装XPM支持

#rpm -ivh xpm-3.4k-2.i386.rpm 
  • 1.

#p#

七、安装libxml2 (记得PHP5.2.1只支持libxml2-2.6.11以上版本)

#tar zxvf libxml2-2.6.11.tar.gz  
#cd libxml2-2.6.11  
#./configure  
#make  
#make install 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

八、装GD库支持

(1)安装ZLIB

#tar zxvf zlib-1.2.1.tar.gz  
#cd zlib-1.2.1  
#./configure  
#make  
#make install  
(2)安装JPEGSRC  
#tar zxvf jpegsrc.v6b.tar.gz  
#cd jpegsrc-6b  
#./configure  
#make  
#make install-lib  
#make install 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.

(3)安装LIBPNG

#tar zxvf libpng-1.2.5.tar.gz  
#cd libpng-1.2.5  
#cp scripts/makefile.std Makefile  
#make  
#make install 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

(4)***是安装GD2.*

gd-2.0.28  
#tar zxvf gd-2.0.28.tar.gz  
#cd gd-2.0.28  
#./configure --with-png=/usr/local --with-jpeg=/usr/local --with-freetype=/usr  
#make  
#make install 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

上面一切都很顺利的话,GD就算成功的安装上了. 如果有问题,应该是缺少支持包,总之是少什么就下载什么来安装上.

九、安装mcrypt

#tar xzvf libmcrypt-2.5.7.tar.gz  
#cd libmcrypt-2.5.7  
#./configure  
#make  
#make install 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

十、安装APAHCHE2

#tar zxvf httpd-2.2.4.tar.gz  
#cd httpd-2.2.4  
#./configure --prefix=/usr/local/apache2 --enable-module=so 
#make  
#make install 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

#p#

十一、安装PHP5

#tar zxvf php-5.2.1.tar.gz  
#cd php-5.2.1  
#./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs 
     --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-gd=/usr/local --enable-trace-vars
     --with-zlib-dir=/usr/local --with-mysql=/var/lib/mysql --with-mcrypt=/usr/local --enable-mbstring  
#make  
#make install 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.

我是把他们分别安装在/usr/local/apache2 & PHP目录下的所有的安装工作做好了,接着我们来配置.

#p#

十二、Apache2配置

(1)复制PHP.INI文件到正确位置,在PHP解压的目录下运行

#cp php.ini-dist /usr/local/php/lib/php.ini 
  • 1.

(2)编辑apache配置文件httpd.conf

#vi /usr/local/apache2/conf/httpd.conf 
  • 1.

要改的有如下几处:

一般都在

#AddType application/x-tar .tgz 
  • 1.

下加一行

AddType application/x-httpd-php .php 
  • 1.

还有找到

DirectoryIndex index.html index.html.var 
  • 1.

在后面加 index.php 让它把index.php做为默认页

再找

#ServerName 
  • 1.

把#去掉,后面的IP改成你的IP.

找到

DocumentRoot "/usr/local/apache2/htdocs" 
  • 1.

把/usr/local/apache2/htdocs改为你存放网页文件的路径

比如我是放在/myweb目录下,所以我以后上传PHP文件就放在/myweb目录下,然后用IP访问,就能看到首页了

差不多就这些了,至于apache2其它优化,请看 http://www.phpv.net/ 里的apache配置那一分类.保存httpd.conf文件.

(3)启动Apache2

# /usr/local/apache2/bin/apachectl start 
  • 1.

如果没有出错,写一个测试页放到你网页目录下, 我的就是上面所说的 /myweb

#vi /home/easy/index.php 
  • 1.

保存.试试在测试器里打IP进去就可以看到PHPINFO页了

好了.如无意外.你现在可以放心在你的机器上运行PHP脚本连接mysql了.

#p#

十二、安装ZendOptimizer-3.2.4加速PHP

#tar zxvf ZendOptimizer-3.2.4-linux-glibc21-i386.tar.gz  
#cd ZendOptimizer-3.2.4-linux-glibc21-i386  
#./install.sh 
  • 1.
  • 2.
  • 3.

一路默认下去应该就好了.再看看测试页,看看末尾是不是这样的?

This program makes use of the Zend Scripting Language Engine:  
Zend Engine v1.3.0, Copyright (c) 1ArrayArray8-2004 Zend Technologies with Zend Extension Manager v1.0.3,
 Copyright (c) 2003-2004, by Zend Technologies with Zend Optimizer v3.2.4, Copyright (c) 1ArrayArray8-2004, by Zend Technologies 
  • 1.
  • 2.
  • 3.

十三、安装phpMyAdmin

#unzip -d . phpMyAdmin-2.10.0.2-all-languages-utf-8-only.zip  
#mv phpMyAdmin-2.10.0.2-all-languages-utf-8-only /usr/local/apache2/htdocs/phpMyAdmin  
#cd /usr/local/apache2/htdocs/phpMyAdmin  
#cp library/config.default.php config.inc.php  
#vi config.inc.php 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.

找到cfg[’PmaAbsoluteUri’]等号后面改为’http://localhost/phpMyAdmin’

找到cfg[’blowfish_secrect]等号后面改为’MySQL数据库root用户密码’

找到cfg[’Server’][$i][’auth_type’]等号后面改为’cookie’

找到$cfg[’Servers’][$i][’user’]等号后面改为’root’

找到cfg[’Server’][$i][’password’]等号后面改为’MySQL数据库root用户密码’

找到$cfg[’DefaultLang’]等号后面改为 zh-gb2312

找到$cfg[’DefaultCharset’]等号后面改为 gb2312

测试:

在浏览器中输入 http://localhost/phpMyAdmin 输入密码后看看末尾mcrypt和mbstring扩展有没有加载,如果没有加载会有红色警告提示

十四、安装Qt4.2.3

#tar xzvf qt-x11-opensource-src-4.2.3.tar.gz  
#cd qt-x11-opensource-src  
#./configure --qt-sql-mysql --qt-sql-sqlite --plugin-sql-mysql --plugin-sql-sqlite -I/usr/include/mysql -L/usr/lib/mysql  
#gmake  
#make install  
#echo "export PATH=/usr/local/Trolltech/Qt-4.2.3/bin:$PATH" >> ~/.bashrc 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

小结:Qt数据库环境配置的内容介绍完了,希望本篇对你有帮助,想要更多内容,请参考编辑推荐。

责任编辑:zhaolei 来源: 互联网
相关推荐

2011-08-30 13:59:06

QTMysql数据库

2011-06-21 15:48:41

2011-06-21 15:58:20

Qt 数据库

2011-08-15 23:14:34

Oraclerman环境配置

2010-04-02 13:59:08

Oracle数据库

2011-07-01 14:06:57

Qt sqlite

2011-07-05 09:54:04

2011-08-30 14:25:06

QT数据库

2011-08-30 14:38:50

QT数据库

2011-07-05 10:03:00

Qt MYSQL 数据库

2011-09-01 15:10:22

Qt数据库SQL

2011-07-05 09:35:52

Ubuntu Qt Mysql

2011-07-05 14:46:34

2010-04-02 17:11:45

Oracle数据库

2010-03-16 14:05:19

Cassandra

2011-06-21 15:31:04

Qt 数据库 SQL

2011-06-21 15:11:04

QT 数据库

2011-07-05 10:16:16

Qt 数据库 SQLite

2011-07-20 12:34:49

SQLite数据库约束

2010-04-14 15:14:11

Oracle数据库
点赞
收藏

51CTO技术栈公众号