首先准備必須的軟件包: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成功!