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

#!/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. .net 程序集

    前言:用了几天的时间把高级编程里面程序集一章看完了,原来自己只知道写代码,右键添加引用,从来也不知道操作的实质是什么,微软总是这个套路,鼠标点点就能把任务完成,这对新手友好但是对要通透了解程序执行和内 ...

  2. vlan内部与外部某终端之间的通信

    实现虚拟局域网外部终端与内部终端之间的通信,即实现pc3与pc1和pc4之间的通信. 把交换机上的默认VLAN1改成VLAN2(红色字体命令). 各vlan内部终端的通信,是通过vlan ID来实现的 ...

  3. 学习笔记:javascript 表单对象(form)

    Form 对象属性 属性 描述 acceptCharset 服务器可接受的字符集. action 设置或返回表单的 action 属性. enctype 设置或返回表单用来编码内容的 MIME 类型. ...

  4. [笔记]scanf的使用(主要是针对char)

    学的是C++,用cin cout也用的很顺溜,写自己的类时重载"<<"与">>"运算符也很爽,但是发现在刷算法竞赛题时,cin cout ...

  5. windows下Python 3.x图形图像处理库PIL的安装

    图像处理是一门应用非常广的技术,而拥有非常丰富第三方扩展库的 Python 当然不会错过这一门盛宴.PIL (Python Imaging Library)是 Python 中最常用的图像处理库,目前 ...

  6. Servlet 详解

    1.什么是 Servlet? Java Servlet 是运行在 Web 服务器或应用服务器上的程序,它是作为来自 Web 浏览器或其他 HTTP 客户端的请求和 HTTP 服务器上的数据库或应用程序 ...

  7. Libevent源码分析—event_init()

    下面开始看初始化event_base结构的相关函数.相关源码位于event.c event_init() 首先调用event_init()初始化event_base结构体 struct event_b ...

  8. Oracle listener服务启动后又停止的解决方案

    这是Oracle监听服务.忘了说我的版本是Oracle10g. 我装完Oracle数据库之后,然后用第三方工具plsql去连接,提示no listener,首先我反复检查tnsnames.ora配置文 ...

  9. centos rabbitmq 安装

    MQ 的一个产品[消息队列] rabbitmq 的本质<1>rabbitmq 是用什么语言编写的? => erlang<2>rabbitmq 其实是遵循amqp 协议的一 ...

  10. 初识Java-IO流

    1.定义: 流是一种抽象概念,它代表了数据的无结构化传递.数据流(Stream)是指数据通信的通道. 2.流的分类: 1)按流向分 输入流:从数据源到程序中的流 输出流:从程序到数据源的流 2)按数据 ...