分类: LINUX
2008-03-21 21:18:40
来源:赛迪网 作者:sixth |
首先准备必须的软件包:httpd-2.0.55.tar.gz mysql-4.1.22.tar.gz php-5.0.5.tar.gz
先安装Mysql :
tar zxvf mysql-4.1.22.tar.gz -C mysql 解压软件包
cd mysql-4.1.22/
./configure --prefix=/usr/local/mysql --sysconfdir=/etc --localstatedir=/var/lib/mysql 编译安装
make&&make install
cp mysql-4.1.22/support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql/bin
执行以下脚本:
./mysql_install_db 初始化数据库
./mysqld_safe
ls -l /var/lib/mysql
chown -R mysql.mysql /var/lib/mysql 修改所属用户和组
cp mysql-4.1.22/support-files/mysql.server /etc/rc.d/init.d/mysqld制作启动服务脚本
chkconfig --add mysqldd
chmod +x /etc/rc.d/init.d/mysqld 加可执行权限
[root@stu100 init.d]# service mysqld restart
Shutting down MySQL. [ OK ]
Starting MySQL [ OK ]
[root@stu100 init.d]# netstat -antp|grep 3306
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 18939/mysqld
至此 Mysql 顺利安装完成
再装apache
tar zxvf httpd-2.0.55.tar.gz -C httpd 解压软件包
cd httpd-2.0.55/
./configure --prefix=/usr/local/httpd --with-mpm=prefork --with-mods-shared=more --enable-so
make&&make install
vi /usr/local/httpd/bin/apachectl 添加以下注释:
#!/bin/sh
#
# httpd Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server. It is used to serve \
# HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid
cp /usr/local/httpd/bin/apachectl /etc/rc.d/init.d/httpd 制作服务启动脚本
chkconfig --add httpd
chkconfig httpd on
netstat -antp|grep 80 查看端口信息
service httpd restart
至此 apache已经顺利安装完成
最后安装php
tar zxvf php-5.0.5.tar.gz -C php 解压软件包
cd php-5.0.5/
./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql --with-apxs2=/usr/local/httpd/bin/apxs 编译安装
make&&make install
ls /usr/local/httpd/modules 现在再查看apache已经加载的模块
cp php-5.0.5/php.ini-dist /etc/php.ini
vi /usr/local/httpd/conf/httpd.conf 修改apache的配置文件在
LoadModule php5_module modules/libphp5.so 行下加入
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
service httpd restart 重启服务
cat /usr/local/httpd/htdocs/test.php 写一个php页面的测试脚本 改为apache用户所有
phpinfo();
?>
接下来重启apache服务
最后执行测试: httpd://192.168.1.100/test.php 如果能顺利看到PHP页面则顺利安装LAMP成功! |