关键词:
分享一个自己写的一键安装LNMP的脚本。
CentOS6安装效果:
#!/bin/bash # Author: Zhangbin # Website: http://qicheng0211.blog.51cto.com/ # Description: CentOS6/7一键安装lnmp(基于yum) PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin export PATH err_echo() { echo -e "e[31m[ Error ] 33[0m [email protected]" exit 1 } info_echo() { echo -e "e[32m[ Info ] 33[0m [email protected]" sleep 1 } # 检查是否root用户 if [ $EUID -ne 0 ]; then err_echo "please run this script as root user." fi # 检查操作系统版本 if egrep "CentOS release 6" /etc/redhat-release > /dev/null 2>&1; then OS=CentOS6 elif egrep "CentOS Linux release 7" /etc/redhat-release > /dev/null 2>&1; then OS=CentOS7 else err_echo "This script is used for CentOS 6.x or 7.x only." fi # 检查网络 ping -c 1 mirrors.163.com &>/dev/null [ $? != 0 ] && err_echo "Network does not work." which wget &>/dev/null || yum install wget -y # CentOS6安装yum的axel插件,使yum支持多线程下载: if [ "$OS" == "CentOS6" ];then wget https://mirrors.tuna.tsinghua.edu.cn/repoforge/redhat/el6/en/x86_64/rpmforge/RPMS/axel-2.4-1.el6.rf.x86_64.rpm rpm -ivh axel-2.4-1.el6.rf.x86_64.rpm axelget_conf_start=$(grep -n ‘axelget.conf start_line‘ "$0" | grep -v grep | awk -F: ‘{print $1}‘) axelget_conf_end=$(grep -n ‘axelget.conf end_line‘ "$0" | grep -v grep | awk -F: ‘{print $1}‘) ((axelget_conf_start++)) ((axelget_conf_end--)) sed -n "${axelget_conf_start},${axelget_conf_end}p" "$0" > /etc/yum/pluginconf.d/axelget.conf axelget_py_start=$(grep -n ‘axelget.py start_line‘ "$0" | grep -v grep | awk -F: ‘{print $1}‘) axelget_py_end=$(grep -n ‘axelget.py end_line‘ "$0" | grep -v grep | awk -F: ‘{print $1}‘) ((axelget_py_start++)) ((axelget_py_end--)) sed -n "${axelget_py_start},${axelget_py_end}p" "$0" > /usr/lib/yum-plugins/axelget.py fi # 安装163 yum源: if [ "$OS" == "CentOS6" ];then wget http://mirrors.163.com/.help/CentOS6-Base-163.repo -O CentOS-Base.repo else wget http://mirrors.163.com/.help/CentOS7-Base-163.repo -O CentOS-Base.repo fi cp -p /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak mv -f CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo yum clean all yum makecache # 安装epel yum源: yum -y install epel-release sed -i ‘s/^mirrorlist=https/mirrorlist=http/‘ /etc/yum.repos.d/epel.repo # CentOS7安装yum的axel插件,依赖epel源 if [ "$OS" == "CentOS7" ];then yum -y install yum-axelget sed -i ‘/^maxconn=/cmaxconn=10‘ /etc/yum/pluginconf.d/axelget.conf fi # nginx的yum源: cat > /etc/yum.repos.d/nginx.repo << ‘EOF‘ [nginx] name=nginx repo baseurl=http://nginx.org/packages/centos/$releasever/$basearch/ enabled=1 gpgcheck=0 EOF # 关闭selinux: setenforce 0 sed -i ‘/^SELINUX=/cSELINUX=disabled‘ /etc/selinux/config # 安装nginx、php: yum -y install nginx php-fpm php-soap php-bcmath php-xml php-opcache php-gd php-mcrypt php-pdo php-mysql php-mbstring php-xmlrpc # 修改/etc/nginx/nginx.conf cp /etc/nginx/nginx.conf /etc/nginx/nginx.conf.bak cat > /etc/nginx/nginx.conf << ‘EOF‘ user nginx; worker_processes auto; error_log /data/logs/nginx_error.log crit; worker_rlimit_nofile 65535; events { use epoll; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 8m; sendfile on; tcp_nopush on; keepalive_timeout 15; tcp_nodelay on; proxy_buffer_size 16k; proxy_buffering on; proxy_buffers 4 64k; proxy_busy_buffers_size 128k; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 128k; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; gzip_disable msie6; log_format access ‘$remote_addr - $remote_user [$time_local] "$request" ‘ ‘$status $body_bytes_sent "$http_referer" ‘ ‘"$http_user_agent" $http_x_forwarded_for ‘; access_log /data/logs/access.log access; include conf.d/*.conf; server_tokens off; reset_timedout_connection on; } EOF mkdir -p /data/logs chown -R nginx. /data/logs sed -i ‘s/^user = apache/user = nginx/‘ /etc/php-fpm.d/www.conf sed -i ‘s/^group = apache/group = nginx/‘ /etc/php-fpm.d/www.conf chown -R nginx /var/log/php-fpm/ # 启动php-fpm: service php-fpm start [ $? -eq 0 ] && info_echo "php-fpm start OK." # 启动nginx: nginx -t && service nginx start [ $? -eq 0 ] && info_echo "nginx start OK." # 设置nginx、php-fpm开机启动: if [ "$OS" == "CentOS6" ];then chkconfig php-fpm on chkconfig nginx on else systemctl enable php-fpm systemctl enable nginx fi # 安装Mysql的yum源: if [ "$OS" == "CentOS6" ];then rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm else rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm fi # 安装mysql: yum -y install mysql mysql-server mysql-devel # 修改/etc/my.cnf cat > /etc/my.cnf << ‘EOF‘ # Example MySQL config file. mysql5.6 RAM 1G zhangbin [client] port = 3306 socket = /var/lib/mysql/mysql.sock [mysqld] user = mysql port = 3306 datadir = /var/lib/mysql/ socket = /var/lib/mysql/mysql.sock sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER bind-address = 0.0.0.0 server-id = 1 skip-name-resolve skip-external-locking back_log = 600 max_connections = 512 max_connect_errors = 6000 open_files_limit = 65535 table_open_cache = 512 max_allowed_packet = 4M max_heap_table_size = 8M tmp_table_size = 16M read_buffer_size = 2M read_rnd_buffer_size = 8M sort_buffer_size = 8M join_buffer_size = 8M thread_cache_size = 8 query_cache_size = 2M query_cache_limit = 2M key_buffer_size = 64M interactive_timeout = 28800 wait_timeout = 28800 # myisam bulk_insert_buffer_size = 8M myisam_sort_buffer_size = 8M myisam_max_sort_file_size = 10G myisam_repair_threads = 1 # bin log log_bin = /var/lib/mysql/mysql-bin.log binlog_cache_size = 2M binlog_format = MIXED expire_logs_days = 7 # slow log slow_query_log = 1 slow_query_log_file = /var/lib/mysql/mysql-slow.log long_query_time = 3 log_queries_not_using_indexes = 1 # innodb default-storage-engine = InnoDB innodb_data_home_dir = /var/lib/mysql/ innodb_data_file_path = ibdata1:10M:autoextend innodb_log_group_home_dir = /var/lib/mysql/ innodb_buffer_pool_size = 512M innodb_log_file_size = 128M innodb_log_files_in_group=3 innodb_log_buffer_size = 8M innodb_flush_log_at_trx_commit = 2 innodb_lock_wait_timeout = 120 innodb_file_per_table = 1 innodb_open_files = 500 innodb_read_io_threads = 4 innodb_write_io_threads = 4 innodb_thread_concurrency=0 innodb_purge_threads = 1 innodb_max_dirty_pages_pct = 90 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [myisamchk] key_buffer = 20M sort_buffer_size = 20M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeout EOF # 启动mysql: service mysqld start [ $? -eq 0 ] && info_echo "mysqld start OK." # 安全设置: #mysql_secure_installation # 设置mysqld开机启动: if [ "$OS" == "CentOS6" ];then chkconfig mysqld on else systemctl enable mysqld fi exit 0 # axelget.conf start_line [main] enabled=1 onlyhttp=1 enablesize=54000 cleanOnException=1 # axelget.conf end_line # axelget.py start_line from yum.plugins import PluginYumExit, TYPE_CORE, TYPE_INTERACTIVE from urlparse import urljoin import os,time requires_api_version = ‘2.3‘ plugin_type = (TYPE_CORE, TYPE_INTERACTIVE) enablesize=300000 trymirrornum=-1 maxconn=10 httpdownloadonly=False cleanOnException=0 def init_hook(conduit): global enablesize,trymirrornum,maxconn,cleanOnException,httpdownloadonly enablesize = conduit.confInt(‘main‘,‘enablesize‘,default=30000) trymirrornum = conduit.confInt(‘main‘,‘trymirrornum‘,default=-1) maxconn = conduit.confInt(‘main‘,‘maxconn‘,default=10) httpdownloadonly=conduit.confBool(‘main‘,‘onlyhttp‘,default=False) cleanOnException=conduit.confInt(‘main‘,‘cleanOnException‘,default=0) return def predownload_hook(conduit): global enablesize,cleanOnException,httpdownloadonly preffermirror="" PkgIdx=0 TotalPkg=len(conduit.getDownloadPackages()) for po in (conduit.getDownloadPackages()): PkgIdx+=1 if hasattr(po, ‘pkgtype‘) and po.pkgtype == ‘local‘: continue totsize = long(po.size) ret = False if totsize <= enablesize: conduit.info(2, "Package %s download size %d less than %d,Skip plugin!" % (po.repo.id,totsize,enablesize)) continue else: conduit.info(2, "[%d/%d]Ok,we will try to use axel to download this big file:%d" % (PkgIdx,TotalPkg,totsize)) local = po.localPkg() if os.path.exists(local): if not os.path.exists(local+".st"): fstate=os.stat(local) if totsize == fstate.st_size: conduit.info(2,"Target already exists,skip to next file!") continue localall = "%s %s" % (local,local+".st") rmcmd = "rm -f %s" % (localall) curmirroridx = 0 conduit.info(2,"Before we start,clean all the key files") os.system(rmcmd) connnum = totsize / enablesize if connnum*enablesize<totsize: connnum+=1 if connnum > maxconn: connnum = maxconn mirrors=[] mirrors[:0]=po.repo.urls if preffermirror != "": mirrors[:0] = [preffermirror] for url in mirrors: if url.startswith("ftp://") and httpdownloadonly: print "Skip Ftp Site:",url continue if url.startswith("file://"): print "Skip Local Site:",url continue curmirroridx += 1 if (curmirroridx > trymirrornum) and (trymirrornum != -1): conduit.info(2, "Package %s has tried %d mirrors,Skip plugin!" % (po.repo.id,trymirrornum)) break remoteurl = "%s/%s" % (url,po.remote_path) syscmd = "axel -a -n %s %s -o %s" % (connnum,remoteurl,local) conduit.info(2, "Execute axel cmd: %s" % syscmd) os.system(syscmd) time.sleep(2) if os.path.exists(local+".st"): conduit.info(2,"axel exit by exception,let‘s try another mirror") if cleanOnException: conduit.info(2,"because cleanOnException is set to 1,we do remove key file first") os.system(rmcmd) continue elif not os.path.exists(local):#this mirror may not update yet continue else: ret = True preffermirror=url break if not ret: conduit.info (2,"try to run rm cmd:%s" % rmcmd) os.system(rmcmd) # axelget.py end_line
本文出自 “启程的Linux博客” 博客,请务必保留此出处http://qicheng0211.blog.51cto.com/3958621/1945917
lnmp一键安装脚本
入职新公司的第一天,带我的哥们就分配给我一个任务,让我装一个lnmp,并且写成脚本,这不是soeasy吗,于是我马上就开搞了,现在把我的脚本分享一下给大家。#lnmp安装脚本#Email:[email protected]#autor:fujinzhou#create&... 查看详情
脚本一键源码编译安装lnmp
script]#catLNMP.sh#!/bin/bashecho"Compileenvironmentinstallation"source$1envinstall(){ cd/opt echo"--------CompileenvironmentinstallStarting--------" yum-y 查看详情
centos7下安装lnmp一键安装包
...法使用yum安装,把这个问题解决后,就开始安装环境lnmp一键安装包,建议新手还是选择lnmp一键安装包吧,至于为什么?大家都懂,省心省事省时间没毛病!首先输入命令检查一下是否已安装screen-Slnmp如果提示screen:commandnotfound命... 查看详情
lnmp一键安装包
介绍与使用更多内容请到乌龟运维wuguiyunwei.com请保证在系统原有yum源文件存在的情况下运行此脚本以下以centos7.3为例:650)this.width=650;"class="alignnonesize-fullwp-image-444"src="http://wuguiyunwei.com/wp-content/uploads/2017/05/1116.png"width="1 查看详情
一键安装lnmp脚本
前段时间一直在找一个快速部署lnmp环境的方法,也没找着,就自己写了一个,结合网上的大神们的。我的方法是脚本结合源码包,很多依赖裤都是yum安装的,这都在脚本里面,需要的源码包我都下载好了,打包成压缩包,源码... 查看详情
lnmp+zabbix一键部署脚本
...续编译失败等问题,该脚本经过个人轮番测试基本上可以一键搞定zabbix的部署工作,目前只是整个Server端的脚本,后续将编写Agent端自动推送的脚本二、脚本用法介绍脚本使用-h参数可以看到该脚本支持传递以下3个参数,该参数... 查看详情
lnmp
环境centos6.7 64位#软件版本nginx-1.6.3+php-5.5.32+mysql-5.5.49#安装依耐包yum install openssl openssl-devel pcre pcre-devel -ywget -q http://nginx.org/download/ng 查看详情
yum一键安装企业级lamp服务环境-技术流ken(代码片段)
1.简介LAMP 是LinuxApacheMySQLPHP的简写,其实就是把Apache,MySQL以及PHP安装在Linux系统上,组成一个环境来运行动态的脚本文件。2.系统环境centos6.7服务器IP:10.220.5.166/243.关闭安全服务[[email protected]~]#serviceiptablesstop[[email protected 查看详情
lnmp一键安装包版本服务任你选
介绍与使用请保证在系统原有yum源文件存在的情况下运行此脚本以下以centos7.3为例:650)this.width=650;"src="https://s1.51cto.com/wyfs02/M01/97/79/wKiom1kuqr7ia0SeAAA-GOS7KLU187.png"title="1116.png"alt="wKiom1kuqr7ia0SeAAA-GOS7KLU187.png"/ 查看详情
gitlab的一键安装方式
一、安装环境的介绍Centos6.7 x86_64 2.6.32-573.el6.x86_64 IP:192.168.159.129 #公司内部测试服务器GitLab版本:9.1.2软件包下载地址:https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/二、安装过程#rpm -ivh 查看详情
centos6/7中通过yum安装软件时提示cannotfindavalidbaseurl...的解决方法(代码片段)
目录1问题描述2解决方法一(CentOS7中有效)3解决方法二(CentOS7中无效)1问题描述新申请了虚拟机,系统版本是CentOS7.2.在安装软件的过程中,发现yum命令不能连接到远程仓库,出现如下提示:[[email protected]~]#yuminstall-yvim[[email protected... 查看详情
centos6.7安装gitlab
1建议安装epel源2建议从国内清华大学yum源安装repo文件:[gitlab-ce]name=gitlab-cebaseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/repo_gpgcheck=0gpgcheck=0enabled=1gpgkey=https://packages.gitlab.com/gpg.key3安装 查看详情
实现基于lnmp的电子商务网站的搭建
一环境准备:centos系统 yum源(安装mysql,nginx,和php-fpm)二:安装步骤:用yum的方式安装mariadb,mariadb-server,php-mysql,php-fpm,nginx下载需要搭建网站的源码,我搭建的是基于小米网站的搭建,然后解压缩到data/web目录650)this.width=650;"src... 查看详情
centos6.7搭建lnmp环境
1:查看环境:1[[email protected]~]#cat/etc/redhat-release2:关掉防火墙1#重启后生效开启2[[email protected]~]#chkconfigiptablesoff34or56#即时生效,重启后失效开启7[[email protected]~]#serviceiptablesstop关闭selinux#即时生效,重 查看详情
lnmp一键安装的卸载
如果是lnmp一键安装的进入安装包目录[[email protected]home]#cdlnmp0.9-full[[email protected]lnmp0.9-full]#ls然后[[email protected]lnmp0.9-full]#./uninstall.sh============================================== 查看详情
使用yum安装lnmp步骤
使用yum安装LNMP步骤使用yum安装LNMP步骤输入命令cat/etc/redhat-release,查看当前Linux系统版本#cat/etc/redhat-releaseCentOSrelease6.5(Final)关闭防火墙自启动#/etc/init.d/iptablesstop#chkconfigiptablesoff在部署LNMP环境之前,首先,用户需要安装Nignx服务... 查看详情
一键安装lnmp途径2
https://lnmp.org/ 查看详情
lnmp一键安装的卸载
http://blog.csdn.net/lansetiankong12/article/details/48130507 如果是lnmp一键安装的进入安装包目录[[email protected]home]#cdlnmp0.9-full[[email protected]lnmp0.9-full]#ls然后[[email protected]lnmp0.9 查看详情