自动安装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 ...
随机推荐
- [原创]ssget过滤动态块的方式
Autocad在2006增加了新的动态块功能,方便了对块的动态修改,但是修改动态块后,块名会变成一个匿名块,导致无法通过块名来快速过滤. 明经论坛上有人通过全选块后再来遍历筛选,我通过研究简化了这个问 ...
- selenium 远程服务设置
第一步:将浏览器的安装地址以及浏览器的驱动地址添加到系统变量path中.浏览器只需要添加此浏览器exe文件所在的目录就可以,驱动需要添加完整的地址包括驱动本身XXX.exe. 第二步:需要安装jdk环 ...
- 解决jmeter乱码问题(改配置文件)
1.先改脚本里面的 content encoding为utf-8 然后response为utf-8 2.如果以上还是不可以,那就改配置文件jmeter.properties,里面的sampleresu ...
- [刷题]算法竞赛入门经典(第2版) 5-13/UVa822 - Queue and A
题意:模拟客服MM,一共有N种话题,每个客服MM支持处理其中的i个(i < N),处理的话题还有优先级.为了简化流程方便出题,设每个话题都是每隔m分钟来咨询一次.现知道每个话题前来咨询的时间.间 ...
- [刷题]算法竞赛入门经典(第2版) 4-6/UVa508 - Morse Mismatches
书上具体所有题目:http://pan.baidu.com/s/1hssH0KO 代码:(Accepted,10 ms) //UVa508 - Morse Mismatches #include< ...
- XSHELL工具上传文件到Linux以及下载文件到本地(Windows)
Xshell很好用,然后有时候想在windows和linux上传或下载某个文件,其实有个很简单的方法就是rz,sz.首先你的Linux上需要安装安装lrzsz工具包,(如果没有安装请执行以下命令,安装 ...
- 【Java SE】利用Java的for循环加random制作小学试卷
前期介绍:很多同学以为学习一门编程语言,一定要学到很高深的时候才可以做项目,其实不然,很多时候我们不需要学到面向对象的思想,就可以从事一些小项目的开发,来增加自己对开发的热情,比如现在我就可以利用Ja ...
- sublime Text3 新建文件时定义模块
开发的过程中有很多的东西,不需要每次编写,如果每次编写这样会很蛋疼,所以sublime 提供了一个牛逼的插件SublimeTmpl, 这个插件可以定义自己新建的模块. sublimeTmpl 安装 1 ...
- C#设置richtextbox某一段文本颜色
假设 RichTextBox1 文本是"你好,我爱你中国",想要把中国变为红色,则 可以先找到中的位置是 7 :国的位置是8 设置 RichTextBox1.SelectionSt ...
- 一次基于Vue.Js用户体验的优化
.mytitle { background: #2B6695; color: white; font-family: "微软雅黑", "宋体", "黑 ...