您的位置:首页 > 运维架构 > Apache

RHEL5系统 apache-2.2.11 + php-5.2.8 + mysql-5.1.30

2009-03-11 16:13 330 查看
【数据资料来自互联网,个人收集总结



1。安装apache-2.2.11
./configure
make
make install
然后在 ~/.bash_profile 文件中添加
PATH=$PATHHOME/bin:/usr/local/apache2/bin
这样为了方便启用、关闭apache

2。安装mysql(mysql-5.1.30-linux-i686-icc-glibc23.tar.gz)
这里采用的是mysql的二进制版本(32位),并为Intel构架优化过的
参考:http://dev.mysql.com/doc/refman/5.1/en/installing-binary.html
【备注】
刚开始这个版本在 rhel5 上运行 scripts/mysql_install_db --user=mysql 失败
改用版本 mysql-5.0.67-linux-i686-icc-glibc23.tar.gz 安装正常,后来发现在
/var/lib/mysql 目录下有以前5.0版本的数据,可能由于兼容性导致5.1版本安装不正常,
于是我将原来的数据删除即可正常安装 5.1 版本。

shell> groupadd mysql
shell> useradd -g mysql mysql
shell> cd /usr/local
shell> gunzip < /path/to/mysql-VERSION-OS.tar.gz | tar xvf -
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &
--------------------------------------------------------------------------------

[root@miix mysql]# scripts/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:
./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h miix.hoho.com password 'new-password'
Alternatively you can run:
./bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl
Please report any problems with the ./bin/mysqlbug script!
The latest information about MySQL is available at http://www.mysql.com/
Support MySQL by buying support/licenses from http://shop.mysql.com/
--------------------------------------------------------------------------------

安装完毕后根据以上的提示,别忘了设置mysql root用户密码,我另外新建一个用户 zhaozh
mysql> grant all on *.* to zhaozh@localhost identified by '××××××'

3。安装php-5.2.8
./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli --with-gd --with-jpeg-dir --with-png-dir
make
make install
cp php.ini-dist /usr/local/lib/php.ini
php安装完后,在 /usr/local/apache2/modules 添加了动态连接库 libphp5.so
如果在启动或者重启apache时候,出现以下信息:
[root@miix htdocs]# apachectl -k restart
httpd: Syntax error on line 53 of /usr/local/apache2/conf/httpd.conf: Cannot load /usr/local/apache2/modules/libphp5.so into server: /usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: Permission denied
这是由于selinux引起的,所以需要这样一下:
chcon -t textrel_shlib_t libphp5.so
php安装完后,在 /usr/local/apache2/conf/httpd.conf 添加了一行:
LoadModule php5_module modules/libphp5.so
本人不想采用这种方式,于是将上述一行注释掉,然后在 httpd.conf 文件末尾添加:
Include conf/conf.d/*.conf
接着建立目录 /usr/local/apache2/conf/conf.d
添加 php.conf 文件,内容如下:
--------------------------------------------------------------------------------
#
# PHP is an HTML-embedded scripting language which attempts to make it
# easy for developers to write dynamically generated webpages.
#
LoadModule php5_module modules/libphp5.so
#
# Cause the PHP interpreter to handle files with a .php extension.
#
AddHandler php5-script .php
AddType text/html .php
#
# Add index.php to the list of files that will be served as directory
# indexes.
#
DirectoryIndex index.php
#
# Uncomment the following line to allow PHP to pretty-print .phps
# files as PHP source code:
#
#AddType application/x-httpd-php-source .phps
--------------------------------------------------------------------------------
重启apache,在 /usr/local/apache2/htdocs 目录下建立一个 test.php 文件,如下
<?php phpinfo(); ?>
在浏览器输入 http://ip/test.php ,如果能正常显示出php信息则说明apache+php OK了。

------------------------------------------------------------------------------------------
赵小蜗牛
QQ: 755721501
E-mail: [email]snailwarrior@qq.com[/email]
在不断奉献中谋求生存发展、打造自己的优秀品质,用人性最本质最动人的一面“营销”自己!
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql apache2 RHEL5 php5 mysql5