LAMP平台搭建
lunux版本:[红帽企业Linux.5.4].rhel-server-5.4-i386-dvd.iso
检查是否已经安装GCC,APR
#rpm -qa |grep gcc
#rpm -qa |grep apr
#rpm -qa |grep httpd
#rpm -qa |grep mysql
#rpm -e httpd --nodeps
#rpm -e mysql --nodeps
先用YUM源安装GCC,APR
#yum install gcc*
#yum install apr*
下载lamp所需的安装包共13个源码包
解压至/usr/src下
tar xzvf *** -C /usr/src
安装时进入各自目录:
[root@localhost libxml2-2.6.30]# ./configure --prefix=/usr/local/libxml
make
make install
[root@localhost ~]# mkdir -p /usr/local/libmcrypt
[root@localhost limcrypt-2.5.8]# ./configure --
prefix=/usr/local/limcrypt
make
make install
[root@localhost zlib-1.2.3]# ./configure --prefix=/usr/local/zlib
make
make install
[root@localhost libpng-1.2.31]# ./configure --prefix=/usr/local/libpng
make
make install
安装JPEG6包时,需要先创建JPEG文件夹,JPEG不自动创建文件夹:
[root@localhost libpng-1.2.31]# mkdir /usr/local/jpeg6
[root@localhost libpng-1.2.31]# mkdir /usr/local/jpeg6/bin
[root@localhost libpng-1.2.31]# mkdir /usr/local/jpeg6/lib
[root@localhost libpng-1.2.31]# mkdir /usr/local/jpeg6/include
[root@localhost libpng-1.2.31]# mkdir /usr/local/jpeg6/man/man1
[root@localhost libpng-1.2.31]# ./configure --prefix=/usr/local/jpeg6
make
make install
[root@localhost freetype-2.3.5]# ./configure --
prefix=/usr/local/freetype/
make
make install
[root@localhost autoconf-2.61]# ./configure
make
make install
配置GD库:
[root@localhost gd-2.0.35]# ./configure --prefix=/usr/local/gd2/ \
> --with-zlib=/usr/local/zlib/ \
> --with-jpeg=/usr/local/jpeg6/ \
> --with-png=/usr/local/libpng/ \
> --with-freetype=/usr/local/freetype/
[root@gfwebserver gd-2.0.35]# vi gd_png.c错误修改(GD库文件找不到)
(/usr/local/libpng/include/png.h)
make
make install
配置安装Apache:
[root@localhost httpd-2.2.9]# ./configure --prefix=/usr/local/apache2/
--sysconfdir=/etc/httpd --with-z=/usr/local/zlib --with-included-apr -
-enable-so --enable-deflate=shared --enable-expires=shared --enable-
rewrite=shared --enable-static-support
make
make install
安装MYSQL:
创建用户组:
#groupadd mysql
#useradd -g mysql mysql 在用户组mysql内再加入mysql
#id mysql
配置
mysql# ./configure --prefix=/usr/local/mysql --with-extra-charsets=all
make
make install
cp /usr/local/support-files/my-medium.conf /etc/my.cnf
mysql#bin/mysql_install_db --user=mysql
#chown -R mysql var // /var目录用户组改为mysql
#chgrp -R mysql.
#netstat -tnl 查看启用端口
#/usr/local/mysql/bin/mysqld_safe --user=mysql & //后台运行
#/mysql/bin/mysqladmin version
#/bin/mysql
mysql>select * from mysql.user \G 查看用户列表
mysql>delete from mysql.user where host!='localhost'; 删除除了localhost
以外的用户
mysql>flush privileges;刷新列表
mysql>set password for 'root'@'localhost'=password('123456'); //设备
密码
mysql>exit //退出
#bin/mysql -u root -h localhost -p 本地登录
Enter password:
#bin/mysqladmin -u root -p shutdwon //关闭mysql
#/usr/local/bin/mysqld_safe --user=mysql & //后台运行启用
设置自启动
#ls /etc/rc.local
#echo "/usr/local/apache2/apachectl start" >>/etc/rc.local //加载自动
启动HTTPD
#echo "/usr/local/mysql/bin/mysqld_safe --user=mysql &" >> /etc/rc.local
//加载自启动mysql
[root@localhost mysql]# chown -R mysql var //修改VAR目录为MYSQL用户
[root@localhost mysql]# chgrp -R mysql var //修改VAR目录为MYSQL用户组
配置PHP
[root@local php]#./configure --prefix=/usr/local/php --with-config-
file-path=/usr/local/php/etc --with-apxs2=/usr/local/apache2/bin/apxs
--with-mysql=/usr/local/mysql --with-libxml-dir=/usr/local/libxml2/ --
with-png-dir=/usr/local/libpng/ --with-jpeg-dir=/usr/local/jpeg6/ --
with-freetype-dir=/usr/local/freetype/ --with-gd=/usr/local/gd2/ --
with-mcrypt=/usr/local/libmcrypt/ --with-
mysqli=/usr/local/mysql/bin/mysql_config --enable-soap --enable-
mbstring=all --enable-sockets
make
make install
配置php模块:
复制源文件目录的php.ini-dist到/usr/local/php/etc下:
[root@localhost php-5.2.6]# cp php.ini-dist /usr/local/php/etc/php.ini
配置APACHE配置文件 httpd.conf
#vim /usr/local/apache2/etc/conf/httpd.conf
插入一行 AddType application/x-httpd-php .php .phtml
#
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php .phtml
安装好LAMP后测试,
# tail -f /usr/local/apache2/logs/error_log //查看HTTP错误访问日志
错误:
[notice] caught SIGTERM, shutting down
[Fri Nov 04 17:18:01 2011] [notice] Apache/2.2.9 (Unix) PHP/5.2.6
configured -- resuming normal operations
加速器安装
[root@localhost ZendOptimizer-3.2.6-linux-glibc21-i386]# ./install.sh
phpmyadmin安装
[root@localhost ~]# cp -a /usr/src/phpMyAdmin-3.0.0-rc1-all-languages/
/usr/local/apache2/htdocs/phpmyadmin
[root@localhost ~]# cd /usr/local/apache2/htdocs/phpmyadmin/
[root@localhost phpmyadmin]# cp config.sample.inc.php config.inc.php
关闭防火墙
开启: service iptables start
关闭: service iptables stop