注:需先上传各安装包至服务器。

#!/bin/bash
#! auto install lnmp #! 安装依赖环境
yum -y groupinstall "X Software Development"
yum -y install libxml2 libxml2-devel bzip2-devel curl-devel libjpeg-devel libpng-devel freetype-devel openssl openssl-devel pcre-devel #! 提取安装包目录及安装包名称
nginxtar=`find / -name "nginx-*" | grep tar | xargs dirname`
nginxname=`find / -name "nginx-*" | grep tar | awk -F / '{print $NF}'`
mariadbtar=`find / -name "mariadb-*" | grep tar | xargs dirname`
mariadbname=`find / -name "mariadb-*" | grep tar | awk -F / '{print $NF}'`
cpunum=`cat /proc/cpuinfo |grep "physical id"|sort |uniq|wc -l `
phptar=`find / -name "php-*" | grep tar | xargs dirname`
phpname=`find / -name "php-*" | grep tar | awk -F / '{print $NF}'` #! 创建相应用户和组 for i in nginx mysql
do
if id $i >/dev/null >&;then
echo "$i已存在"
else
groupadd -r $i
useradd -r -g $i $i
fi
done #! 安装nginx
cd $nginxtar
tar xf $nginxname
nginxdir=`find $nginxtar -maxdepth -type d | grep nginx-`
cd $nginxdir
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_flv_module --with-http_stub_status_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/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre
make && make install #! 编写nginx启动脚本
cat >> /etc/rc.d/init.d/nginx << EOF
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: -
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid # Source function library.
. /etc/rc.d/init.d/functions # Source networking configuration.
. /etc/sysconfig/network # Check that networking is up.
[ "\$NETWORKING" = "no" ] && exit nginx="/usr/local/nginx/sbin/nginx"
prog=\$(basename \$nginx) NGINX_CONF_FILE="/etc/nginx/nginx.conf" [ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx lockfile=/var/lock/subsys/nginx make_dirs() {
# make required directories
user=\`\$nginx -V >& | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -\`
options=\`\$nginx -V >& | grep 'configure arguments:'\`
for opt in \$options; do
if [ \`echo \$opt | grep '.*-temp-path'\` ]; then
value=\`echo \$opt | cut -d "=" -f \`
if [ ! -d "\$value" ]; then
# echo "creating" \$value
mkdir -p \$value && chown -R \$user \$value
fi
fi
done
} start() {
[ -x \$nginx ] || exit
[ -f \$NGINX_CONF_FILE ] || exit
make_dirs
echo -n \$"Starting \$prog: "
daemon \$nginx -c \$NGINX_CONF_FILE
retval=\$?
echo
[ \$retval -eq ] && touch \$lockfile
return \$retval
} stop() {
echo -n \$"Stopping \$prog: "
killproc \$prog -QUIT
retval=\$?
echo
[ \$retval -eq ] && rm -f \$lockfile
return \$retval
} restart() {
configtest || return \$?
stop
sleep
start
} reload() {
configtest || return \$?
echo -n \$"Reloading \$prog: "
killproc \$nginx -HUP
RETVAL=\$?
echo
} force_reload() {
restart
} configtest() {
\$nginx -t -c \$NGINX_CONF_FILE
} rh_status() {
status \$prog
} rh_status_q() {
rh_status >/dev/null >&
} case "\$1" in
start)
rh_status_q && exit
\$
;;
stop)
rh_status_q || exit
\$
;;
restart|configtest)
\$
;;
reload)
rh_status_q || exit
\$
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit
;;
*)
echo \$"Usage: \$0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit
esac
EOF chmod +x /etc/rc.d/init.d/nginx
chkconfig --add nginx
chkconfig nginx on #! 安装mysql cd $mariadbtar
tar xf $mariadbname
mariadbdir=`find $mariadbtar -maxdepth -type d | grep mariadb-`
mkdir -p /mydata/data
ln -sv $mariadbdir /usr/local/mysql
cd /usr/local/mysql
chown -R mysql:mysql .
scripts/mysql_install_db --user=mysql --datadir=/mydata/data
chown -R root .
cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
sed -e '/thread_concurrency = 8/a\datadir = /mydata/data' /etc/my.cnf -i
sed -e 's|thread_concurrency = 8|thread_concurrency = '$cpunum'|' /etc/my.cnf -i
cp /usr/local/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
echo 'MANPATH /usr/local/mysql/man' >>vi /etc/man.config
ln -sv /usr/local/mysql/include /usr/include/mysql
echo '/usr/local/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
ldconfig
echo 'PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile
echo 'export PATH' >> /etc/profile
# source /etc/profile #! 安装php
cd $phptar
tar xf $phpname
phpdir=`find $phptar -maxdepth -type d | grep php-` cd $phptar
cd $phpdir
./configure --prefix=/usr/local/php --with-config-file-path=/etc --with-bz2 --with-curl --enable-ftp --enable-sockets --disable-ipv6 --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-freetype-dir=/usr/local --enable-gd-native-ttf --with-iconv-dir=/usr/local --enable-mbstring --enable-calendar --with-gettext --with-libxml-dir=/usr/local --with-zlib --with-pdo-mysql=mysqlnd --with-mysqli=mysqlnd --with-mysql=mysqlnd --enable-dom --enable-xml --enable-fpm --with-libdir=lib64 --enable-bcmath
make && make install
cp php.ini-production /etc/php.ini
cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
chkconfig --add php-fpm
chkconfig php-fpm on
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf service nginx start
service mysqld start
service php-fpm start

自动安装lnmp的更多相关文章

  1. 一个自动安装LNMP的简洁Shell脚本

    此脚本在生产服务器上使用了一年多,本脚本崇尚简单唯美,只需要一个脚本就可以在任何一台有网络的服务器上自动配置LNMP.本脚本会在脚本执行目录下,建packages目录用于存放LNMP所需要的软件.大家 ...

  2. ansible批量自动安装LNMP

  3. LNMP安装Let’s Encrypt 免费SSL证书方法:自动安装与手动配置Nginx

    前几天介绍了最新StartSSL免费SSL申请与配置,很多人看到部落介绍SSL证书安装时总是推荐了OneinStack,因为OneinStack提供了一键添加和配置Let's Encrypt 免费SS ...

  4. 安装lnmp一键安装包(转)

    系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要3GB以上硬盘剩余空间 128M以上内存,Xen的需要有SWAP,OpenVZ的另外 ...

  5. 关于轻松安装LNMP和LAMP的编译环境

    http://lnmp.org/install.html 系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要2GB以上硬盘剩余空间 1 ...

  6. 细化如何安装LNMP + Zabbix 监控安装文档以及故障排除

    1.LNMP所需安装包: 上传如下软件包到/soft目录中 mysql- (centos6. 64位自带)也可根据版本自行挑选,前提你了解这个版本 pcre-8.36.tar.gz nginx-.ta ...

  7. 亚马逊AWS EC2云实例AMI安装LNMP环境(3)——Mysql5.5

    概括:这里选择亚马逊EC2的Linux AMI实例,该Linux服务器是亚马逊预配置的Linux环境,内置多个YUM源,属于亚马逊首推的稳定Linux服务器.默认登录用户名为ec2-user,执行ro ...

  8. 亚马逊AWS EC2云实例AMI安装LNMP环境(2)——PHP5.6

    概括:这里选择亚马逊EC2的Linux AMI实例,该Linux服务器是亚马逊预配置的Linux环境,内置多个YUM源,属于亚马逊首推的稳定Linux服务器.默认登录用户名为ec2-user,执行ro ...

  9. ubuntu 安装lnmp、swoole、redis

    1.安装lnmp (此处也可用于centos) 登陆服务器后  cd /var screen -S lnmp wget http://soft.vpser.net/lnmp/lnmp1.5.tar.g ...

随机推荐

  1. Android学习资料整理

    1.官方网站 http://developer.android.com/index.html http://android-developers.blogspot.com/ 2.Android Des ...

  2. js函数的使用

                           js函数应用   [函数的声明及调用]: 1.函数声明:    function 函数名(参数1,参数2,·····){    //函数体    retu ...

  3. Vue.js 实战总结

    最近在某个项目中用到了Vue.js,从上手做开发到项目发布,一步步踩了不少坑.本文试图总结过去一个多月使用Vue.js中的一些经验,也算是一点心得体会吧,拿出来与大家分享,欢迎多多交流. Vue.js ...

  4. Item 27: 明白什么时候选择重载,什么时候选择universal引用

    本文翻译自<effective modern C++>,由于水平有限,故无法保证翻译完全正确,欢迎指出错误.谢谢! 博客已经迁移到这里啦 Item 26已经解释了,不管是对全局函数还是成员 ...

  5. liunx命令2

    查看系统和bios硬件时间 [root@localhost ~]# date '+%y- %m- %d %H:%M' 17- 05- 15 02:57[root@localhost ~]# date ...

  6. 模板不存在:./xx 错误位置 FILE: LINE:110 (thinkphp上传至服务器后模板无法解析原因)

    thinkphp上传至服务器后模板无法解析原因 前几日做好的响应式静态页面上传至虚拟空间,打开网址地址出现: 模板不存在:./App/Admin/View/Config/customerService ...

  7. 在Eclipse如何实现在xml文件实现代码提示

    通常我们创建xml文件时, 总会在编辑代码的时候不能像编辑Java文件那样进行自动提示或者补全.其实这个是可以实现的,下面我就以struts2.xml进行示范: 1.点击"winbdows& ...

  8. java基础阅读卷1整理(待更新)

    JAVA语言的一些简单摘要,分为11点 1.简单性2.面相对象3.网络技能(Network-Savvy)4.健壮性5.安全性 6.体系结构中立7.可移植性8.解释型9.高性能10.多线程11.多态性 ...

  9. Selenium 高阶应用之WebDriverWait 和 expected_conditions

    Seleniium 是相当不错的一个第三方测试框架,可惜目前国内已经无法访问其官网(FQ可以). 不知道大家是否有认真查看过selenium 的api,我是有认真学习过的.selenium 的api中 ...

  10. 005---query接口初步

    Query session.createQuery(String hql)方法; * hibernate的session.createQuery()方法是使用HQL(hibernate的查询语句)语句 ...