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

#!/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. IOS中的绘图Quartz2D

    drawRect 方法的使用 常见图形的绘制:线条.多边形.圆 绘图状态的设置:文字颜色.线宽等 图形上下文状态的保存与恢复 图形上下文栈 Quartz 2D是一个二维绘图引擎,同时支持IOS和MAC ...

  2. C# 文件上传(可以多文件上传)

    一.前端搭建 1.前端用到js:uploadify(下载地址:http://www.uploadify.com/download/).layer (下载地址:http://layer.layui.co ...

  3. Oracle的instr函数

    instr函数 instr(目标字符串,被匹配的字符串,搜索的开始位置默认是1,第几次被搜索到) 例子1: SQL> select ename,instr(ename,'L',1,1) from ...

  4. 配置nginx脚本开机自启动

    vi /etc/init.d/nginx 插入以下内容,修改红色字体自己安装路径 #!/bin/bash## chkconfig: - 85 15# description: Nginx is a W ...

  5. win10下使用nodejs安装及webstorm创建express项目的指导

    title: win10下使用nodejs安装 win10下使用nodejs安装及webstorm创建express项目的指导 windows下nvm的安装 熟悉linux下nodejs开发的朋友应该 ...

  6. 对类对象使用new时地址分配的情况

    我们知道,string类内部的构造函数是采用new来分配地址的.当创建对象时,会调用string的构造函数,从而实质上也使用了new.那么问题来了,如果我用new再创建一个string类型的指针呢?下 ...

  7. JSP中include指令和include动作区别

    首先 <%@ include file=” ”%>:为指令元素 <jsp:include page=” ” flush=”true”/>:为 动作元素 先说指令元素: incl ...

  8. 关于STM32 IAP

    转眼间天亮了...... 然后就想起了一个朋友QQ的个性签名:年轻人总是要为一些自己认为有意义的事情而废寝忘食,通宵达旦,直至白发方休........ 对了这篇文章一定会介绍的很详细,请细嚼慢咽... ...

  9. 测试工具——JMeter

    本学期新学的课程,软件测试,上机的实验用到了C++Test,QTP,还有JMeter.今天针对JMeter做一次总结,方便以后用到,知道步骤会更加方便. 首先,对Jmeter进行一个大致的了解,包括对 ...

  10. 更换包管理工具npm为yarn

    官网:https://yarnpkg.com/zh-Hans/ 主要考虑: 1. npm管理安装模块依赖的版本不太方便,容易在删除node_modules重新install或在其他机器上新安装时, 安 ...