Linux+Apache+Mysql+Perl/PHP/Python一组常用来搭建或者服务器的,本身都是各自独立的程序,但是因为常被放在一起使用,拥有了越来越高的兼容度,共同组成了一个强大的Web平台。随着开源潮流的蓬勃发展,开放源的LAMP已经与和形成三足鼎立之势,并且该软件开发的项目在软件方面的投资成本较低,因此受到整个界的关注。从网站的流量上来说,70%以上的访问流量是LAMP来提供的,LAMP是最强大的网站解决方案

实验环境

centos6.5_x64

实验软件

autoconf-2.61.tar.gz    

libxml2-2.6.30.tar.gz

libpng-1.2.31.tar.gz

libmcrypt-2.5.8.tar.gz 

freetype-2.3.5.tar.gz

libiconv-1.13.1.tar.gz

gd-2.0.35.tar.gz 

jpegsrc.v8b.tar.gz

zlib-1.2.3.tar.gz

httpd-2.2.9.tar.gz

mysql-5.0.41.tar.gz

php-5.2.6.tar.gz

memcache-3.0.8.tgz 

     

软件安装

yum install -y gcc  gcc-c++ make  lsof  lrzsz  vim  ntp     wget openssl openssl-devel  fontconfig-devel.x86_64  libgd*

yum install -y   ncurses-devel  libxml2-devel libpng-devel  libXpm-devel.x86_64  libtool-ltdl-devel cyrus-sasl  libmcrypt  libtool* libtomcrypt*  glibc.i686

tar zxvf libiconv-1.13.1.tar.gz

cd libiconv-1.13.1

./configure --prefix=/usr/local/libiconv && make && make install

tar zxvf libxml2-2.6.30.tar.gz

cd libxml2-2.6.30

./configure --prefix=/usr/local/libxml2 && make && make install

tar zxvf libmcrypt-2.5.8.tar.gz

cd libmcrypt-2.5.8

./configure --prefix=/usr/local/libmcrypt && make && make install

tar zxvf zlib-1.2.3.tar.gz

cd zlib-1.2.3

CFLAGS="-O3 -fPIC" ./configure --prefix=/usr/local/zlib && make && make install

tar zxvf libpng-1.2.31.tar.gz 

cd libpng-1.2.31

./configure --prefix=/usr/local/libpng && make && make install

tar zxvf jpegsrc.v8b.tar.gz

cd jpeg-8b/

mkdir -pv /usr/local/jpeg8/ {bin,lib,include}

mkdir -p /usr/local/jpeg8/man/man1

./configure --prefix=/usr/local/jpeg8/ --enable-shared --enable-static  && make && make install

tar zxvf freetype-2.3.5.tar.gz

cd freetype-2.3.5

./configure --prefix=/usr/local/freetype &&  make && make install

tar zxvf autoconf-2.61.tar.gz 

cd autoconf-2.61

./configure && make && make install

tar zxvf gd-2.0.35.tar.gz

cd gd-2.0.35

./configure --prefix=/usr/local/gd2 \

--enable-m4_pattern_allow  \

--with-zlib=/usr/local/zlib  --with-jpeg=/usr/local/jpeg8 \

--with-png=/usr/local/libpng --with-freetpye=/usr/local/freetype/

make  && make install

tar zxvf httpd-2.2.9.tar.gz

cd httpd-2.2.9

./configure --prefix=/usr/local/apache2 \

--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

cp -pv /usr/local/apache2/conf/httpd.conf /usr/local/apache/conf/httpd.conf.bak

sed -i "s/#ServerName www.example.com:80/ServerName *:80/g" /usr/local/apache2/conf/httpd.conf

echo 'welcome to apache server' > /usr/local/apache2/htdocs/index.html 

cp -pv /etc/rc.d/init.d/httpd /etc/rc.d/init.d/httpd.bak

sed -i '1 a# chkconfig: 2345 80 81' /etc/rc.d/init.d/httpd

sed -i '2 a# Description: this is httpd server' /etc/rc.d/init.d/httpd

service httpd restart/start/stop

chkconfig --level 35 httpd on

pkill httpd    杀死进程

netstat -tuplna | grep httpd

tcp        0      0 :::80                       :::*                        LISTEN      15841/httpd 

ps -ef | grep httpd

root     15841     1  0 16:21 ?      00:00:00 /usr/local/apache/bin/httpd -k start

daemon   15842 15841  0 16:21 ?        00:00:00 /usr/local/apache/bin/httpd -k start

curl  http://localhost/index.html

welcome to apache server

/usr/sbin/groupadd mysql

/usr/sbin/useradd -g mysql mysql

tar zxvf mysql-5.0.41.tar.gz

cd mysql-5.0.41

./configure --prefix=/usr/local/mysql  --with-extra-charsets=all

make && make install 

chown -R mysql:mysql /usr/local/mysql/

cp -pv support-files/my-medium.cnf /etc/my.cnf 

cp -pv support-files/mysql.server  /etc/rc.d/init.d/mysqld

nohup /usr/local/mysql/bin/mysql_install_db --user=mysql  &

chmod +x /etc/init.d/mysqld

service mysqld restart   启动服务            

/usr/local/mysql/bin/mysqladmin  -uroot password 数据库密码 password 数据库密码有空格

/usr/local/mysql/bin/mysql -uroot -p数据库密码 -p数据库密码无空格

cp -pv /etc/profile /etc/profile.bak

echo 'PATH=/usr/local/mysql/bin:$PATH' >>  /etc/profile

echo 'export PATH' >>  /etc/profile

source /etc/profile

cp -pv /etc/my.cnf  /etc/my.cnf.bak

sed -i '37 adatadir = /usr/local/mysql/data'  /etc/my.cnf   

37 配置文件37行前插入  adatadir = /usr/local/mysql/data  a配置文件前插入 datadir = /usr/local/mysql/data 执行命令

netstat -tuplna | grep mysqld

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      15875/mysqld       

ps -aux | grep mysqld

Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ

root     15850  0.0  0.1 106120  1344 pts/0    S    19:54   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --user=mysql

mysql    15875  0.3  2.6 275752 26676 pts/0    Sl   19:54   0:00 /usr/local/mysql/libexec/mysqld --basedir=/usr/local/mysql --datadir=/usr/local/mysql/var --user=mysql --pid-file=/usr/local/mysql/var/centos6.pid --skip-external-locking --port=3306 --socket=/tmp/mysql.sock

root     15894  0.0  0.0 103328   844 pts/0    S+   19:55   0:00 grep mysqld

tar zxvf php-5.2.6.tar.gz

cd php-5.2.6

cp -pv /usr/local/apache2/build/libtool /root/php-5.2.6

./configure --prefix=/usr/local/php \       

--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/jpeg8/ \

--with-freetype-dir=/usr/local/freetype/ \

--with-gd=/usr/local/gd2/ \

--with-zlib-dir=/usr/local/zlib/ \

--with-mcrypt=/usr/local/libmcrypt/ \

--with-mysqli=/usr/local/mysql/bin/mysql_config \

--with-iconv=/usr/local/libiconv

--enable-soap --enable-mbstring=all  --enable-sockets 

make && make install

cp -pv  php.ini-dist  /usr/local/php/etc/php.ini

cp -pv /usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.conf.bak

sed -i 's/#AddType application/AddType application/g' /usr/local/apache2/conf/httpd.conf

sed -i '300 aAddType application/x-httpd-php .php' /usr/local/apache2/conf/httpd.conf

service httpd  restart

pkill  httpd

touch /usr/local/apache2/htdocs/test.php  

echo '<?php phpinfo(); ?>'  >  /usr/local/apache2/htdocs/test.php

memcache-3.0.8.tgz                 安装扩展模块

cd memcache-3.0.8

/usr/local/php/bin/phpize

./configure --with-php-config=/usr/local/php/bin/php-config

make && make install

ll /usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/

memcache.so

cp -pv /usr/local/php/etc/php.ini /usr/local/php/etc/php.ini.bak

sed -i '486 aextension = memcache.so' /usr/local/php/etc/php.ini     配置文件486行后插入extension=memcache.so