shell 之 lnmp(nginx-1.0.5+php-fpm5.3.6+mysql)安装脚本

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群版 2核4GB 100GB
推荐场景:
搭建个人博客
云数据库 RDS MySQL,高可用版 2核4GB 50GB
简介:

详细请参考 nginx_笔记分享_1_安装篇(nginx-1.0.5+php-fpm5.3.6+mysql)

#update 20120717 

1 安装脚本以附件install.sh.txt 为准

2 需要调用mysql_server.sh 脚本

#update 20120718

1 安装脚本以附件install2.sh.txt 为准

 

脚本如下:

 
  1. #!/bin/bash 
  2. # nstall nginx php (php-fpm) mysql
  3. # by zm 20110731
  4.  
  5. #variables 
  6. dir=/usr/local 
  7.  
  8. #pcre 
  9. if [ ! -e "$dir/pcre" ];then 
  10.    #echo "not found" 
  11.    tar zxf pcre*.tar.gz 
  12.    cd pcre*/ 
  13.    ./configure --prefix="$dir/pcre" && make && make install 
  14.    cd ../ 
  15.    if [ ! -e "$dir/pcre" ];then 
  16.        echo "error! can't install prce  please check ! Will now out of the scri    pt!" 
  17.        exit 1 
  18.        # 
  19.        #rm -rf pcre*/ 
  20.    fi 
  21. else 
  22.    echo "prce is already exists!" 
  23. fi 
  24.   
  25. #openssl 
  26. if [ ! -e "$dir/openssl" ];then 
  27.    #echo "not found" 
  28.    tar zxf openssl*.tar.gz 
  29.    mv openssl*/ "$dir/openssl" 
  30. else 
  31.    echo "openssl is already exists!" 
  32. fi 
  33.  
  34. #nginx 
  35. if ! grep 'nginx' /etc/passwd;then 
  36.     useradd nginx -s /sbin/nologin 
  37. fi 
  38. if [ ! -e "$dir/nginx" ];then 
  39.        tar zxf nginx*.tar.gz 
  40.        cd nginx*/ 
  41.        ./configure --prefix=/usr/local/nginx --with-pcre=../pcre-8.12/  --with-openssl=/usr/local/openssl/ --with-http_ssl_module --with-http_flv_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/  --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --user=nginx  --group=nginx 
  42.        make && make install 
  43.        cd ../ 
  44.     if [ ! -e "$dir/nginx" ];then 
  45.        echo "error! can't install nginx  please check ! Will now out of the script!" 
  46.        exit 1 
  47.     else 
  48.        rm -rf nginx*/ 
  49.     fi 
  50. else 
  51.        echo "nginx uesr and nginx group is already exists!" 
  52.        echo "nginx is already exists!" 
  53. fi 
  54. #   
  55. if ! grep '/usr/local/nginx/sbin' /etc/profile>/dev/null;then 
  56.        sed -i '$,/export/ a\export PATH=$PATH:/usr/local/nginx/sbin' /etc/profile 
  57.        source /etc/profile 
  58.        mkdir -p /var/tmp/nginx/client/ 
  59. fi 
  60.      
  61. #mysql 
  62. if [ ! -e "$dir/php" ];then 
  63.    ./mysql_server.sh 
  64.    #cd ../ 
  65.    sleep 1 
  66. else 
  67.     echo "mysql_server Already exists" 
  68. fi 
  69.   
  70.  
  71. #freetype 
  72. if [ ! -d "$dir/freetype" ];then 
  73.    tar xzf freetype*.tar.gz  
  74.    cd  freetype*/ 
  75.    ./configure --prefix=/usr/local/freetype 
  76.    make && make install && make clean 
  77.    cd ../   
  78.    if [ ! -d /usr/local/freetype ] 
  79.       then 
  80.       echo "error! can't install freetype  please check ! Will now out of the script!" 
  81.       exit 1 
  82.    else 
  83.       rm -rf freetype*/ 
  84.    fi 
  85. else 
  86.     echo "freetype Already exists!" 
  87. fi 
  88.   
  89.  
  90. #curl 
  91. if [ ! -d "$dir/curl" ];then 
  92.    tar xzf curl*.gz 
  93.    cd  curl*/ 
  94.    ./configure --prefix=/usr/local/curl 
  95.    make && make install  
  96.    cd ../   
  97.    if [ ! -d "$dir/curl" ];then 
  98.       echo "error! can't install curl  please check ! Will now out of the script!" 
  99.       exit 1 
  100.    else 
  101.       rm -rf curl*/ 
  102.    fi 
  103.     echo "curl ok!" 
  104. else 
  105.     echo "curl Already exists!" 
  106. fi 
  107.  
  108.  
  109. #libiconv 
  110. if [ ! -d "$dir/libiconv" ];then 
  111.    tar xzf libiconv*.gz 
  112.    cd  libiconv*/ 
  113.    ./configure --prefix=/usr/local/libiconv 
  114.    make && make install 
  115.    cd ../ 
  116.    if [ ! -d "$dir/libiconv" ];then 
  117.       echo "error! can't install iconv  please check ! Will now out of the script!" 
  118.       exit 1 
  119.    else 
  120.       rm -rf libiconv*/ 
  121.       echo " /usr/local/libiconv/lib" >> /etc/ld.so.conf 
  122.       ldconfig 
  123.    fi 
  124.    echo "libiconv ok!" 
  125. else 
  126.    echo "libiconv Already exists!" 
  127. fi 
  128.  
  129.  
  130. #libpng 
  131. if [ ! -d "$dir/libpng" ];then 
  132.    tar xzf libpng*.gz 
  133.    cd  libpng*/ 
  134.    ./configure --prefix=/usr/local/libpng 
  135.    #make && make install && make clean 
  136.    make && make install  
  137.    #./configure && make && make install 
  138.    cd ../ 
  139.    if [ ! -d "$dir/libpng" ];then 
  140.       echo "error! can't install png  please check ! Will now out of the script!" 
  141.       exit 1 
  142.    else 
  143.       echo "libpng ok!" 
  144.       rm -rf libpng*/ 
  145.    fi 
  146. else 
  147.     echo "libpng Already exists!" 
  148. fi 
  149.  
  150.  
  151.  
  152. #jpeg 
  153. if [ ! -d "$dir/libjpeg" ];then 
  154.    tar xzf jpeg*.gz 
  155.    cd  jpeg*/ 
  156.    ./configure --prefix=/usr/local/libjpeg 
  157.    sed -i 's/CFLAGS\= -O2  -I\$(srcdir)/CFLAGS\= -O3 -I\$(srcdir) -fPIC/g' Makefile 
  158.    mkdir -p /usr/local/libjpeg/include 
  159.    mkdir -p /usr/local/libjpeg/lib 
  160.    mkdir -p /usr/local/libjpeg/bin 
  161.    mkdir -p /usr/local/libjpeg/man/man1 
  162.    make && make install-lib && make install 
  163.   cd ../ 
  164.   if [ ! -d "$dir/libjpeg" ];then 
  165.      echo "error! can't install jpeg  please check ! Will now out of the script!" 
  166.      exit 1 
  167.   else 
  168.      echo "libjpeg ok!" 
  169.      rm -rf jpeg*/ 
  170.   fi 
  171. else 
  172.   echo "libjpeg Already exists!" 
  173. fi 
  174.  
  175.  
  176.  
  177. #php5.3 
  178. if [ ! -e "$dir/php" ];then 
  179.    tar zxf php*.tar.gz 
  180.    cd php*/ 
  181.    ./configure --prefix=/usr/local/php  --with-config-file-path=/etc/ \ 
  182.  --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-curl=/usr/local/curl --with-libxml-dir=/usr/include/libxml2 --with-gd \ 
  183.  --with-jpeg-dir=/usr/local/libjpeg --with-png-dir=/usr/local/libpng --with-bz2 --with-freetype-dir=/usr/local/freetype --with-iconv-dir=/usr/local/libiconv \ 
  184.  --with-zlib-dir --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-exif --enable-dba --disable-ipv6 --disable-cgi \ 
  185.  --enable-bcmath --enable-sockets --enable-mbstring --enable-fpm 
  186.    make && make install 
  187.    cd ../ 
  188.    if [ ! -e "$dir/php" ];then 
  189.        echo "error! can't install php  please check ! Will now out of the scri    pt!" 
  190.        exit 1 
  191.    else 
  192.        ! grep 'php' /etc/profile && echo "export PATH=\$PATH:/usr/local/php/bin" >> /etc/profile && source /etc/profile 
  193.        ! grep 'php-fpm' /etc/profile && echo "export PATH=\$PATH:/usr/local/php/sbin" >> /etc/profile && source /etc/profile 
  194.        cp php*/php.ini-development /etc/php.ini 
  195.        cp php*/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm 
  196.        chmod 755 /etc/init.d/php-fpm 
  197.        sed -i 's/;pm.start_servers = 20/pm.start_servers = 20/' /usr/local/php/etc/php-fpm.conf.default  
  198.        sed -i 's/;pm.min_spare_servers = 5/pm.min_spare_servers = 5/' /usr/local/php/etc/php-fpm.conf.default  
  199.        sed -i 's/;pm.max_spare_servers = 35/pm.max_spare_servers = 35/' /usr/local/php/etc/php-fpm.conf.default  
  200.        sed -i 's/;pm.max_requests = 500/pm.max_requests = 500/' /usr/local/php/etc/php-fpm.conf.default   
  201.        cp "$dir/php/etc/php-fpm.conf.default" "$dir/php/etc/php-fpm.conf" 
  202.        #rm -rf php*/ 
  203.    fi 
  204. else 
  205.    echo "php is already exists!" 
  206. fi 

 


本文转自 dongnan 51CTO博客,原文链接: http://blog.51cto.com/dngood/629076



相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
7天前
|
关系型数据库 MySQL 数据库
数据迁移脚本优化过程:从 MySQL 到 Django 模型表
在大规模的数据迁移过程中,性能问题往往是开发者面临的主要挑战之一。本文将分析一个数据迁移脚本的优化过程,展示如何从 MySQL 数据库迁移数据到 Django 模型表,并探讨优化前后的性能差异。
|
1天前
|
应用服务中间件 Linux 网络安全
nginx安装的详细教程(包括命令行安装和编译安装)
nginx安装的详细教程(包括命令行安装和编译安装)
|
5天前
|
Shell
蓝易云 - 简单shell脚本的编写教程
以上就是编写一个基本Shell脚本的步骤。当然,Shell脚本可以做的远不止这些,你可以使用变量,控制结构(如if语句和循环),以及各种Shell命令和功能来编写更复杂的脚本。
12 1
|
7天前
|
NoSQL 关系型数据库 MySQL
linux服务器重启php,nginx,redis,mysql命令
linux服务器重启php,nginx,redis,mysql命令
16 1
|
1天前
|
移动开发 网络协议 Shell
查看IP访问量的shell脚本汇总
查看IP访问量的shell脚本汇总
|
3天前
|
应用服务中间件 Linux nginx
【项目部署系列教程】3. 安装宝塔 vs nginx
【项目部署系列教程】3. 安装宝塔 vs nginx
11 0
|
6天前
|
Shell 调度
Shell脚本中的if条件判断语句
Shell脚本中的if条件判断语句
|
6天前
|
Shell
蓝易云 - 简单shell脚本的编写教程
以上就是编写一个基本Shell脚本的步骤。当然,Shell脚本可以做的远不止这些,你可以使用变量,控制结构(如if语句和循环),以及各种Shell命令和功能来编写更复杂的脚本。
5 0
|
7天前
|
机器学习/深度学习 Unix Java
技术笔记:Linux之Shell脚本编程(一)
技术笔记:Linux之Shell脚本编程(一)
12 0
|
7天前
|
应用服务中间件 Linux 程序员
老程序员分享:nginx安装及其配置详细教程
老程序员分享:nginx安装及其配置详细教程