下载软件
httpd-2.0.52.tar.gz http://www.apache.org
mysql-4.0.21.tar.gz http://www.mysql.com
php-5.0.2.tar.gz http://www.php.net
下载到
/soft/lamp目录下面
# tar zxvf httpd-2.0.52.tar.gz
# tar zxvf mysql-4.0.21.tar.gz
# tar zxvf php-5.0.2.tar.gz
在根目录上建一个/www的目录把程序都装到此目录里面
首先安装Mysql
#groupadd mysql //建立mysql用户组
#useradd -g mysql mysql //建立mysql用户
# cd /soft/lamp/mysql-4.0.21
# ./configure --prefix=/www/mysql --with-mysqld-user=zzw --with-charset=gb2312 --with-extra-charsets=all --with-unix-socket-path=/tmp/mysql.sock
[注]关于configure的选项的一点说明:
--prefix=/opt/mysql 把mysql-4.0.16指定安装到/opt/mysql目录中;
--with-charset=gb2312 指定mysql默认语言为gb2312,也就是中文;
--with-extra-charsets=all 对多语言的支持;
--with-unix-socket-path=/opt/mysql/var/mysql.sock 这个是指定mysql服务器启动后,联机套接字文件所处的位置和文件名,也就是说,如果mysql服务器成功启动后,就能在/opt/mysql/var目录中看到mysql.sock文件。如果看不到,肯定是mysql启动不了。
--with-mysqld-user=beinan 这个是让mysql服务器也能让系统中普通用户beinan也能启动mysql服务器。当然要活学活用了:)你也可以把beinan换成你的系统中已经存在的普通用户,比如您的系统中已经存在sir这个用户,那就把beinan替换成sir就行了。用普通用户来启动mysql的好处是:mysql的进程会自己死掉自动退出。当然root用户也可以,不过有时mysql有些进程死了,但不会自动退出,root自己也杀不掉。所以用普通用户就有这样的好处,大多不会出现mysql进程已死,但不会退出的情况;
# make //编译
# make install //安装
# cd /www/mysql/bin
# ./mysql_install_db //初始化数据库
# vi ~/.bashrc 加入
export PATH=“$PATH: /www/mysql/bin“ //把mysql/bin下的命令都加入到系统PATH里
加入启动项
# cp /www/mysql/share/mysql/mysql.server /etc/rc.d/init.d/mysql //复制mysql服务启动项文件
# chmod +x /etc/rc.d/init.d/mysql //执行权限
# chown -R mysql /www/mysql
# chown -R mysql /etc/rc.d/init.d/mysql //给mysql用户权限
-注--------------------------------------------------------------------
# chgrp -R mysql /www/mysql //给mysql的用户组读/www/mysql的权限
# chown -R mysql /www/mysql //给mysql用户读/www/mysql的权限
------------------------------------------------
# /sbin/chkconfig --del mysql
# /sbin/chkconfig --add mysql //把mysql放到启动项列表里
重启linux就安装好mysql了
如果不可以启动则试一下
#cd /www/mysql/bin
#./mysqld_safe --user=mysql &
二、安装Apache2
# cd httpd-2.0.52
# ./configure --prefix=/www/apache --enable-so --enable-rewrite
#make
#make install 编译安装完成后,启动apache
#cd /www/apache/bin
#./apachectl start
这样就启动了apache服务器
三、安装php
# cd php-5.0.2
#./configure --prefix=/www/php --with-mysql=/www/mysql --with-apxs2=/www/apache/bin/apxs --enable-track-vars --enable-force-cgi-redirect --with-config-file-path=/www/php/etc
一点说明:
--prefix=/www/php 指定把php-4.3.4安装到/opt/php目录中;
--with-mysql=/www/mysql 指定mysql数据服务器安装的位置;
--with-apxs2=/www/apache/bin/apxs 这是加入apache中为DSO模块的位置;
-enable-track-vars 为启动cookie的get/post等追踪功能
--with-config-file-path=/www/php/etc 指定php的配制文件存放的目录是/www/php/etc目录,我们安装完成后,也要把php.ini复制到这个目录中来。
# make
# make install
复制php.ini-dist为php.ini,并存放到/www/php/etc/目录下
# cp php.ini-dist /www/php/etc/php.ini
编辑/www/php/etc/php.ini文件,找到如下的一行
;default_charset = "iso-8859-1"
在这行下面加一行
default_charset = "gb2312"
把register_globals = Off改为register_globals = On
------------------------------------------------------
max_execution_time = 600 ;最大运行时间 600 秒
max_input_time = 600 ;最大输出时间 600秒
memory_limit = 20M ;最大内存限制 20M
file_uploads = On ;允许上载文件
upload_max_filesize = 20M ;最大文件大小 20M
post_max_size = 20M ;php可接受的 post 方法大小 20M
session.auto_start = 1 ;session自动启动
---------------------------------------------------
修改httpd.conf文件
# vi /www/apache/conf/httpd.conf
加入
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
AddType application/x-httpd-php .php3
#修改
AddDefaultCharset ISO-8859-1 改为 AddDefaultCharset gb2312
#加入默认的引导文件index.php(找到DirectoryIndex,修改如下:)
DirectoryIndex index.html index.html.var index.php
#指定网站目录(假设为 /apache 目录)
DocumentRoot "/apache"
安装完成
# cd /www/apache/bin/apachectl start/restart/stop
管理apache
apache在linux启动时,自动启动方法
方法一:
# vi /etc/rc.local 加入
/www/apache/bin/apachectl start
方法二:
# cp /www/apache/bin/apachectl /etc/rc.d/init.d/httpd
# cd /etc/rc.d/rc3.d
# ln -s ../init.d/httpd S80httpd
方法三:
自启动脚本:
/usr/local/apache2/bin;
./apachectl start
文件位于/etc/rc.d/init.d下,名为apached,注意要可执行.
#chmod +x /etc/rc.d/init.d/apached //设置文件的属性为可执行
#ln -s /etc/rc.d/init.d/apached /etc/rc3.d/S90apache //建立软连接,快捷方式
#ln -s /etc/rc.d/init.d/apached /etc/rc0.d/K20apache
方法三:
自启动脚本:
/usr/local/apache2/bin;
./apachectl start
文件位于/etc/rc.d/init.d下,名为apached,注意要可执行.
#chmod +x /etc/rc.d/init.d/apached //设置文件的属性为可执行
#ln -s /etc/rc.d/init.d/apached /etc/rc3.d/S90apache //建立软连接,快捷方式
#ln -s /etc/rc.d/init.d/apached /etc/rc0.d/K20apache