zoukankan      html  css  js  c++  java
  • 第十三周作业

    10.0.0.71服务器一键安装脚本

    #!/bin/bash
    
    SRC1=https://mirror.csclub.uwaterloo.ca/apache//httpd/httpd-2.4.46.tar.bz2
    SRC2=https://mirrors.bfsu.edu.cn/apache//apr/apr-1.7.0.tar.bz2
    SRC3=https://mirrors.bfsu.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2
    
    PKG1=`echo $SRC1 | awk -F'/' '{print $NF}'` 
    PKG2=`echo $SRC2 | awk -F'/' '{print $NF}'`
    PKG3=`echo $SRC3 | awk -F'/' '{print $NF}'` 
    
    DIR1=`echo $PKG1 | sed -nr 's/(.*).tar.*/1/p'` 
    DIR2=`echo $PKG2 | sed -nr 's/(.*).tar.*/1/p'` 
    DIR3=`echo $PKG3 | sed -nr 's/(.*).tar.*/1/p'` 
    
    DIR=/apps/httpd
    SRVS=`echo $DIR | awk -F'/' '{print $NF}'` 
    
    
    #安装httpd服务
    
    
    #安装依赖并下载相关文件解压至特定目录
    yum -y install wget lbzip2 gcc make prce-devel openssl-devel expat-devel
    wget $SRC1 
    wget $SRC2
    wget $SRC3
    tar vxf $PKG1
    tar vxf $PKG2
    tar vxf $PKG3
    mv $DIR2 $DIR1/srclib/apr
    mv $DIR3 $DIR1/srclib/apr-util
    
    
    #编译安装httpd
    cd $DIR1
    ./configure --prefix=$DIR --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-included-apr --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork
    make && make install
    
    
    #创建apache用户并更改配置文件
    cd ~
    useradd -s /sbin/nologin -r apache
    sed -i 's/^User.*/User apache/' $DIR/conf/httpd.conf
    sed -i 's/^Group.*/Group apache/' $DIR/conf/httpd.conf
    
    #配置环境变量和添加man帮助
    ln -s $DIR/bin/* /usr/bin
    echo "MANDATORY_MANPATH                       $DIR/man" >> /etc/man_db.conf
    
    #设置开机自启
    echo "$DIR/bin/apachectl start" >> /etc/rc.d/rc.local
    chmod +x /etc/rc.d/rc.local
    
    
    #创建启动脚本文件
    cat > /usr/lib/systemd/system/$SRVS.service << EOF
    [Unit]
    Description=The Apache HTTP Server
    After=network.target remote-fs.target nss-lookup.target
    Documentation=man:httpd(8)
    Documentation=man:apachectl(8)
    [Service]
    Type=forking
    ExecStart=$DIR/bin/apachectl start
    EXecReload=$DIR/bin/apachectl graceful
    ExecStop=$DIR/bin/apachectl stop
    KillSignal=SIGCONT
    PrivateTmp=true
    [install]
    WantedBy=multi-user.target
    EOF
    
    #启动服务
    systemctl daemon-reload
    systemctl enable --now $SRVS
    
    
    #编译安装php7.3
    
    SRC4=https://www.php.net/distributions/php-7.3.24.tar.xz
    PKG4=`echo $SRC4 | awk -F'/' '{print $NF}'`
    DIR4=`echo $PKG4 | sed -nr 's/(.*).tar.*/1/'`
    NAME=/apps/php
    
    yum -y install  libxml2-devel bzip-devel libmcrypt-devel
    wget $SRC4
    tar vxf $PKG4
    cd $DIR4
    ./configure --prefix=$NAME --enable-mysqlnd --with-mysqli=mysqlnd --with-openssl --with-pdo-mysql=mysqlnd --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --enable-sockets --with-apxs2=$DIR/bin/apxs --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --enable-maintainer-zts --disable-fileinfo
    make && make install
    cp php.ini-production /etc/php.ini
    
    #修改配置文件并重启httpd服务
    cd ~
    cat >> $DIR/conf/httpd.conf <<EOF
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps
    EOF
    sed -Ei '/index.html/s/(.*) index.html/1 index.php index.html/' $DIR/conf/httpd.conf
    apachectl restart
    
    
    #部署wordpress
    SRC5=https://wordpress.org/wordpress-5.3.2.tar.gz
    PKG5=`echo $SRC5 | awk -F'/' '{print $NF}'`
    
    wget $SRC5
    tar  vxf $PKG5
    mv wordpress $DIR/htdocs
    chown -R apache.apache $DIR/htdocs/wordpress/
    

    10.0.0.81服务器安装mariadb脚本

    #!/bin/bash
    DIR="/data/mysql"
    NAME="/usr/local/mysql"
    URL="https://mirrors.tuna.tsinghua.edu.cn/mariadb//mariadb-10.5.5/bintar-linux-systemd-x86_64/mariadb-10.5.5-linux-systemd-x86_64.tar.gz
    "
    PACK="mariadb-10.5.5-linux-systemd-x86_64.tar.gz"
    FILE="mariadb-10.5.5-linux-systemd-x86_64"
    
    for i in {wget,libaio,numactl-libs};do
    	rpm -q $i &> /dev/null || yum -y install $i
    done
    yum -y install libncurses*
    mkdir $DIR
    groupadd -r -g 306 mysql
    useradd -r -u 306 -g mysql mysql
    chown mysql.mysql $DIR
    wget $URL
    tar xf $PACK  -C /usr/local
    ln -sn /usr/local/$FILE $NAME
    $NAME/scripts/mysql_install_db --user=mysql --datadir=$DIR
    echo PATH='/usr/local/mysql/bin:$PATH' >/etc/profile.d/mysql.sh
    ln -s /usr/local/mysql/bin/* /usr/bin
    cat > /etc/my.cnf <<EOF
    [mysqld]
    datadir=$DIR
    skip_name_resolve=1
    socket=$DIR/mysql.sock
    log-error=$DIR/mysql.log
    pid-file=$DIR/mysql.pid
     
    [client]
    socket=$DIR/mysql.sock
    EOF
    cp $NAME/support-files/mysql.server  /etc/init.d/mysqld
    chkconfig --add mysqld
    service mysqld start
    mysql -e 'create database wordpress'
    mysql -e "grant all on wordpress.* to wpuser@'10.0.0.%' identified by 'wppass'"
    



  • 相关阅读:
    SQL Server, Timeout expired.all pooled connections were in use and max pool size was reached
    javascript 事件调用顺序
    Best Practices for Speeding Up Your Web Site
    C语言程序设计 使用VC6绿色版
    破解SQL Prompt 3.9的几步操作
    Master page Path (MasterPage 路径)
    几个小型数据库的比较
    CSS+DIV 完美实现垂直居中的方法
    由Response.Redirect引发的"Thread was being aborted. "异常的处理方法
    Adsutil.vbs 在脚本攻击中的妙用
  • 原文地址:https://www.cnblogs.com/LittleRabbit220/p/13911762.html
Copyright © 2011-2022 走看看