共计 6227 个字符,预计需要花费 16 分钟才能阅读完成。
这篇文章主要介绍“Linux+Apache2+Mysql+Php 的安装配置方法”,在日常操作中,相信很多人在 Linux+Apache2+Mysql+Php 的安装配置方法问题上存在疑惑,丸趣 TV 小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Linux+Apache2+Mysql+Php 的安装配置方法”的疑惑有所帮助!接下来,请跟着丸趣 TV 小编一起来学习吧!
在此 Linux 下全新安装配置 Mysql、Apache2、PHP,解决在安装 Mysql 时出现的报错:Character set gbk is not a compiled character set and is not specified in the /usr/local/mysql/share/mysql/charsets/Index.xml file
在安装 mysql 后可以在下面目录找到 mysql 的相关安装配置信息说明 /usr/local/mysql/info/mysql.info
[@more@]
在此 Linux 下全新安装配置 Mysql、Apache2、PHP,解决在安装 Mysql 时出现的报错:Character set gbk is not a compiled character set and is not specified in the /usr/local/mysql/share/mysql/charsets/Index.xml file
在安装 mysql 后可以在下面目录找到 mysql 的相关安装配置信息说明 /usr/local/mysql/info/mysql.info
############################################
1. 检查系统及内核状态
[root@app /]# cat /etc/issue
Red Hat Enterprise Linux AS release 4 (Nahant)
Kernel r on an m
[root@app /]# cat /proc/version
Linux version 2.6.9-5.ELsmp (bhcompile@decompose.build.redhat.com) (gcc version 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)) #1 SMP Wed Jan 5 19:30:39 EST 2005
[root@app /]# uname -r
2.6.9-5.ELsmp
1.1 查看 CPU 及 MEM
[root@app /]# grep model name /proc/cpuinfo
model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz
model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz
model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz
model name : Intel(R) Xeon(R) CPU 5130 @ 2.00GHz
[root@app /]# grep MemTotal /proc/meminfo
MemTotal: 4147280 kB
1.2 操作系统位数
[root@app /]# getconf LONG_BIT
32
[root@app /]# ldd /sbin/mii-tool
libc.so.6 = /lib/tls/libc.so.6 (0x0097e000)
/lib/ld-linux.so.2 (0x00965000)
2. 准备好安装包
mysql-5.0.45.tar.gz
mysql-5.0.45-linux-i686-glibc23.tar.gz
httpd-2.2.4.tar.gz
php-4.4.7.tar.gz
3. 进行安装配置
3.1 检查系统是否已经安装相应的 Mysql,php,apache 软件包
# rpm -qa | grep mysql 和# rpm -qa | grep MySQL
rpm -q -a|grep -i mysql
rpm -q -a|grep -i httpd
rpm -q -a|grep -i php
如果没有返回以 mysql 或 MySQL 打头的信息, 则说明没有安装. 如果已经安装, 则可以直接使用或更换新版本
卸载方法:
# rpm -e mysql-xxxxxx
# rpm -e httpd-xxxxxx
# rpm -e php-xxxxxx
遇到依赖性问题而无法卸载,可以使用 –nodeps 或—force 强制卸载. 不过最好慎用.
rpm -e –nodeps httpd
rpm -e –nodeps php
3.2 进行安装
cp mysql-5.0.45.tar.gz /tmp
cp mysql-5.0.45-linux-i686-glibc23.tar.gz /tmp
cp httpd-2.2.4.tar.gz /tmp
cp php-4.4.7.tar.gz /tmp
3.3 Mysql-5.0.45 版本的安装
cd /tmp
tar xvfz mysql-5.0.45.tar.gz
cd /mysql-5.0.45
./configure –prefix=/usr/local/mysql –with-extra-charsets=gbk –with-charset=gbk –sysconfdir=/etc –localstatedir=/var/lib/mysql
make
make install
指定字符类型为 gbk 进行编译安装
#prefix=/usr/local/mysql mysql 安装的目标目录
#sysconfdir=/etc my.cnf 配置文件的路径
#localstatedir=/var/lib/mysql 数据库存放的路径
安装完以后要初始化数据库,当然你是升级的话不用做这步;
/usr/local/mysql/bin/mysql_install_db –user=mysql
Installing MySQL system tables…
OK
Filling help tables…
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/local/mysql/bin/mysqladmin -u root password new-password
/usr/local/mysql/bin/mysqladmin -u root -h app.shunde.gov.cn password new-password
See the manual for more instructions.
You can start the MySQL daemon with:
cd /usr/local/mysql ; /usr/local/mysql/bin/mysqld_safe
信息有提示将
cp /usr/local/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysqld
cp /usr/local/mysql/share/mysql/my-huge.cnf /etc/my.cnf
/usr/local/mysql/bin/mysqladmin -u root password ******
启动 Mysql 进行测试
/etc/rc.d/init.d/mysqld status
/etc/rc.d/init.d/mysqld start
如果大家还是不能启动不了的话,那就用我的比较繁琐的权限的设置,反正我每次都是这么做的,一般不会有问题,见下:
chown -R root /usr/local/mysql
chgrp -R mysql /usr/local/mysql
chown -R root /usr/local/mysql/bin
chgrp -R mysql /usr/local/mysql/bin
chgrp -R mysql /var/lib/mysql
chmod 777 /var/lib/mysql
chown -R root /var/lib/mysql/mysql
chgrp -R mysql /var/lib/mysql/mysql
chmod 777 /var/lib/mysql/mysql
chown -R root /var/lib/mysql/mysql/*
chgrp -R mysql /var/lib/mysql/mysql/*
chmod 777 /var/lib/mysql/mysql/*
chmod 777 /usr/local/mysql/lib/mysql/libmysqlclient.a
ln -s /usr/local/mysql/lib/mysql /usr/lib/mysql
ln -s /usr/local/mysql/include/mysql /usr/include/mysql
其下可能还有如下错误出现
/usr/local/mysql/bin/mysqladmin: Character set gbk is not a compiled character set and is not specified in the
/usr/local/mysql/share/mysql/charsets/Index.xml file
/usr/local/mysql/bin/mysqladmin: connect to server at localhost failed
error: Can t initialize character set gbk (path: /usr/local/mysql/share/mysql/charsets/)
现在找到该解决办法是打 mysql-5.0.45-linux-i686-glibc23.tar.gz 补丁包
cd /tmp
tar xvfz mysql-5.0.45-linux-i686-glibc23.tar.gz
cp /usr/local/mysql /usr/local/old_mysql
rm -rf /usr/local/mysql
cp mysql-5.0.45-linux-i686-glibc23 /usr/local/mysql
重新启动 Mysql,没有出现 gbk 的报错
继续修改 /etc/my.cnf 的参数配置,将 default-character-set=gbk 增加在如下位置
[client]
default-character-set=gbk
[mysqld]
default-character-set=gbk
重新启动 Mysql
/etc/rc.d/init.d/mysqld restart
登录 Mysql
/usr/local/mysql/bin/mysql -uroot -p******
mysql SHOW VARIABLES LIKE char%
+————————–+—————————————-+
| Variable_name | Value |
+————————–+—————————————-+
| character_set_client | gbk |
| character_set_connection | gbk |
| character_set_database | gbk |
| character_set_filesystem | binary |
| character_set_results | gbk |
| character_set_server | gbk |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql/share/mysql/charsets/ |
+————————–+—————————————-+
8 rows in set (0.01 sec)
如上图所示改成所需字符类型 gbk
[root@app bin]# /usr/local/mysql/bin/mysqlshow -uroot -p******
[root@app bin]# /usr/local/mysql/bin/mysqlcheck -A -uroot -p******
3.3.1 转移 mysql 数据,先从旧库导出成 *.sql, 然后导入到新库
[root@house ~]# /usr/local/mysql/bin/mysqldump -uroot -p****** db1 /opt/db1_bakup.20080304.sql
[root@house ~]# /usr/local/mysql/bin/mysqldump -uroot -p****** db2 /opt/db2_bakup.20080304.sql
[root@house ~]# /usr/local/mysql/bin/mysql -uroot -p****** db1 /opt/db1_bakup.20080304.sql
[root@house ~]# /usr/local/mysql/bin/mysql -uroot -p****** db2 /opt/db2_bakup.20080304.sql
3.4 安装 Apache-2.2.4
cd /tmp
tar xvfz httpd-2.2.4.tar.gz
cd /httpd-2.2.4
./configure –prefix=/usr/local/apache2 –enable-module=so –enable-module=rewrite –enable-shared=max
– 启动 apache
/usr/local/apache2/bin/apachectl start
– 关闭 apache
/usr/local/apache2/bin/apachectl stop
3.5 安装 php-4.4.7
cd /tmp
tar xvfz php-4.4.7.tar.gz
cd / php-4.4.7
[root@app php-4.4.7]# ./configure –prefix=/usr/local/php –with-mysql=/usr/local/mysql –enable-force-cgi-redirect –with-freetype-dir=/usr –with-png-
dir=/usr –with-gd –enable-gd-native-ttf –with-ttf –with-gdbm –with-gettext –with-iconv –with-jpeg-dir=/usr –with-png –with-zlib –with-xml —
enable-calendar –with-apxs2=/usr/local/apache2/bin/apxs
make
make install
3.5.1 配置 php.ini
/usr/local/php/lib/php.ini
到此,关于“Linux+Apache2+Mysql+Php 的安装配置方法”的学习就结束了,希望能够解决大家的疑惑。理论与实践的搭配能更好的帮助大家学习,快去试试吧!若想继续学习更多相关知识,请继续关注丸趣 TV 网站,丸趣 TV 小编会继续努力为大家带来更多实用的文章!