RedhatAs Linux3下安装Php5.2.0+Mysql5.0.27+Apache2.2.3
1、首先安装Mysql5.0.27步骤如下:
groupadd mysql
useradd -g mysql mysql
CFLAGS="-O3 -mpentiumpro" CXX=gcc \
CXXFLAGS="-O3 -mpentiumpro -felide-constructors -fno-exceptions -fno-rtti" \
./configure \
--prefix=/usr/local/mysql --enable-assembler \
--with-mysqld-ldflags=-all-static \
--with-charset=gb2312 \
--with-extra-charsets=complex
make
make install
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql
cp mysql.server /etc/init.d/mysqld
bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql var
chgrp -R mysql .
修改/etc/my.cnf
[mysqld]
set-variable = max_connections=100
default-character-set = utf8
修改root和匿名账户的密码
/usr/local/mysql/bin/mysql -uroot
UPDATE user SET Password=PASSWORD('new_password') WHERE user='root';
FLUSH PRIVILEGES;
UPDATE user set password=PASSWORD('yournewpassword') where user='';
FLUSH PRIVILEGES;
增加新用户
GRANT ALL ON databasename.* TO username@192.168.128.0/17 IDENTIFIED BY "password"
CFLAGS="-O3 -mpentiumpro" CXX=gcc \
CXXFLAGS="-O3 -mpentiumpro -felide-constructors -fno-exceptions -fno-rtti" \
./configure \
--prefix=/opt/mysql --enable-assembler \
--with-mysqld-ldflags=-all-static \
--with-client-ldflags=-all-static \
--with-charset-utf8 \
--localstatedir=/opt/mysqldata
2、安装apache2.2.3,步骤如下:
如果您在安装操作系统的时候已经安装了Apache,卸载它!利用RPM管理器卸载Apache及其相关套件,只有源码级编译安装的操作系统才是最彻底的系统安装,你才能真正控制它。这是Unix的优点,Unix系统认为它的用户最少也是一个Fan,而NT认为它的用户最少是个懒虫,这就是区别,目标用户的不同,无论您爱听不爱听,这是事实。
cd 到你下载的apache源文件目录
tar xvzf apache*
./configure --prefix=/usr/local/apache --enable-module=so
make;make install
3、安装php5.2.0,步骤如下:
尽管我的电脑里已经安装了php4.3.2,但是仍然使用命令tar -jxvf php-5.2.0.tar.bz2解压php包,然后cd到php-5.2.0目录下面,执行如下命令编译安装:
./configure --with-apxs2=/usr/local/apache/bin/apxs \
--prefix=/usr/local/php \#php的安装目录
--with-mysql -enable-track-vars \#支持管理mysql的项
--with-jpeg-dir --with--ttf --with-png-dir --with-gd
--with-zlib-dir
make
make install
make clean
4、测试一下:
用vi编辑器输入如下内容:
<?php
$dbh = mysql_connect('localhost:3306','root','hua');
mysql_select_db('test');
$query ="insert into hh values (2,'hong')";
$res = mysql_query($query, $dbh);
$err = mysql_error();
if($err){
echo "发生错误,请通知< a href=mailto:likai333@21cn.com >我< /a >";
echo "$err";
}
else
{ echo "成功入库"; }
?>
保存到apache的htdocs目录下test.php,访问一下:
http://localhost/test.php成功!
5、PhpMyAdmin的安装把下载的phpMyAdmin-2.8.2.1.tar.bz2包解压出来,然后配置apache的
httpd.conf文件,增加Alias项:
使用:/usr/local/apache/bin/apachectl start命令启动apache,
在浏览器里输入http://ip地址/phpadmin即可实现对mysql的管理,注意如果mysql已经设置了密码一定要改变phpMyAdmin的顶层目录libraries里的config.default.php文件里的
$cfg['Servers'][$i]['password'] = 'password';
到此完成。