Chinaunix首页 | 论坛 | 博客
  • 博客访问: 88850
  • 博文数量: 29
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 281
  • 用 户 组: 普通用户
  • 注册时间: 2014-01-02 18:00
文章分类
文章存档

2014年(29)

我的朋友

分类: 网络与安全

2014-01-25 11:20:26

LAMP(Linux-Apache-MySQL-PHP)网站架构是目前国际流行的Web框架,该框架包括:Linux操作系统,Apache网络服务器,MySQL数据库,Perl、PHP或者Python编程语言,所有组成产品均是开源软件,是国际上成熟的架构框架,很多流行的商业应用都是采取这个架构,和Java/J2EE架构相比,LAMP具有Web资源丰富、轻量、快速开发等特点,微软的.NET架构相比,LAMP具有通用、跨平台、高性能、低价格的优势,因此LAMP无论是性能、质量还是价格都是企业搭建网站的首选平台。

  对于大流量、大并发量的网站系统架构来说,除了硬件上使用高性能的服务器、负载均衡、CDN等之外,在软件架构上需要重点关注下面几个环节:使用高性能的操作系统(OS)、高性能的网页服务器(Web Server)、高性能的数据库(Databse)、高效率的编程语言等。

   我选择的包是 httpd-2.2.25.tar.gz    mysql-5.1.34.tar.gz  php-5.4.19.tar.gz


#!/bin/bash


APACHEDIR=/usr/local/apache

MYSQLDIR=/usr/local/mysql

PHPDIR=/usr/local/php

HTTPD=httpd-2.2.25

MYSQL=mysql-5.1.34

PHP=php-5.4.19

TAR=.tar.gz

APACHEMBER=81

APACHENU=82

MYSQLMBER=83

MYSQLNU=84

MYSQLNUMBER=85

PHPMBER=86

HTTPDPORT=$(lsof -i :80 | awk 'NR==2{print $1}' )

MYSQLPORT=$(lsof -i :3306 | awk 'NR==2{print $1}' )


  netstat -nl | grep :80 &> /dev/null


 if [ $? -eq 0 ];then


       pkill -9 $HTTPDPORT

  else

       echo " 80 port already by release"

 fi


    netstat -nl | grep :3306 &> /dev/null


     if [ $? -eq 0 ];then

    pkill -9 $MYSQLPORT

else

    echo " 3306 port already by release "

    fi


for  package  in  {gcc,gcc-c++,openssl-devel,openssl,ncurses-devel,libtermcap-devel,ncurses,libtermcap,libxml2,libxml2-devel}


do

rpm -q $package &> /dev/null

  if [ $? != 0 ];then

   yum -y install $package

    else

   echo " $package  already install "


  fi


done


echo "----------------------------------------------------------------------"

echo " install apache "

sleep 3


    cd /root


      tar -zxf /root/$HTTPD$TAR  


  cd /root/$HTTPD


./configure  --prefix=$APACHEDIR --enable-so --enable-rewrite \

    --enable-ssl --enable-cgi --enable-charset-lite  \

    --enable-suexec  --with-suexec-caller=daemon   \

    --with-suexec-docroot=$APACHEDIR/htdocs    

  if [ $? -eq 0 ];then

make && make install


    else

echo " apache install failed "

 exit $APACHEMBER

  fi

cp $APACHEDIR/bin/apachectl /etc/init.d/apache

sed -i '2c # chkconfig: 35 85 15 ' /etc/init.d/apache

sed -i '3c # description: Apache is a world web server' /etc/init.d/apache

sed -i '/#ServerName/s/\*/' $APACHEDIR/conf/httpd.conf


ln -s $APACHEDIR/bin/* /usr/sbin/

chkconfig --add apache

service apache start

chkconfig  apache on

 if [ $? -eq 0 ];then

echo "------------------------------------------------------------------------"

echo " install mysql"


sleep 3


 id mysql &> /dev/null


      if [ $? != 0 ];then

useradd mysql

        else

echo "user mysql already exist"


      fi


 cd /root


     tar -zxf /root/$MYSQL$TAR


cd /root/$MYSQL


./configure --prefix=$MYSQLDIR --with-charset=utf8 \

           --with-collation=utf8_general_ci  \

   --with-extra-charsets=all  \

   --exec-prefix=$MYSQLDIR  \

   --with-client-ldflags=-all-static \

   --with-mysqld-ldflags=-all-static \

           --with-innodb   --with-plugins=partition


  if  [ $? -eq 0 ];then

make && make install


else

echo " mysql install failed"

exit &MYSQLMBER

 fi


test -f /etc/my.cnf


if [ $? -eq 0 ];then

mv /etc/my.cnf /etc/my.conf

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


else

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


fi


   cp support-files/mysql.server /etc/init.d/mysql && chmod +x /etc/init.d/mysql

      cp support-files/mysql.server /etc/rc.d/init.d/mysql && chmod +x /etc/rc.d/init.d/mysql


chkconfig --add mysql


 chown -R mysql.mysql $MYSQLDIR/*


ln -s $MYSQLDIR/bin/* /usr/sbin/

 ln -s $MYSQLDIR/lib/mysql/* /usr/lib64/

   ln -s $MYSQLDIR/include/mysql/*  /usr/include/

             sed -i  's/^skip-federated$/# skip-federated/' /etc/my.cnf


mysql_install_db --user=mysql  


if [ $? -eq 0 ];then

    :

  else

        echo " mysql servier initialize failed "

  exit  $MYSQLNUMBER

fi

    else

echo  "apache start failed please check up after the continue "

 exit $APACHENU

 fi


service mysql restart


chkconfig mysql on


if [ $? -eq 0 ];then


echo "-----------------------------------------------------------------------"

echo "install php"

    sleep 3


 cd /root


tar -zxf /root/$PHP$TAR


 cd /root/$PHP


./configure  --prefix=$PHPDIR  --with-apxs2=$APACHEDIR/bin/apxs  \

    --with-mysql=$MYSQLDIR  --with-config-file-php=$PHPDIR \

    --enable-mbstring  --enable-sockets \

  if [ $? -eq 0 ];then

  make && make install


     else

  echo "php install failed"

   exit $PHPMBER

          fi


   cp php.ini-development $PHPDIR/php/php.ini

       sed -i '311a    AddType application/x-httpd-php .php' $APACHEDIR/conf/httpd.conf

  sed -i '168c DirectoryIndex index.html index.php' $APACHEDIR/conf/httpd.conf

service apache restart

chkconfig apache on


    else


echo "mysql start failed please check up after the continue"

exit $MYSQLNU


  fi


for  delete in { $MYSQL,$PHP,$HTTPD}


do

     rm -rf /root/$delete


done
阅读(1165) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~