yum lnmp全家桶
1 ######################################################### 2 #by:kingle # 3 #use: lnmp # 4 #version:1.0 # 5 ######################################################### 6 #!/bin/sh 7 [ -f /etc/init/functions ] && source /etc/init/functions 8 echo ' 9 1) 安装lnmp 10 2) 退出 11 ' 12 read -p "please 1 to 2: " n 13 yum install -y epel-release 14 rpm --import mysql_pubkey.asc 15 rpm -Uvh http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm 16 rpm --import http://rpms.remirepo.net/RPM-GPG-KEY-remi 17 rpm -Uvh http://remi.mirrors.arminco.com/enterprise/remi-release-7.rpm 18 rpm --import http://nginx.org/packages/keys/nginx_signing.key 19 rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm 20 sed -i "/remi\/mirror/{n;s/enabled=0/enabled=1/g}" /etc/yum.repos.d/remi.repo 21 sed -i "/test\/mirror/{n;n;s/enabled=0/enabled=1/g}" /etc/yum.repos.d/remi.repo 22 sed -i "/php70\/mirror/{n;s/enabled=0/enabled=1/g}" /etc/yum.repos.d/remi-php70.repo 23 yum clean all 24 yum makecache 25 function yuminstall(){ 26 yum install -y mysql-community-server nginx php php-bcmath php-fpm php-gd php-json php-mbstring php-mcrypt php-mysqlnd php-opcache php-pdo php-pdo_dblib php-pgsql php-recode php-snmp php-soap php-xml php-pecl-zip phpMyAdmin 27 28 } 29 function mysql(){ 30 ystemctl start mysqld.service 31 mysql_secure_installation && expect mysql.exp 32 } 33 function php(){ 34 cat >>/etc/php.ini<<EOF 35 #更换监听方式 36 listen = /dev/shm/php-fpm-default.sock 37 #监听队列最大长度为不限 38 listen.backlog = -1 39 #指定监听用户和用户组(需存在) 40 listen.owner = www 41 listen.group = www 42 EOF 43 systemctl start php-fpm.service 44 } 45 function nginx(){ 46 #新建名为 nginx-default.conf 的配置文件 47 touch /etc/nginx/conf.d/nginx-default.conf 48 cat >>/etc/nginx/conf.d/nginx-default.conf<<EOF 49 server 50 { 51 listen 80 default; 52 return 400; 53 } 54 server 55 { 56 listen 80; 57 #监听80端口 58 server_name default.com www.default.com; 59 #绑定域名 default.com 和 www.default.com 60 index index.html index.htm index.php; 61 #设置首页文件,越前优先级越高 62 charset utf-8; 63 #设置网页编码 64 65 root /home/wwwroot/default; 66 #设置站点根目录 67 68 #运行 PHP 69 location ~ .*\.php$ 70 { 71 fastcgi_pass 127.0.0.1:9000 72 #默认使用9000端口和PHP通信 73 #fastcgi_pass unix:/dev/shm/php-fpm-default.sock; 74 #使用 unix sock 和PHP通信 75 fastcgi_index index.php; 76 fastcgi_param DOCUMENT_ROOT /home/wwwroot/default; 77 #PHP 文档根目录 78 fastcgi_param SCRIPT_FILENAME /home/wwwroot/default$fastcgi_script_name; 79 #PHP 脚本目录 80 include fastcgi_params; 81 try_files $uri = 404; 82 } 83 84 #设置文件过期时间 85 location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma)$ 86 { 87 expires 30d; 88 } 89 90 #设置文件过期时间 91 location ~ .*\.(js|css)$ 92 { 93 expires 12h; 94 } 95 96 #设置文件访问权限 97 location ~* /templates(/.*)\.(bak|html|htm|ini|old|php|tpl)$ { 98 allow 127.0.0.1; 99 deny all; 100 } 101 102 #设置文件访问权限 103 location ~* \.(ftpquota|htaccess|htpasswd|asp|aspx|jsp|asa|mdb)?$ { 104 deny all; 105 } 106 107 #保存日志 108 access_log /var/log/nginx/default-access.log main; 109 error_log /var/log/nginx/default-error.log crit; 110 } 111 EOF 112 #防火墙放行 HTTP 端口访问 113 firewall-cmd --permanent --zone=public --add-service=http 114 firewall-cmd --reload 115 #启动nginx 116 systemctl start nginx.service 117 118 } 119 function phpmyadmin(){ 120 cat >>etc/phpMyAdmin/config.inc.php<<EOF 121 $cfg['Servers'][$i]['host'] = 'localhost'; 122 $cfg['Servers'][$i]['port'] = '3306'; 123 $cfg['Servers'][$i]['socket'] = '/var/lib/mysql/mysql.sock'; 124 $cfg['Servers'][$i]['connect_type'] = 'socket'; 125 $cfg['Servers'][$i]['extension'] = 'mysqli'; 126 $cfg['Servers'][$i]['auth_type'] = 'cookie'; 127 $cfg['UploadDir'] = '/tmp'; 128 $cfg['SaveDir'] = '/tmp'; 129 EOF 130 #复制 phpMyAdmin 目录 131 cp -a /usr/share/phpMyAdmin /home/wwwroot/default/ 132 133 #替换连接形式为目录 134 rm -rf /home/wwwroot/default/phpMyAdmin/doc/html 135 cp -a /usr/share/doc/phpMyAdmin-4.8.2/html/ /home/wwwroot/default/phpMyAdmin/doc/ 136 } 137 case $n in 138 1) 139 yuminstall 140 nginx 141 php 142 phpmyadmin 143 mysql 144 exit 145 ;; 146 2) 147 exit 0 148 ;; 149 *) 150 echo "please input 1 or 2" 151 exit 1 152 ;; 153 esac
1 #!/usr/bin/expect 2 set password "123456" 3 expect { 4 "[Y/n]" {send "Y\r;exp_continue"} 5 "(enter for none)" {send "\r;exp_continue"} 6 } 7 expect eof 8
yum 源各位换下 ,,,我用了不怎么好用
人生就像一滴水,非要落下才后悔!
--kingle