lamp升级

lamp升级
2011年08月23日
  --
  lamp
  mysql-cluster ---> 替换mysql-5.1.36
  rm /usr/local/mysql -rf --(留下/data/ /usr/src/lamp/mysql-5.1.36 通过make install进行恢复)
  使用mysql-cluster源码升级
  把配置文件数据目录指向/data
  /var/run/mysqld/mysql5.socket保持路径不变,php就可以找到mysql
  -----------------------------------------------------
  如果升级php扩展库
  如果升级gd库,
  1,重新编译新版本gd (参数尽量参考以前的编译参数)
  2,重编php
  升级apache
  1,重新编译新版本apache (参数尽量参考以前的编译参数)
  2,重编译php php 链接 /usr/local/apache2/bin/apxs
  升级php时要注意php.ini,记得替换一下
  升级gd,php
  gd-2.0.36RC1.tar.gz
  php-5.3.3.tar.bz2
  # tar xvf /share/soft/lamp/nginx/gd-2.0.36RC1.tar.gz -C /usr/src/lamp/
  cd /usr/src/lamp/gd-2.0.36/
  ./configure --with-gnu-ld --with-x --with-libiconv-prefix=/usr/local/ --with-png=/usr/local/ --with-freetype=/usr/local/ --with-fontconfig=/usr --with-jpeg=/usr/local/
  make; make install
  ldconfig
  # tar xvf /share/soft/lamp/php_source/php-5.3.3.tar.bz2 -C /usr/src/lamp/
  ./configure --with-apxs2=/usr/local/apache2/bin/apxs --enable-magic-quotes --disable-ipv6 --with-libxml-dir=/usr/local/ --with-zlib --with-bz2 --enable-calendar --with-curl --with-pcre-dir=/usr/local/ --with-gd=/usr/local/ --with-jpeg-dir=/usr/local/ --with-png-dir=/usr/local/ --with-freetype-dir=/usr/local/ --enable-gd-native-ttf --enable-mbstring --with-mcrypt=/usr/local/ --with-mhash=/usr/local/ --with-mysql=/usr/local/mysql/ --with-mysql-sock=/var/run/mysqld/mysql5.socket --with-mysqli=/usr/local/mysql/bin/mysql_config --with-snmp --enable-sockets --with-libxml-dir=/usr/local/ --with-iconv-dir=/usr/local/ --enable-zip --enable-zend-multibyte --with-gnu-ld --enable-sysvmsg --enable-sysvsem --enable-sysvshm --with-pdo-mysql=/usr/local/mysql/
  make ;make install
  注意安装信息,要求运行下面命令
  libtool --finish /usr/src/lamp/php-5.3.3/libs
  再注意安装信息
  Libraries have been installed in:
  /usr/src/lamp/php-5.3.3/libs
  echo /usr/src/lamp/php-5.3.3/libs >> /etc/ld.so.conf.d/lamp.conf
  ldconfig
  # cp /usr/src/lamp/php-5.3.3/php.ini-production /usr/local/lib/php.ini
  cp:是否覆盖“/usr/local/lib/php.ini”? y
  # vim /usr/local/lib/php.ini
  [MySQL]
  mysql.default_port = 3307
  mysql.default_socket = /var/run/mysqld/mysql5.socket
  [MySQLi]
  mysqli.default_port = 3307
  mysqli.default_socket = /var/run/mysqld/mysql5.socket
  重启apache,查看test.php页面,是升级到了php5.3.3
  因为5.3.3不支持eyeos等软件,而且phpmyadmin也不能使用
  php降级回去
  cd /usr/src/lamp/php-5.2.10/ --以前的这个源码包没有删除
  make install
  libtool --finish /usr/src/lamp/php-5.2.10/libs
  echo /usr/src/lamp/php-5.2.10/libs >> /etc/ld.so.conf.d/lamp.conf
  ldconfig
  vim /usr/local/lib/php.ini
  [MySQL]
  mysql.default_port = 3307
  mysql.default_socket = /var/run/mysqld/mysql5.socket
  [MySQLi]
  mysqli.default_port = 3307
  mysqli.default_socket = /var/run/mysqld/mysql5.socket
  重启apache
  ----------------------------------------------
  apache 错误页面的控制
  自定义错误控制页面
  vim /usr/local/apache2/conf/httpd.conf
  # Multi-language error messages
  Include conf/extra/httpd-multilang-errordoc.conf --打开这个子配置文件
  vim /usr/local/apache2/conf/extra/httpd-multilang-errordoc.conf
  可以看到多种错误号,对应的多种错误页面都存放在/usr/local/apache2/error/下面
  ErrorDocument 404 /error/notfounderror.html --修改一个新的文件名
  # cd /usr/local/apache2/error/
  # vim notfounderror.html --创建这个文件,并在里面写上你想要的错误信息,可以写一个html的静态页面,加上图片
  重启apache
  再用浏览器访问一个不存在的页面,就会返回刚才自定义的错误信息
  -------------------------------------------------------------------
  php加速
  zend optimizer  Zend优化器――优化你的PHP代码。
  /share/soft/lamp/php_source/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
  # tar xvf /share/soft/lamp/php_source/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz -C /usr/src/lamp/
  # cd /usr/src/lamp/ZendOptimizer-3.3.3-linux-glibc23-i386/
  直接./install.sh
  安装完毕后查看/usr/local/lib/php.ini 最后是否自动加入了下面这段配置
  [Zend]
  zend_extension_manager.optimizer=/usr/local/Zend/lib/Optimizer-3.3.3
  zend_extension_manager.optimizer_ts=/usr/local/Zend/lib/Optimizer_TS-3.3.3
  zend_optimizer.version=3.3.3
  zend_extension=/usr/local/Zend/lib/ZendExtensionManager.so
  zend_extension_ts=/usr/local/Zend/lib/ZendExtensionManager_TS.so
  eaccelerator Accelerator是一个自由开放源码php加速器,优化和动态内容缓存,提高了php脚本的缓存性能,使得PHP脚本在编译的状态下,对服务器的开销几乎完全消除。 它还有对脚本起优化作用,以加快其执行效率。使您的PHP程序代码执效率能提高1-10倍;
  /share/soft/lamp/eaccelerator-0.9.5.2.tar.tar
  # tar xvf /share/soft/lamp/eaccelerator-0.9.5.2.tar.tar -C /usr/src/lamp/
  # cd /usr/src/lamp/eaccelerator-0.9.5.2/
  phpize - prepare a PHP extension for compiling
  # /usr/local/bin/phpize --先用此命令,才会有configure文件,就可以进行编译了
  Configuring for:
  PHP Api Version: 20041225
  Zend Module Api No: 20060613
  Zend Extension Api No: 220060519
  ./configure --with-php-config=/usr/local/bin/php-config --with-eaccelerator-sessions --with-eaccelerator-shared-memory --enable-eaccelerator
  make ;make install
  注意安装信息
  Libraries have been installed in:
  /usr/src/lamp/eaccelerator-0.9.5.2/modules
  Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/
  echo /usr/src/lamp/eaccelerator-0.9.5.2/modules >> /etc/ld.so.conf.d/lamp.conf
  ldconfig
  调用eaccelerator插件需要在php.ini里配置
  vim /usr/local/lib/php.ini
  extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613/"
  [eaccelerator]
  extension="eaccelerator.so"
  eaccelerator.shm_size="16"
  eaccelerator.cache_dir="/tmp/eaccelerator"
  eaccelerator.enable="1"
  eaccelerator.optimizer="1"
  eaccelerator.check_mtime="1"
  eaccelerator.debug="0"
  eaccelerator.filter=""
  eaccelerator.shm_max="0"
  eaccelerator.shm_ttl="0"
  eaccelerator.shm_prune_period="0"
  eaccelerator.shm_only="0"
  eaccelerator.compress="1"
  eaccelerator.compress_level="9"
  # mkdir /tmp/eaccelerator
  # chmod 777 /tmp/eaccelerator/
  重启apache,验证/tmp/eaccelerator下是否产生了一些子目录
  # ls /tmp/eaccelerator/
  0 1 2 3 4 5 6 7 8 9 a b c d e f
  验证test.php看是否有zend和eaccelerator配置信息段
  并使用浏览器访问php网站,再去查看/tmp/eaccelerator的大小,是否增大
  -----------------------------------------------------------------
  memcache
  高性能的分布式内存缓存服务器,通过缓存数据库查询结果,减少数据库访问次数,以提高动态web应用的速度
  client
  | |
  应用服务器
  | |
  数据库 memcache
  第一次,从数据库中取得数据保存到memcached
  第二次,从memcached中取得数据
  http://www.memcached.org/
  # tar xvf /share/soft/lamp/apache_source/memcached-1.4.1.tar.gz -C /usr/src/lamp/
  # cd /usr/src/lamp/memcached-1.4.1/
  ./configure --with-libevent=/usr/local/
  make ;make install
  # memcached -p 11211 -l 127.0.0.1 -d -u daemon -m 64m
  -p TCP port number to listen on (default: 11211)
  -l interface to listen on (default: INADDR_ANY, all addresses)
  -d run as a daemon
  -m max memory to use for items in megabytes (default: 64 MB)
  -u assume identity of (only when run as root)
  # netstat -ntlup |grep 11211
  tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN 28752/memcached
  udp 0 0 127.0.0.1:11211 0.0.0.0:* 28752/memcached
  php-->链接memcached
  # tar xvf /share/soft/lamp/apache_source/memcache-2.2.5.tar.gz -C /usr/src/lamp/
  # cd /usr/src/lamp/memcache-2.2.5/
  # /usr/local/bin/phpize
  ./configure --with-php-config=/usr/local/bin/php-config --enable-memcache
  注意安装信息
  Libraries have been installed in:
  /usr/src/lamp/memcache-2.2.5/modules
  Installing shared extensions: /usr/local/lib/php/extensions/no-debug-non-zts-20060613/ --这个目录因为上面安装eaccelerator时,已经加入到php.ini文件里,所以这里不用加
  echo /usr/src/lamp/memcache-2.2.5/modules >> /etc/ld.so.conf.d/lamp.conf
  ldconfig
  修改php.ini增加memcached的扩展
  extension_dir = "/usr/local/lib/php/extensions/no-debug-non-zts-20060613/"--这一句前面装eaccelerator时装过,这里不用再加
  extension="memcache.so"
  重启apache,查看test.php是否有memcache的扩展配置段
  ------------------
  安装wiki并使用memcached做为链接对象
  # tar xvf /share/soft/lamp/LAMP_source/mediawiki-1.13.0.tar.gz -C /web/
  cd /web/mediawiki-1.13.0/
  chmod a+w config/
  ----------------------------------------
  补充:php的session控制
  安装时检查安装环境,有下面的警告
  Warning: A value for session.save_path has not been set in PHP.ini. If the default value causes problems with saving session data, set it to a valid path which is read/write/execute for the user your web server is running under.
  vim /usr/local/lib/php.ini
  session.save_handler = files --这一句默认是打开的
  session.save_path = "/tmp/session" --这一句没有,加上这一句
  session.use_cookies = 1 --cookies认证
  # mkdir /tmp/session
  # chmod 777 /tmp/session/
  重启apache,再刷新一下wiki的安装界面
  session警告就没有了,代替的是下面的信息
  Session save path (/tmp/session) appears to be valid.
  ---------------------------------------------
  在object caching选项里选择 memcached
  memcached server 填 上 127.0.0.1:11211
  mysql> create database wikidb;
  mysql> grant all on wikidb.* to 'wikiuser'@'localhost' identified by '123';
  mysql> flush privileges;
  再去wiki的安装界面填写数据授权选项
  # Connected to memcached on 127.0.0.1:11211 successfully
  Generating configuration file...
  # Database type: MySQL
  # Loading class: DatabaseMysql
  # Attempting to connect to database server as wikiuser...success.
  # Connected to 5.1.36-log; enabling MySQL 4.1/5.0 charset mode
  # Database wikidb exists
  # Creating tables... done.
  # Initializing statistics...
  # Created sysop account admin.
  #
  Creating LocalSettings.php...
  # mv config/LocalSettings.php .
  安装完毕
  --------------------------------------------------------------------------
  apache 限制功能 针对不同的虚拟主机来限制
  # tar xvf /share/soft/lamp/apache_source/mod-cband-0.9.7.2.tgz -C /usr/src/lamp/
  # cd /usr/src/lamp/mod-cband-0.9.7.2/
  ./configure --with-apxs=/usr/local/apache2/bin/apxs
  make;make install
  # vim /usr/local/apache2/conf/httpd.conf --查看配置文件里是否自动加载了mod_cband.so
  LoadModule cband_module modules/mod_cband.so
  http://cband.linux.pl/documentation --PDF文档里指定的文档路径,自动跳转到下面的url
  http://codee.pl/cband_documentation.html
  # vim /usr/local/apache2/conf/httpd.conf
  Include conf/extra/httpd-vhosts.conf --打开虚拟主机子配置文件
  # vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
  NameVirtualHost *:80
  
  DocumentRoot "/web"
  ServerName 10.1.1.35
  ErrorLog "logs/10.1.1.35-error_log"
  CustomLog "logs/10.1.1.35-access_log" common
  cbandlimit 100M --指允许的总流量,也就是到达100M后,不允许再下载
  cbandperiod 1W --总流量的清0时间,1W表示1week,就是一星期内最大只允许被下载100M
  cbandspeed 300 10 30 --当前时间的总带宽, 每秒可以同时连接数 最大的总连接数
  cbandremotespeed 10kb/s 3 3 --每个用户下载最高速度为10k,每秒同时3个连接数,每个IP生成3个连接
  
  SetHandler cband-status
  odrer allow,deny
  allow from 10.1.1.35 -- 只允许10.1.1.35访问cband-status
  
  
  SetHandler cband-status-me
   --这两小段是查看cband的状态信息
  
  重启apache
  在网站家目录下dd创建一个大点的文件,做下载测试
  # dd if=/dev/zero of=/web/1.img bs=1M count=1000
  # wget http://10.1.1.35/1.img --使用wget下载测试
  并用浏览器查看
  http://10.1.1.35/cband-status
  和
  http://10.1.1.35/cband-status-me 这两个图形化的页面
  -----------------------------------------------------
  增加apache最大连接数
  # ab -n 10000 -c 10000 http://10.1.1.35:8080/1.img
  会报socket: Too many open files (24) 的错误
  # vim /etc/security/limits.conf
  daemon soft nofile 20000
  daemon hard nofile 20000
  daemon soft nproc 20000
  daemon hard nproc 20000
  mysql soft nofile 20000
  mysql hard nofile 20000
  mysql soft nproc 20000
  msyql hard nproc 20000
  
  serverlimit 2500
  StartServers 10
  MinSpareServers 10
  MaxSpareServers 15
  MaxClients 2000
  MaxRequestsPerChild 1000
  
  # lsof -i:8080
  COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
  httpd 2998 root 3u IPv4 282432 TCP *:webcache (LISTEN)
  httpd 2999 daemon 3u IPv4 282432 TCP *:webcache (LISTEN)
  httpd 3000 daemon 3u IPv4 282432 TCP *:webcache (LISTEN)
  httpd 3001 daemon 3u IPv4 282432 TCP *:webcache (LISTEN)
  httpd 3002 daemon 3u IPv4 282432 TCP *:webcache (LISTEN)
  httpd 3003 daemon 3u IPv4 282432 TCP *:webcache (LISTEN)
  httpd 3004 daemon 3u IPv4 282432 TCP *:webcache (LISTEN)
  httpd 3005 daemon 3u IPv4 282432 TCP *:webcache (LISTEN)
  httpd 3006 daemon 3u IPv4 282432 TCP *:webcache (LISTEN)
  httpd 3007 daemon 3u IPv4 282432 TCP *:webcache (LISTEN)
  httpd 3008 daemon 3u IPv4 282432 TCP *:webcache (LISTEN)
  ----------------------------------------------------
  mod_dosevaseive 播件防DDOS
  # ls /share/soft/lamp/apache_source/mod_dosevasive.1.8.tar.gz
  # tar xvf /share/soft/lamp/apache_source/mod_dosevasive.1.8.tar.gz -C /usr/src/
  # cd /usr/src/mod_dosevasive-1.8/
  查看readme里有apache2.x版本的安装方法
  APACHE v2.0
  -----------
  1. Extract this archive
  2. Run $APACHE_ROOT/bin/apxs -i -a -c mod_dosevasive20.c
  3. The module will be built and installed into $APACHE_ROOT/modules, and loaded into your httpd.conf
  4. Restart Apache
  # /usr/local/apache2/bin/apxs -i -a -c /usr/src/mod_dosevasive-1.8/mod_dosevasive20.c --按照readme的方法把模块编译成DSO形式
  # vim /usr/local/apache2/conf/httpd.conf --编译完后,可以在apache的配置文件里找到下面这一句
  LoadModule dosevasive20_module modules/mod_dosevasive20.so
  # vim /usr/local/apache2/conf/httpd.conf --在配置文件
   --注意是有20的那段,表示的是apache2.x版本
  DOSHashTableSize 3097
  DOSPageCount 2
  DOSSiteCount 50
  DOSPageInterval 1
  DOSSiteInterval 1
  DOSBlockingPeriod 10
  
  # /usr/local/apache2/bin/apachectl start --启动apache
  测试:
  用客户端firefox访问测试
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值