LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 715|回复: 2

[原创] Apache+PHP+MySQL... 编译安装脚本

[复制链接]
发表于 2005-7-12 15:28:33 | 显示全部楼层 |阅读模式
本脚本自动下载并编译安装 Apache v2.0.54 + PHP v4.4.0 + MySQL v4.0.25 及相关软件,并自动修改 mysql 最大连接数 100 为 1000,自动加入 Apache 及 MySQL 自动启动。
测试系统:Debian Linux Sarge 3.1r0
作者: keelort
网站: http://www.micronsky.net


  1. #!/bin/bash

  2. rm -R bw_mod-0.6 > /dev/null
  3. rm -R ClibPDF > /dev/null
  4. rm -R curl-7.14.0 > /dev/null
  5. rm -R freetype-2.1.10 > /dev/null
  6. rm -R gd-2.0.33 > /dev/null
  7. rm -R httpd-2.0.54 > /dev/null
  8. rm -R jpeg-6b > /dev/null
  9. rm -R libiconv-1.9.2 > /dev/null
  10. rm -R libpng-1.2.8 > /dev/null
  11. rm -R mod_dosevasive > /dev/null
  12. rm -R mod_limitipconn-0.22 > /dev/null
  13. rm -R mysql-4.0.25 > /dev/null
  14. rm -R openssl-0.9.7g > /dev/null
  15. rm -R php-4.4.0 > /dev/null
  16. rm -R ZendOptimizer-2.5.10-linux-glibc21-i386 > /dev/null
  17. rm -R zlib-1.2.2 > /dev/null

  18. ##### Download #####
  19. echo "[Downloading...]";echo -e "\a";sleep 6

  20. echo "[1/16]";wget -N http://www.apache.org/dist/httpd/httpd-2.0.54.tar.gz
  21. echo "[2/16]";wget -N http://cn.php.net/distributions/php-4.4.0.tar.gz
  22. echo "[3/16]";wget -N http://download.softagency.net/MySQL/Downloads/MySQL-4.0/mysql-4.0.25.tar.gz
  23. echo "[4/16]";wget -N http://downloads.zend.com/optimizer/2.5.10/ZendOptimizer-2.5.10-linux-glibc21-i386.tar.gz
  24. echo "[5/16]";wget -N http://curl.haxx.se/download/curl-7.14.0.tar.gz
  25. echo "[6/16]";wget -N http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.9.2.tar.gz
  26. echo "[7/16]";wget -N http://www.openssl.org/source/openssl-0.9.7g.tar.gz
  27. echo "[8/16]";wget -N http://savannah.nongnu.org/download/freetype/freetype-2.1.10.tar.gz
  28. echo "[9/16]";wget -N http://www.boutell.com/gd/http/gd-2.0.33.tar.gz
  29. echo "[10/16]";wget -N http://www.fastio.com/clibpdf202r1.tar.gz
  30. echo "[11/16]";wget -N http://www.ijg.org/files/jpegsrc.v6b.tar.gz
  31. echo "[12/16]";wget -N http://switch.dl.sourceforge.net/sourceforge/libpng/libpng-1.2.8.tar.gz
  32. echo "[13/16]";wget -N http://www.zlib.net/zlib-1.2.2.tar.gz
  33. echo "[14/16]";wget -N http://dominia.org/djao/limit/mod_limitipconn-0.22.tar.gz
  34. echo "[15/16]";wget -N http://www.ivn.cl/apache/bw_mod-0.6.tgz
  35. echo "[16/16]";wget -N http://www.nuclearelephant.com/projects/dosevasive/mod_dosevasive_1.10.tar.gz

  36. ##### Decompression #####
  37. echo "[Decompressing...]";echo -e "\a";sleep 6

  38. for i in `ls *.gz`;do tar zxvf $i; done;
  39. for i in `ls *.tgz`;do tar zxvf $i; done;

  40. mkdir /data
  41. mkdir /data/mysql-db
  42. mkdir /data/vhosts
  43. mkdir /data/vhosts/0
  44. mkdir /server
  45. mkdir /server/conf
  46. mkdir /server/conf/vhosts
  47. mkdir /server/conf/vhosts-ssl

  48. ##### zlib #####
  49. echo "[Installing zlib...]";echo -e "\a";sleep 6

  50. cd zlib-1.2.2

  51. ./configure

  52. make && make install

  53. cd ..

  54. rm -R zlib-1.2.2

  55. ##### OpenSSL #####
  56. echo "[Intalling OpenSSL...]";echo -e "\a";sleep 6

  57. cd openssl-0.9.7g

  58. ./config --prefix=/usr/local \
  59. shared \
  60. zlib

  61. make && make install

  62. cd ..

  63. rm -R openssl-0.9.7g

  64. ##### MySQL #####
  65. echo "[Installing MySQL...]";echo -e "\a";sleep 6

  66. cd mysql-4.0.25

  67. sed -i 's/\&max_connections, 0, GET_ULONG, REQUIRED_ARG, 100,/\&max_connections, 0, GET_ULONG, REQUIRED_ARG, 1000,/g' ./sql/mysqld.cc

  68. apt-get install libncurses5-dev

  69. groupadd mysql
  70. useradd -g mysql mysql

  71. ./configure \
  72. --prefix=/server/mysqld \
  73. --sysconfdir=/server/conf \
  74. --without-isam \
  75. --without-debug \
  76. --enable-assembler \
  77. --with-unix-socket-path=/tmp/mysql.sock \
  78. --with-mysqld-user=mysql \
  79. --with-extra-charset=all \
  80. --with-client-ldflags=-all-static \
  81. --with-mysqld-ldflags=-all-static \
  82. --localstatedir=/data/mysql-db

  83. make && make install

  84. /server/mysqld/bin/mysql_install_db --user=mysql

  85. chown -R mysql /data/mysql-db
  86. chgrp -R mysql /data/mysql-db
  87. chown -R root /server/mysqld
  88. chgrp -R mysql /server/mysqld

  89. cp /server/mysqld/share/mysql/my-medium.cnf /server/conf/my.cnf

  90. /server/mysqld/share/mysql/mysql.server start
  91. sleep 3
  92. /server/mysqld/bin/mysqladmin -u root password 1029384756

  93. cd ..

  94. rm -R mysql-4.0.25

  95. ##### Apache2 #####
  96. echo "[Installing Apache2...]";echo -e "\a";sleep 6

  97. cd httpd-2.0.54

  98. ./configure --prefix=/server/httpd \
  99. --enable-so \
  100. --with-mysql=/server/mysqld \
  101. --enable-cgi \
  102. --enable-cgid \
  103. --with-config-file-path=/server/conf \
  104. --enable-track-vars \
  105. --enable-mods-shared=all \
  106. --enable-cache \
  107. --enable-disk-cache \
  108. --enable-mem-cache \
  109. --enable-rewrite \
  110. --with-mpm=worker \
  111. --enable-mime-magic \
  112. --enable-static-support \
  113. --enable-static-htpasswd \
  114. --enable-static-htdigest \
  115. --enable-static-rotatelogs \
  116. --enable-static-logresolve \
  117. --enable-static-htdbm \
  118. --enable-static-ab \
  119. --enable-static-checkgid \
  120. --with-ssl=/usr/local \
  121. --enable-ssl

  122. make && make install

  123. mkdir /server/conf/vhosts
  124. mkdir /server/conf/vhosts-ssl
  125. mkdir /data/vhosts
  126. mkdir /data/vhosts/localhost
  127. mv /server/httpd/conf/* /server/conf
  128. rm -R /server/httpd/conf
  129. ln -s /server/conf /server/httpd/conf

  130. cd ..

  131. ##### FreeType #####
  132. echo "[Installing FreeType...]";echo -e "\a";sleep 6

  133. cd freetype-2.1.10

  134. ./configure --prefix=/usr/local

  135. make && make install

  136. cd ..

  137. rm -R freetype-2.1.10

  138. ##### LibPNG #####
  139. echo "[Installing LibPNG...]";echo -e "\a";sleep 6

  140. cd libpng-1.2.8

  141. cp scripts/makefile.linux makefile

  142. make test
  143. make install

  144. cd ..

  145. rm -R libpng-1.2.8

  146. ##### Jpeg #####
  147. echo "[Installing Jpeg...]";echo -e "\a";sleep 6

  148. cd jpeg-6b

  149. mkdir /usr/local/man/man1
  150. ./configure --prefix=/usr/local --enable-shared --enable-static

  151. make && make install

  152. cd ..

  153. rm -R jpeg-6b

  154. ##### GD Library #####
  155. echo "[Installing GD Library...]";echo -e "\a";sleep 6

  156. cd gd-2.0.33

  157. ./configure --prefix=/usr/local \
  158. --with-jpeg=/usr/local \
  159. --with-freetype=/usr/local \
  160. --with-png \
  161. --with-zlib

  162. make && make install

  163. cd ..

  164. rm -R gd-2.0.33

  165. ##### ClibPDF #####
  166. echo "[Installing ClibPDF...]";echo -e "\a";sleep 6

  167. cd ClibPDF/source
  168. cp Makefile.Linux makefile

  169. make && make install

  170. cd ../../

  171. rm -R ClibPDF

  172. ##### LibIconv #####
  173. echo "[Installing LibIconv...]";echo -e "\a";sleep 6

  174. cd libiconv-1.9.2

  175. ./configure --prefix=/usr/local

  176. make && make install

  177. cd ..

  178. rm -R libiconv-1.9.2

  179. ##### cURL #####
  180. echo "[Installing cURL...]";echo -e "\a";sleep 6

  181. cd curl-7.14.0

  182. ./configure --prefix=/usr/local

  183. make && make install

  184. cd ..

  185. rm -R curl-7.14.0

  186. ##### PHP #####
  187. echo "[Installing PHP...]";echo -e "\a";sleep 6

  188. cd php-4.4.0

  189. ./configure --prefix=/server/php \
  190. --with-apxs2=/server/httpd/bin/apxs \
  191. --with-gd=/usr/local \
  192. --enable-gd \
  193. --enable-gd-native-ttf \
  194. --with-jpeg-dir=/usr/local \
  195. --with-png \
  196. --with-ttf \
  197. --with-zlib \
  198. --with-zlib-dir \
  199. --with-freetype-dir=/usr/local \
  200. --enable-magic-quotes \
  201. --with-mysql=/server/mysqld \
  202. --with-mysql-sock=/tmp/mysql.sock \
  203. --with-iconv=/usr/local \
  204. --with-curl=/usr/local \
  205. --with-mbstring \
  206. --enable-mbstring \
  207. --enable-track-vars \
  208. --enable-force-cgi-redirect \
  209. --enable-ftp \
  210. --with-config-file-path=/server/conf \
  211. --with-openssl=/usr/local \
  212. --with-openssl-dir=/usr/local \
  213. --with-cpdflib=/usr/local \
  214. --with-pear=/server/php/pear

  215. make && make install

  216. cp php.ini-dist /server/conf/php.ini

  217. cd ..

  218. rm -R php-4.4.0

  219. #########################################################################
  220. ##### mod_deflate #####
  221. echo "[Installing mod_deflate...]";echo -e "\a";sleep 6

  222. /server/httpd/bin/apxs -i -c -a httpd-2.0.54/modules/filters/mod_deflate.c

  223. rm -R httpd-2.0.54

  224. ##### mod_limitipconn #####
  225. echo "[Installing mod_limitipconn...]";echo -e "\a";sleep 6

  226. /server/httpd/bin/apxs -i -c -a mod_limitipconn-0.22/mod_limitipconn.c

  227. rm -R mod_limitipconn-0.22

  228. ##### Bandwidth Module #####
  229. echo "[Installing Bandwidth Module...]";echo -e "\a";sleep 6

  230. /server/httpd/bin/apxs -i -c -a bw_mod-0.6/bw_mod-0.6.c

  231. rm -R bw_mod-0.6

  232. ##### Apache DoS Evasive Maneuvers Module #####
  233. echo "[Installing Apache DoS Evasive Maneuvers Module...]";echo -e "\a";sleep 6

  234. /server/httpd/bin/apxs -i -c -a mod_dosevasive/mod_dosevasive20.c

  235. rm -R mod_dosevasive

  236. ##### Configure Install #####
  237. echo "[Configuring...]";echo -e "\a";sleep 6

  238. sed -i 's/\#ExtendedStatus On/ExtendedStatus On/g' /server/conf/httpd.conf
  239. sed -i 's/\#NameVirtualHost \*/NameVirtualHost \*/g' /server/conf/httpd.conf
  240. cp /server/httpd/bin/apachectl /etc/init.d/httpd
  241. cp /server/mysqld/share/mysql/mysql.server /etc/init.d/mysqld

  242. ##### Run Time #####
  243. cp -R /server/conf /server/conf-bak
  244. sed -i 's/ServerAdmin you\@example\.com/\#ServerAdmin you\@example\.com/g' /server/conf/httpd.conf
  245. sed -i 's/\/server\/httpd\/htdocs/\/data\/vhosts\/localhost/g' /server/conf/httpd.conf
  246. sed -i 's/Options Indexes FollowSymLinks/Options FollowSymLinks/g' /server/conf/httpd.conf
  247. sed -i 's/DirectoryIndex index.html index.html.var/DirectoryIndex index.html index.htm index.php/g' /server/conf/httpd.conf
  248. sed -i 's/AddHandler cgi-script \.cgi/AddHandler cgi-script \.cgi \.pl/g' /server/conf/httpd.conf
  249. sed -i 's/UserDir public_html/\#UserDir public_html/g' /server/conf/httpd.conf

  250. ln -s /etc/init.d/httpd /etc/rc2.d/S20httpd
  251. ln -s /etc/init.d/httpd /etc/rc3.d/S20httpd
  252. ln -s /etc/init.d/httpd /etc/rc4.d/S20httpd
  253. ln -s /etc/init.d/httpd /etc/rc5.d/S20httpd

  254. ln -s /etc/init.d/mysqld /etc/rc2.d/S20mysqld
  255. ln -s /etc/init.d/mysqld /etc/rc3.d/S20mysqld
  256. ln -s /etc/init.d/mysqld /etc/rc4.d/S20mysqld
  257. ln -s /etc/init.d/mysqld /etc/rc5.d/S20mysqld

  258. echo "[Ending...]"
  259. echo $SECONDS "Seconds"
复制代码


原文: http://bbs.micronsky.net/viewtopic.php?t=390
发表于 2005-7-12 19:46:15 | 显示全部楼层
不用下载?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-7-13 15:07:54 | 显示全部楼层
自动下载的
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表