• lnmp环境脚本自动配置


    #!/usr/bin/env bash
    echo "=============START====================="
    cd /home/
    echo '[yum] 安装epel-release第三方软件包'
    yum install epel-release -y
    #安装php5.6.31
    rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
    echo '[PHP] yum install php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-fpm php-redis php-gd'
    yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-fpm php-redis php-gd
    # 设置PHP 默认时区
    echo '[php]change php.ini date.timezone'
    sed -i 's/^;date.timezone =/date.timezone = "Asia/Shanghai"/' /etc/php.ini
    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
    
    
    
    # 安装mysql5.7
    echo '[msyql]install mysql mysql5.7-server'
    wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
    yum localinstall mysql57-community-release-el7-8.noarch.rpm -y
    yum install mysql-community-server -y
    
    # 安装 redis 
    yum install redis -y
    
    # 安装 ningx
    echo '[nginx]install nginx'
    yum install nginx -y
    
    echo 'mkdir /home/wwwroot/'
    mkdir -p /home/wwwroot/logs
    mkdir /home/wwwroot/default_site
    touch /home/wwwroot/default_site/index.php
    echo '<?php phpinfo();' > /home/wwwroot/default_site/index.php
    #mv /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.bak
    
    echo "[nginx] SET DOMAIN(ignore www,like baidu.com):--------------->"
    
    read DOMAIN
    confile="/etc/nginx/conf.d/${DOMAIN}.conf"
    touch $confiles
    
    echo '
    server {
      listen 80;
      charset utf-8;
    ' > $confile
    
    echo "
      server_name _ ${DOMAIN} www.${DOMAIN};
      root /home/wwwroot/${DOMAIN}/;
      access_log /home/wwwroot/logs/${DOMAIN}_access.log main;
      error_log /home/wwwroot/logs/${DOMAIN}_error.log;
    " >> $confile
    
    echo '
      location /{
        index index.php index.html index.htm;
        if (!-e $request_filename){
          rewrite ^/(.*)$ /index.php/$1 last;
        }
        # Must www
        # if ($http_host !~ "^www.domain.com$") {
       # rewrite ^(.*) http://www.domain.com$1 permanent;
        # }
      }
    
      location ~ ^.+.php{
        fastcgi_buffer_size 128k;
        fastcgi_buffers 32 32k;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_split_path_info ^((?U).+.php)(/?.+)$;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
        fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
        include fastcgi_params;
      }
    
      #error_page 404 /404.html;
      error_page 500 502 503 504 /50x.html;
      location = /50x.html {
        root /usr/share/nginx/html;
      }
    
      # deny ci
     location ^~ /views|controllers|config {
      deny all;
     }
    
     # deny .ht
     location ~ /.ht {
      deny all;
     }
    
      # deny .git
      location ~ /.git {
        deny all;
      }
    
      # location ~* ^.+.(ico|gif|jpg|jpeg|png|html|htm|css|js|txt|xml|swf|wav)$ {
      # # root /home/http/object/static;
      # access_log off;
      # expires 30d;
      # }
    }
    ' >> $confile
    
    echo '[php]start php-fpm'
    systemctl start php-fpm.service
    systemctl enable php-fpm.service
    
    echo '[nginx]start nginx'
    systemctl start nginx.service
    systemctl enable nginx.service
    
    echo '[mysql]start mysql'
    systemctl start mysqld.service
    systemctl enable mysqld.service
    
    echo '[redis]start redis'
    systemctl start redis.service
    systemctl enable redis.service
    
    echo '======================END=========================='
    echo '[end]open the IP site,read phpinfo '
    echo 'web: /home/wwwroot/'
    echo 'nginx: /etc/nginx/conf.d/'
    echo 'php: /etc/php.init /etc/php-fpm.d/www.conf'
    echo 'mysql: /etc/my.ini'
    # 查看mysql5.7初始密码 grep 'temporary password' /var/log/mysqld.log 
    # 登入后第一步修改密码 alter user root@localhost identified by 'Taozhuzhu!@#123';
  • 相关阅读:
    纯前端导出Excel表格
    vue 组件按需引用,vue-router懒加载,vue打包优化,加载动画
    解决图片循环展示间距
    微信小程序aes前后端加密解密交互
    判断字符串中是否包含表情
    银行卡号Luhn校验算法
    身份证校验(支持15位和18位身份证号)、邮箱校验正则
    数组去重
    bootstrap 中 css 与 javascript 的使用
    js 分页
  • 原文地址:https://www.cnblogs.com/mmmzh/p/10077831.html
Copyright © 2020-2023  润新知