1.安装mysql数据库
tar -zxvf mysql-5.1.58.tar.gz
cd mysql-5.1.58
./configure --prefix=/usr/local/mysql --enable-assembler --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-readline --with-ssl--with-embedded-server --enable-local-infile --with-plugins=partition,innobase,myisammrg
make
make install
创建MySQL数据库服务器的配置文件
cp support-files/my-medium.cnf /etc/my.cnf
cd /usr/local/mysql/
初始化mysql数据库
bin/mysql_install_db --user=mysql
修改文件及其目录的权限,使其目录或文件的宿主为root,宿组为mysql,(data的宿主为mysql)
chown -R root .
chown -R mysql data
chgrp -R mysql .
启动mysql数据库
/usr/local/mysql/bin/mysqld_safe --user=mysql &
netstat -tnl|grep 3306
设置mysql启动脚本文件
cp support-files/mysql.server /etc/rc.d/init.d/mysqld
chmod +x /etc/rc.d/init.d/mysqld
编辑/etc/rc.d/init.d/mysqld
指定mysql安装的目录basedir
/etc/init.d/mysqld restart
/usr/local/mysql/bin/mysql -uroot -p
2.安装apache服务器
创建apache用户和用户组
/usr/sbin/groupadd apache
/usr/sbin/useradd -g apache -M -s /sbin/nologin apache -M 参数说明给apache不创建家目录
tar -zxvf httpd-2.2.15.tar.gz
cd httpd-2.2.15
./configure --prefix=/usr/local/httpd/ --enable-deflate --enable-headers --enable-modules=so --enable-so --with-mpm=worker --enable-rewrite --enable-cgi --enable-file-cache --enable-cache --enable-disk-cache --enable-mem-cache
make
make install
修改apache运行的用户和用户组daemon为apache
vim /usr/local/httpd/conf/httpd.conf
65 User apache
66 Group apache
启动apache服务
/usr/local/httpd/bin/apachectl start
查看apache是否启动成功
[root@mail httpd-2.2.15]# netstat -antlp |grep "LISTEN" |grep "80"
tcp 0 0 :::80 :::* LISTEN 19706/httpd
设置开机自动重启apache服务
vim /etc/rc.d/rc.local 最后添加
/usr/local/httpd/bin/apachectl start
3.安装PHP
tar -zxvf php-5.2.13.tar.gz
cd php-5.2.13
./configure --prefix=/usr/local/php 指定PHP安装路径
--with-apxs2=/usr/local/httpd/bin/apxs 告诉PHP查找Apache目录
--with-mysql=/usr/local/mysql 指定mysql安装路径
--with-mysqli=/usr/local/mysql/bin/mysql_config 指定mysql启动文件存放目录
--with-config-file-path=/usr/local/php/etc
--with-ttf
--with-libxml-dir
--with-xmlrpc
--with-openssl
--with-zlib
--with-freetype-dir
--with-gd
--with-gettext
--with-jpeg-dir
--with-png-dir
--with-mhash
--with-curl
--with-curlwrappers
--with-mcrypt
--with-iconv=/usr/local/libiconv
--enable-short-tags
--enable-sockets
--enable-xml
--enable-zend-multibyte
--enable-soap
--enable-mbstring
--enable-static
--enable-inline-optimization
--enable-gd-native-ttf
--enable-inline-optimization
--enable-exif --enable-mbregex
在编译PHP时候出现下面错误信息,安装相应的软件包即可
1)If configure fails try --with-xpm-dir=
yum install gd
2)configure: error: libpng.(a|so) not found.
yum install libjpeg
yum install libjpeg-devel
yum install libpng
yum install libjpeg-devel
3)configure: error: Please reinstall the iconv library.
tar -zxvf libiconv-1.13.1.tar.gz
cd libiconv-1.9.2
./configure --prefix=/usr/local/libiconv
make
make install
4)configure: error: mcrypt.h not found. Please reinstall libmcrypt.
yum install libmcrypt libmcrypt-devel
5)configure: error: Please reinstall libmhash - I cannot find mhash.h
yum install libmhash mhash-devel
make
make install
4)LAMP整合
拷贝PHP主配置文件
cp php.ini-dist /usr/local/lib/php.ini
配置apache主配置文件,添加下面内容
vim /usr/local/httpd/conf/httpd.conf
LoadModule php5_module modules/libphp5.so 共享对象打开
#AddType application/x-gzip .tgz
AddType application/x-httpd-php .php 添加PHP应用程序
DirectoryIndex index.html index.php 添加PHP默认主页类型
重启启动apache服务
/usr/local/httpd/bin/apachectl stop
/usr/local/httpd/bin/apachectl start
编写PHP测试网页
vim /usr/local/httpd/htdocs/ phpinfo.php
phpinfo();
?>
在客户端测试LAMP整合是否successful
6)安装phpMyAdmin
tar -zxvf phpMyAdmin-3.2.4-all-languages.tar.gz
mkdir -p /var/www/
mv phpMyAdmin-3.2.4-all-languages /var/www/phpMyAdmin/
cp /var/www/phpMyAdmin/config.sample.inc.php /var/www/phpMyAdmin/config.inc.php
vim /var/www/phpMyAdmin/config.inc.php 指定下面选项即可
$cfg['Servers'][$i]['host'] = '127.0.0.1'; 把localhost修改为127.0.0.1
$cfg['Servers'][$i]['user'] = 'root'; 指定mysql服务器的用户名,可以是其他用户,但必须要给该用户授权
$cfg['Servers'][$i]['password'] = 'mysql'; 指定mysql数据库密码
创建phpMyAdmin.conf配置文件
vim /usr/local/httpd/conf/extra/phpMyAdmin.conf
Alias /phpMyAdmin /var/www/phpMyAdmin
Order deny,allow
Deny from all
Allow from 127.0.0.1
Allow from 192.168.1.115 指定客户端连接的IP地址
编辑apache的主配置文件添加下面内容
vim /usr/local/httpd/conf/httpd.conf
Include conf/extra/phpMyAdmin.conf
重启apache服务就大功告成啦
/usr/local/httpd/bin/apachectl restart