1.apache已经linux存在,查看apache版本信息及安装目录
# apachectl -v
Server version: Apache/2.2.3
2.安装mysql,由于redhat Enterprise 5 中自带一个mysql的版本,需要先删除
a. 查找已安装的myslq 版本:
#rpm -qa | grep mysql (注意大小写,如果mysql 不行就换MySQL)
在屏幕上将显示已安装的mysql包名如:mysql-5.0.77-3.el5 ;
b. 将搜索出的包名卸载:
#rpm -e --nodeps mysql-5.0.77-3.el5 (nodeps表示强制删除)
再次查找该包名,如果没有结果输出则表明已将该版本的mysql卸载了
c. 下载mysql:http://dev.mysql.com/downloads/mysql/5.0.html
客户端:MySQL-client-community-5.0.92-1.rhel5.x86_64.rpm
服务端:MySQL-server-community-5.0.92-1.rhel5.x86_64.rpm
d.检查perl-DBI-1.52-2.el5.rpm是否安装,
该包为是安装mysql的依赖,没它mysql安装不起,查看是否安装,如果安装了就不需要了,
可以通过 #rpm -qa | grep perl* 查看是否已经安装,该包在linux系统盘上可以找到,以下提供该包下载)
e.安装mysql
[root@localhost /]#rpm -ivh MySQL-server-community-5.0.92-1.rhel5.x86_64.rpm
[root@localhost /]#rpm -ivh MySQL-client-community-5.0.92-1.rhel5.x86_64.rpm
f.查看是否安装成功
[root@localhost /]#netstat -ntpl
显示3306端口开放表示服务安装成功
[root@localhost /]#mysql
能自动登陆,则已成功
g.修改mysql root密码
[root@localhost /]#/usr/bin/mysqladmin -u root password 'xxxxxx';
[root@localhost /]#mysql -u root -p
Enter password:xxxxxx
出现mysql>表示登陆成功!
h.对mysql用户设置远程访问权限
方法1、改表法:登陆mysql后,更改“mysql”数据库里的“user”表里的“host”项,将“localhost”改“%”
mysql>use mysql;
mysql>update user set host ='%' where user ='root';
mysql>select host,user from user;
mysql>FLUSH PRIVILEGES
方法2、授权法:假设允许用户username通过密码password从远程连接到mysql服务器
mysql>GRANT ALL RRIVILEGES ON *.* TO username@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
mysql>FLUSH PRIVILEGES;
i.安装目录结构
数据库目录:/var/lib/mysql/
配置文件:/usr/share/mysql(mysql.server命令及配置文件)
相关命令:/usr/bin(mysqladmin、mysqldump等命令)
(*mysql的一种安全启动方式:/usr/bin/mysqld_safe -- user=root &)
启动脚本:/etc/rc.d/init.d/
2.安装php最新版,从http://www.php.net/downloads.php下载
php-5.3.5.tar.gz
a.解压
[root@localhost /]# tar -zxvf php-5.3.5.tar.gz
b.安装
[root@localhost /]# cd php-5.3.5
[root@localhost /]# ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/lib --enable-track-vars --with-xml --with-mysql
其中--with-apxs2=/usr/local/apache/bin/apxs 是指向apache目录
[root@localhost /]# make
[root@localhost /]# make install
[root@localhost /]# cp php.ini-production /usr/local/lib/php.ini
c.配置
# vi /usr/local/apache/conf/httpd.conf
修改此文件,更改以下指令为:
DirectoryIndex index.html index.shtml index.cgi index.php index.phtml index.php3
ServerName 12.34.56.78:80 //这里的ip和端口号视实际情况而定
Options FollowSymLinks MultiViews //为安全起见,去掉"Indexes"
找到AddType处,并添加以下2行:
AddType application/x-httpd-php .php .php3 .phtml .inc
AddType application/x-httpd-php-source .phps
vi /usr/local/lib/php.ini
更改以下指令为:
register_globals = On
3.安装php碰到的问题
a.configure: error: Cannot find MySQL header files under yes
解决办法:安装MySQL-devel-community-5.0.92-1.rhel5.x86_64.rpm即可
b.configure: error: Cannot find libmysqlclient under /usr.
解决办法:cp /usr/lib64/mysql/* /usr/lib/mysql/
这个问题也应该是安装64位的才会出现。
4.重新安装apache2.3.8
需先安装以下包,用于解决问题:apache2.3.8编译出错 configure: error: APR-util not found. Please read the documentation
a.apr-1.4.2.tar.gz
[root@localhost /]# ./configure –prefix=/usr/local/web/apr
[root@localhost /]# make
[root@localhost /]# make install
b.apr-util-1.3.10.tar.gz
[root@localhost /]#./configure –prefix=/usr/local/web/apr-util –with-apr=/usr/local/web/apr
[root@localhost /]#make
[root@localhost /]#make install
c.pcre-8.10.tar.gz
[root@localhost /]#./configure –prefix=/usr/local/web/pcre
[root@localhost /]#make
[root@localhost /]#make install
最后安装apache
[root@localhost /]#./configure -prefix=/usr/local/apache -enable-rewrite -enable-so -with-apr=/usr/local/web/apr -with-apr-util=/usr/local/web/apr-util -with-pcre=/usr/local/web/pcre
[root@localhost /]#make
[root@localhost /]#make install
apache2.3.8安装成功