仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 640|回复: 7
打印 上一主题 下一主题

[shell编程] 来一发linux shell剧本之lnmp的搭建

[复制链接]
山那边是海 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-14 20:18:53 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!<divstyle="padding:0px;margin:0px;color:#2c2c2c;font-family:宋体,arialnarrow,arial,serif;font-size:14px;line-height:28px;background-color:#ffffff;"><divid="highlighter_819871"class="syntaxhighlighterbash"style="overflow:visible!important;width:718px;"><divclass="container">#!/bin/bash
#thisscriptissourcepackagesinstalledlnmpforredhatorcentos6.xmal
yum-yinstallwget
#"============downloadthesourcepackage=============="
wgethttp://cloud.github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
wgethttp://nginx.org/download/nginx-1.3.8.tar.gz
wgethttp://www.ckuyun.com/files/v2.8/cmake-2.8.6.tar.gz
wgethttp://ftp.gnu.org/gnu/bison/bison-2.5.1.tar.gz
wgethttp://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.30.tar.gz
wgethttp://ncu.dl.sourceforge.net/project/qdbm/qdbm/1.8.77/qdbm-1.8.77.tar.gz
wgethttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
wgethttp://fossies.org/linux/www/gd-2.0.35.tar.gz
wgethttp://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.bz2/download
wgethttp://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/mhash-0.9.9.9.tar.bz2/download
wgethttp://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz/download
wgethttp://cronolog.org/download/cronolog-1.6.2.tar.gz
wgethttp://cn2.php.net/distributions/php-5.4.14.tar.gz
wgethttp://ncu.dl.sourceforge.net/project/pcre/pcre/8.11/pcre-8.11.tar.gz
#"=============downloadall======================"
printf"========installthecompiletool=============
"
yum-yinstallgccgcc-c++openssl-develncursesncurses-develzlib-develbzip2bzip2-develcurl-devellibjpeg-devellibxml2*libpng*freetype*libxslt*
#yum-ygroupinstall"Development""DevelopmentTools"#orusethiscommandinsteadoftheabove
#tarthesourcepackage解压源代码包到指定的目次
tarzxvfpcre-8.11.tar.gz-C/usr/local/src/
tarzxvflibevent-2.0.21-stable.tar.gz-C/usr/local/src/
tarzxvfnginx-1.3.8.tar.gz-C/usr/local/src/
tarzxvfcmake-2.8.6.tar.gz-C/usr/local/src/
tarzxvfbison-2.5.1.tar.gz-C/usr/local/src/
tarzxvfmysql-5.5.30.tar.gz-C/usr/local/src/
tarzxvflibiconv-1.14.tar.gz-C/usr/local/src/
tarzxvfqdbm-1.8.77.tar.gz-C/usr/local/src/
tarzxvfgd-2.0.35.tar.gz-C/usr/local/src/
tarzxvfmcrypt-2.6.8.tar.gz-C/usr/local/src/
tarzxvfcronolog-1.6.2.tar.gz-C/usr/local/src/
tarzxvfphp-5.4.14.tar.gz-C/usr/local/src/
tarjxvflibmcrypt-2.5.8.tar.bz2-C/usr/local/src/
tarjxvfmhash-0.9.9.9.tar.bz2-C/usr/local/src/
#Compiletheunpackthesourcecodepackage编译解压的源代码包
echo"===========nginxRelevantsourcepackageisinstalled=========="
echo"#####pcreinstall#####"
cd/usr/local/src/pcre-8.11/
./configure--prefix=/usr/local/pcre&&make&&makeinstall
printf"====pcreisok====
"
echo"#####libeventinstall######"
cd/usr/local/src/libevent-2.0.21-stable/
./configure--prefix=/usr/local/libevent&&make&&makeinstall
printf"====libeventisok====
"
echo"####nginxinstall######"
groupadd-rnginx
useradd-r-gnginx-s/bin/false-Mnginx
cd/usr/local/src/nginx-1.3.8/
###beforeyouconfigure,youcansee"./configureChelp"seecarefully"Cwith-pcre=DIRsetpathtoPCRElibrarysources"在编译之前能够先help看看
./configure--prefix=/usr/local/nginx--with-pcre=/usr/local/src/pcre-8.11/--sbin-path=/usr/local/nginx/sbin/nginx--pid-path=/usr/local/nginx/logs/nginx.pid
--with-http_gzip_static_module--with-http_ssl_module--with-http_flv_module--with-http_stub_status_module--user=nginx--group=nginx
--http-proxy-temp-path=/var/tmp/nginx/proxy/--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/--lock-path=/var/lock/nginx.lock--http-client-body-temp-path=/var/tmp/nginx/client/
&&make&&makeinstall
printf"======nginxisok!!======
"
mkdir-pv/var/tmp/nginx/
#writestartupnginxfilesbyyourself本人手动写nginx的启动剧本
cat>>/etc/init.d/nginx<<EOF
#!/bin/bash
#nginxStartupscriptfortheNginxHTTPServer
#itisv.0.0.2version.
#chkconfig:C8515
#description:Nginxisahigh-performancewebandproxyserver.
#Ithasalotoffeatures,butit’snotforeveryone.
#processname:nginx
#pidfile:/var/run/nginx.pid
#config:/usr/local/nginx/conf/nginx.conf
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/usr/local/nginx/logs/nginx.pid
RETVAL=0
prog="nginx"
#Sourcefunctionlibrary.
./etc/rc.d/init.d/functions
#Sourcenetworkingconfiguration.
./etc/sysconfig/network
#Checkthatnetworkingisup.
[${NETWORKING}="no"]&&exit0
[-x$nginxd]||exit0
#Startnginxdaemonsfunctions.
start(){
if[-e$nginx_pid];then
echo"nginxalreadyrunning…."
exit1
fi
echo-n$"Starting$prog:"
daemon$nginxd-c${nginx_config}
RETVAL=$?
echo
[$RETVAL=0]&&touch/var/lock/subsys/nginx
return$RETVAL
}
#Stopnginxdaemonsfunctions.
stop(){
echo-n$"Stopping$prog:"
killproc$nginxd
RETVAL=$?
echo
[$RETVAL=0]&&rm-f/var/lock/subsys/nginx/usr/local/nginx/logs/nginx.pid
}
reload(){
echo-n$"Reloading$prog:"
#kill-HUP`cat${nginx_pid}`
killproc$nginxd-HUP
RETVAL=$?
echo
}
#Seehowwewerecalled.
case"$1"in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status$prog
RETVAL=$?
;;
*)
echo"Usage:$prog{start|stop|restart|reload|status|help}"
exit1
esac
exit$RETVAL
EOF
chmod+x/etc/init.d/nginx
chkconfig--addnginx
chkconfig--level35nginxon
servicenginxrestart
echo"===========mysqlRelevantsourcepackageisinstalled=========="
useradd-M-s/sbin/nologinmysql
echo"#####cmakeinstall#####"
cd/usr/local/src/cmake-2.8.6
./bootstrap&&gmake&&gmakeinstall
printf"====cmakeisok====
"
echo"#####bisoninstall#####"
cd/usr/local/src/bison-2.5.1/
./configure&&make&&makeinstall
printf"====bisonisok====
"
echo"#####mysqlinstall#####"
cd/usr/local/src/mysql-5.5.30/
cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DMYSQL_UNIX_ADDR=/tmp/mysql.sock-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci
-DWITH_EXTRA_CHARSETS:STRING=utf8,gbk-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_READLINE=1-DENABLED_LOCAL_INFILE=1
-DMYSQL_DATADIR=/var/mysql/data&&make&&makeinstall
printf"====mysqlisok====
"
#setupthemysqlconfigurationfileandinitializethedatabase创建mysql的设置文件和初始化数据库
#cpusr/local/mysql/support-files/my-huge.cnf/etc/my.cnf##ifyoumemoryisgreaterthan2G,pleasechoosethis内存年夜于2G就copy这个设置文件
cp/usr/local/mysql/support-files/my-medium.cnf/etc/my.cnf
cp/usr/local/mysql/support-files/mysql.server/etc/init.d/mysqld
/usr/local/mysql/scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql/--datadir=/var/mysql/data
/usr/local/mysql/bin/mysqld_safe--user=mysql
chmod-R755/usr/local/mysql
chown-Rmysql:mysql/usr/local/mysql
chown-Rmysql:mysql/var/mysql/data
chkconfig--addmysqld
chkconfig--level35mysqldon
servicemysqldrestart
read-p"pleasesetuppasswordformysql:"pwd
/usr/local/mysql/bin/mysqladmin-urootpassword$pwd
exportPATH=$PATH:/usr/local/mysql/bin/
echo"PATH=$PATH:/usr/local/mysql/bin">>/etc/profile
ln-s/usr/local/mysql/bin/*/usr/local/bin/
ln-s/usr/local/mysql/lib/*/usr/lib
ln-s/usr/local/mysql/include/mysql/*/usr/include/
echo"===========phpRelevantsourcepackageisinstalled=========="
echo"####libiconvinstall####"
cd/usr/local/src/libiconv-1.14/
./configure--prefix=/usr/local/libiconv&&make&&makeinstall
printf"====libiconvisok====
"
echo"####qdbminstall#####"
cd/usr/local/src/qdbm-1.8.77/
./configure--prefix=/usr/local/qdbm--enable-devel--enable-zlib--enable-iconv&&make&&makeinstall
printf"====qdbmisok====
"
echo"####gdinstall####"
cd/usr/local/src/gd-2.0.35/
./configure--prefix=/usr/local/gd2--with-jpeg--with-png--with-zlib--with-freetype&&make&&makeinstall
printf"====gdisok====
"
sed-i/*gd_free/avoid(*data);/usr/local/gd2/include/gd_io.h
echo"/usr/local/gd2/lib">>/etc/ld.so.conf
ldconfig
echo"####libmcryptandlibltdlinstall####"
cd/usr/local/src/libmcrypt-2.5.8/
./configure--prefix=/usr/local/libmcrypt&&make&&makeinstall
ldconfig
cd/usr/local/src/libmcrypt-2.5.8/libltdl
./configure--prefix=/usr/local/libltdl--enable-ltdl-install&&make&&makeinstall
ln-sf/usr/local/lib/libmcrypt.*/usr/lib
ln-sf/usr/local/bin/libmcrypt-config/usr/bin
printf"====libmcryptandlibltdlisok====
"
echo"####mhashinstall####"
cd/usr/local/src/mhash-0.9.9.9/
./configure--prefix=/usr/local/mhash&&make&&makeinstall
ln-sf/usr/local/lib/libmhash.*/usr/lib/
printf"====mhashisok====
"
echo"####mcryptinstall####"
cd/usr/local/src/mcrypt-2.6.8/
/sbin/ldconfig
./configure--prefix=/usr/local/mcrypt&&make&&makeinstall
printf"====mcryptisok====
"
echo"####cronologinstall####"
cd/usr/local/src/cronolog-1.6.2
./configure--prefix=/usr/local/cronolog&&make&&makeinstall
printf"====cronologisok====
"
echo"####phpinstall#####"
ln-sf/usr/local/mysql/lib/libmysqlclient.so.18/usr/lib
ln-sf/usr/local/qdbm/lib/libqdbm.so*/usr/lib
cd/usr/local/src/php-5.4.14
./configure--prefix=/usr/local/php5--with-config-file-path=/usr/local/php5/etc--with-mysql=/usr/local/mysql
--with-iconv=/usr/local/libiconv--with-gd=/usr/local/gd2--with-iconv-dir=/usr/local--with-pdo-mysql=/usr/local/mysql
--with-libxml-dir=/usr--with-qdbm=/usr/local/qdbm--with-mime-magic=/usr/share/file/magic--with-jpeg-dir--with-png-dir--with-freetype-dir
--with-bz2--with-zlib--without-pear--with-xmlrpc--with-zlib-dir--with-curl--with-curlwrappers--with-mcrypt=/usr/local/libmcrypt--with-mhash
--with-ttf--with-xsl--with-gettext--with-pear--with-openssl--enable-discard-path--enable-gd-native-ttf
--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--enable-mbregex--enable-xml
--enable-soap--enable-calendar--enable-wddx--enable-dba--enable-gd-native-ttf--enable-calendar--enable-safe-mode
--enable-ftp--enable-fpm--enable-zip--enable-mbstring--enable-bcmath--enable-sockets--enable-exif--enable-magic-quotes--disable-rpath--disable-debug
&& make&&makeinstall
printf"====phpisok====
"
ln-s/usr/local/php5/bin/*/usr/local/bin/
ln-s/usr/local/php5/sbin/*/usr/local/sbin/
cp/usr/local/src/php-5.4.14/php.ini-production/usr/local/php5/php.ini
#Configurenginxsupportphp设置nginx撑持php情况
cp/usr/local/php5/etc/php-fpm.conf.default/usr/local/php5/etc/php-fpm.conf
sed-i/run/s/;//g/usr/local/php5/etc/php-fpm.conf
sed-i/^/d/usr/local/php5/etc/php-fpm.conf
sed-is/nobody/nginx/g/usr/local/php5/etc/php-fpm.conf
sed-i/start/s/2/20//usr/local/php5/etc/php-fpm.conf
sed-i/min/s/1/5//usr/local/php5/etc/php-fpm.conf
sed-i/max_spare/s/3/25//usr/local/php5/etc/php-fpm.conf
sed-i/max_children/s/5/35//usr/local/php5/etc/php-fpm.conf
/usr/local/sbin/php-fpm#启动php-fpm历程
#testnginxmysqlphpworktegether
sed-i/<user>/ausernginx;/usr/local/nginx/conf/nginx.conf#把user改成nginx用户
sed-i/<index>/s/index.htmlindex.htm/index.htmlindex.htmindex.php/g/usr/local/nginx/conf/nginx.conf#增加撑持index.php
#这上面的六句本人手动的增加到nginx的设置文件内里往/usr/local/nginx/conf/nginx.conf
#location~.php${
#roothtml;
#fastcgi_pass127.0.0.1:9000;
#fastcgi_indexindex.php;
#includefastcgi.conf;
#}
cat>>/usr/local/nginx/html/test.php<<EOF
<?php
$link=mysql_connect(localhost,root,123456);
if($link)echo"<h1>lianjiemysqlchenggong!!</h1>";
mysql_close();
?>
EOF
servicenginxrestart
#doneallyoucantestlnmphttp://ip(testnginx)orhttp://ip/test.php(testnginxwithmysqlphp)
##############=========nginxandphp-fpmStartupscript##################
##############=========#!/bin/bash
##############=========#nginxandphp-fpmStartupscriptfortheNginxHTTPServer
##############=========#chkconfig:C8515
##############=========nginxd=/usr/local/nginx/sbin/nginx
##############=========nginx_config=/usr/local/nginx/conf/nginx.conf
##############=========nginx_pid=/usr/local/nginx/logs/nginx.pid
##############=========php_fpm=/usr/local/sbin/php-fpm
##############=========php_fpm_config=/usr/local/php5/etc/php-fpm.conf
##############=========php_fpm_pid=/usr/local/php5/var/run/php-fpm.pid
##############=========RETVAL=0
##############=========prog="nginx"
##############=========prog1="php-fpm"
##############=========#Sourcefunctionlibrary.
##############=========./etc/rc.d/init.d/functions
##############=========#Sourcenetworkingconfiguration.
##############=========./etc/sysconfig/network
##############=========#Checkthatnetworkingisup.
##############=========[${NETWORKING}="no"]&&exit0
##############=========[-x$nginxd]||exit0
##############=========#Startnginxdaemonsfunctions.
##############=========start(){
##############=========if[-e$nginx_pid];then
##############=========echo"nginxalreadyrunning…."
##############=========exit1
##############=========fi
##############=========echo-n$"Starting$prog:"
##############=========RETVAL=$?
##############=========echo
<divclass="linenumber288index287alt1">##############=========[$RETVAL=0]&&touch/var/lock/sub如果您觉得本篇CentOSLinux教程讲得好,请记得点击右边漂浮的分享程序,把好文章分享给你的好朋友们!
海妖 该用户已被删除
沙发
发表于 2015-1-24 07:34:44 | 只看该作者
一些显而易见的小错误还是用vi改正比较方便。以后的大一点的程序就得在Linux下调试了,因为有的头文件在VC里面说找不到。?
分手快乐 该用户已被删除
板凳
发表于 2015-2-1 09:41:59 | 只看该作者
笔者五分钟后就给出了解决方法: “首先备份原文件到其他目录,然后删掉/usr/local/unispim/unispimsp.ksc,编辑 /usr/local/unispim/unispimsp.ini,最后重启动计算机
莫相离 该用户已被删除
地板
发表于 2015-2-7 05:41:07 | 只看该作者
如果上面的措施没有解决问题,此时你就需要Linux社区的帮助了。 Linux的使用者一般都是专业人士,他们有着很好的电脑背景且愿意协助他人。
小女巫 该用户已被删除
5#
发表于 2015-2-21 09:59:51 | 只看该作者
应对Linux的发展历史和特点有所了解,Linux是抢占式多任务多用户操作系统,Linux最大的优点在于其作为服务器的强大功能,同时支持多种应用程序及开发工具。
若天明 该用户已被删除
6#
发表于 2015-3-6 21:15:27 | 只看该作者
Windows有MS-DOS?方式,在该方式下通过输入DOS命令来操作电脑;Linux与Windows类似,也有命令方式,Linux?启动后如果不执行?X-WINDOWS,就会处于命令方式下,必须发命令才能操作电脑。?
因胸联盟 该用户已被删除
7#
发表于 2015-3-13 22:10:02 | 只看该作者
下面笔者在论坛看到的一个好问题: “安装红旗4.0后,系统紫光输入法自带的双拼方案和我的习惯不一样,如何自定义双拼方案解决?谢谢?”这个问题很简练。
再现理想 该用户已被删除
8#
发表于 2015-3-20 21:54:19 | 只看该作者
随着Linux技术的更加成熟、完善,其应用领域和市场份额继续快速增大。目前,其主要应用领域是服务器系统和嵌入式系统。然而,它的足迹已遍布各个行业,几乎无处不在。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-12 09:50

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

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