自动安装lnmp
注:需先上传各安装包至服务器。 #!/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的更多相关文章
- 一个自动安装LNMP的简洁Shell脚本
此脚本在生产服务器上使用了一年多,本脚本崇尚简单唯美,只需要一个脚本就可以在任何一台有网络的服务器上自动配置LNMP.本脚本会在脚本执行目录下,建packages目录用于存放LNMP所需要的软件.大家 ...
- ansible批量自动安装LNMP
- LNMP安装Let’s Encrypt 免费SSL证书方法:自动安装与手动配置Nginx
前几天介绍了最新StartSSL免费SSL申请与配置,很多人看到部落介绍SSL证书安装时总是推荐了OneinStack,因为OneinStack提供了一键添加和配置Let's Encrypt 免费SS ...
- 安装lnmp一键安装包(转)
系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要3GB以上硬盘剩余空间 128M以上内存,Xen的需要有SWAP,OpenVZ的另外 ...
- 关于轻松安装LNMP和LAMP的编译环境
http://lnmp.org/install.html 系统需求: CentOS/RHEL/Fedora/Debian/Ubuntu/Raspbian Linux系统 需要2GB以上硬盘剩余空间 1 ...
- 细化如何安装LNMP + Zabbix 监控安装文档以及故障排除
1.LNMP所需安装包: 上传如下软件包到/soft目录中 mysql- (centos6. 64位自带)也可根据版本自行挑选,前提你了解这个版本 pcre-8.36.tar.gz nginx-.ta ...
- 亚马逊AWS EC2云实例AMI安装LNMP环境(3)——Mysql5.5
概括:这里选择亚马逊EC2的Linux AMI实例,该Linux服务器是亚马逊预配置的Linux环境,内置多个YUM源,属于亚马逊首推的稳定Linux服务器.默认登录用户名为ec2-user,执行ro ...
- 亚马逊AWS EC2云实例AMI安装LNMP环境(2)——PHP5.6
概括:这里选择亚马逊EC2的Linux AMI实例,该Linux服务器是亚马逊预配置的Linux环境,内置多个YUM源,属于亚马逊首推的稳定Linux服务器.默认登录用户名为ec2-user,执行ro ...
- ubuntu 安装lnmp、swoole、redis
1.安装lnmp (此处也可用于centos) 登陆服务器后 cd /var screen -S lnmp wget http://soft.vpser.net/lnmp/lnmp1.5.tar.g ...
随机推荐
- java I/O :RandomAccessFile
- HttpClient--HttpGet使用
最近公司在做一个爬虫工具,爬取公司现网的数据,留给方通项目使用 用到里阿帕奇的这两个类,在网上看到了一些资料结合自己的应用,这个贴出一个demo import com.alibaba.fastjson ...
- hdu1150 Machine Schedule 经典二分匹配题目
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1150 很经典的二分题目 就是求最小点覆盖集 二分图最小点覆盖集=最大匹配数 代码: #include& ...
- 如何在WebGL全景图上做标记
WebGL可以用来做3D效果的全景图呈现,例如故宫的全景图.但有时候我们不仅仅只是呈现全景图,还需要增加互动.故宫里边可以又分了很多区域,例如外朝中路.外朝西路.外朝东路等等.我们需要在3D图上做一些 ...
- 多人合作开发启动activity-----规范问题
A----FirstActivity button1.setOnClickListener(new OnClickListener() { @Override public void ...
- 开涛spring3(1) - Spring概述
1.1.1 Spring是什么 Spring是一个开源的轻量级Java SE(Java 标准版本)/Java EE(Java 企业版本)开发应用框架,其目的是用于简化企业级应用程序开发.应用程序是由 ...
- 连续分段累计器FPGA实现的探讨
- 写给Android App开发人员看的Android底层知识(7)
(十二)ContentProvider (1)ContentProvider是什么? ContentProvider,简称CP. 做App开发的同学,尤其是电商类App,对CP并不熟悉,对这个概念的最 ...
- .net开源权限管理系统
有业务请加QQ 245747009 源码地址:http://git.oschina.net/sunzewei/EIP 一.更新记录1.更新日期:2017-02-24 00:00:002.更新内容: 版 ...
- 从零开始理解JAVA事件处理机制(2)
第一节中的示例过于简单<从零开始理解JAVA事件处理机制(1)>,简单到让大家觉得这样的代码简直毫无用处.但是没办法,我们要继续写这毫无用处的代码,然后引出下一阶段真正有益的代码. 一:事 ...