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

    1、写出 MPM multi-processing module 工作模式原理以及区别

      profork:多进程I/O模型,每个进程响应一个请求。

      worker:复用的多进程I/O模型,多进程多线程

      event:事件驱动模型,每个进程响应多个请求。

    2、编译安装httpd 2.4

    #!/bin/bash
    DIR=`pwd`
    yum install -y gcc make pcre-devel openssl-devel expat-devel bzip2
    wget https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-1.7.0.tar.bz2
    wget https://downloads.apache.org//apr/apr-util-1.6.1.tar.bz2
    wget https://downloads.apache.org//httpd/httpd-2.4.46.tar.bz2
    mkdir /apps/httpd/ -p
    tar xvf apr-1.7.0.tar.bz2
    tar xvf apr-util-1.6.1.tar.bz2
    tar xvf httpd-2.4.46.tar.bz2
    mv ${DIR}/httpd-2.4.46 /apps/httpd
    mv ${DIR}/apr-1.7.0 /apps/httpd/httpd-2.4.46/srclib/apr
    mv ${DIR}/apr-util-1.6.1 /apps/httpd/httpd-2.4.46/srclib/apr-util
        cd /apps/httpd/httpd-2.4.46
    ./configure --prefix=/apps/httpd24
    --enable-so
    --enable-ssl
    --enable-rewrite
    --with-zlib
    --with-pcre
    --with-included-apr
    --enable-modules=most
    --enable-mpms-shared=all
    --with-mpm=prefork
    make && make install
    useradd -s /sbin/nologin -r apache
    sed -ri 's/^User.*$/User apache/' /apps/httpd24/conf/httpd.conf
    sed -ri 's/^Group.*$/Group apache/' /apps/httpd24/conf/httpd.conf
    sed -ri 'N;22 a MANDATORY_MANPATH                       /apps/httpd24/man' /etc/man_db.conf
    echo PATH=/apps/httpd24/bin:$PATH > /etc/profile.d/httpd24.sh
    source  /etc/profile.d/httpd24.sh
    cat > /usr/lib/systemd/system/httpd.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
    #EnvironmentFile=/etc/sysconfig/httpd

    ExecStart=/apps/httpd24/bin/apachectl start
    ExecReload=/apps/httpd24/bin/apachectl graceful
    ExecStop=/apps/httpd24/bin/apachectl stop
    KillSignal=SIGCONT
    PrivateTmp=true

    [Install]
    WantedBy=multi-user.target
    EOF
    systemctl daemon-reload
    systemctl enable --now  httpd
    3、编写一个一键部署 LAMP 架构之 wordpress 脚本

    #!/bin/bash
    yum install gcc make pcre-devel openssl-devel expat-devel bzip2-devel make wget libaio  libxml2-devel  libmcrypt-devel sqlite-devel oniguruma-devel   -y

    wget(){
      wget  https://mirrors.ustc.edu.cn/mariadb//mariadb-10.2.33/bintar-linux-x86_64/mariadb-10.2.33-linux-x86_64.tar.gz
      wget https://www.php.net/distributions/php-7.4.10.tar.bz2
      wget https://cn.wordpress.org/latest-zh_CN.tar.gz
      wget  https://mirrors.bfsu.edu.cn/apache//apr/apr-1.7.0.tar.bz2
      wget  https://mirrors.tuna.tsinghua.edu.cn/apache//apr/apr-util-1.6.1.tar.bz2
      wget  https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.46.tar.bz2
      mkdir /apps
      useradd -s /sbin/nologin -r  -u 88 apache
      useradd -r -s /sbin/nologin mysql
    }

    install_mariadb(){
    tar xf mariadb-10.2.33-linux-x86_64.tar.gz -C /usr/local/
    cd /usr/local/
    ln -sv mariadb-10.2.33-linux-x86_64 mysql
    cd mysql
    chown -R root.root ./*
    mkdir /data/mysql -p
    chown -R mysql.mysql /data/mysql
    mkdir /etc/mysql
    chown -R mysql.mysql /etc/mysql
    cp support-files/my-huge.cnf /etc/mysql/my.cnf
    sed -ri '/[mysqld]/askip_name_resolve=on' /etc/mysql/my.cnf
    sed -ri '/[mysqld]/adatadir=/data/mysql' /etc/mysql/my.cnf

    echo "PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/lamp.sh
    . /etc/profile.d/lamp.sh
    scripts/mysql_install_db --user=mysql --datadir=/data/mysql
    cp support-files/mysql.server /etc/rc.d/init.d/mysqld
    chkconfig --add mysqld
    service mysqld start
    ss -ntl
    mysql -e "drop database test;"
    mysql -e "create database wordpress;"
    mysql -e "grant all on wordpress.* to wpuser@'10.0.0.%' identified by '123456';"
    }

    install_httpd24(){
    cd
    tar xf apr-1.7.0.tar.bz2
    tar xf apr-util-1.6.1.tar.bz2
    tar xf httpd-2.4.46.tar.bz2
    mv apr-1.7.0 httpd-2.4.46/srclib/apr
    mv apr-util-1.6.1 httpd-2.4.46/srclib/apr-util
    cd httpd-2.4.46
    ./configure --prefix=/apps/httpd24
    --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
    --with-included-apr
    make -j 4 && make install
    sed -ri 's/^User.*$/User apache/' /apps/httpd24/conf/httpd.conf
    sed -ri 's/^Group.*$/Group apache/' /apps/httpd24/conf/httpd.conf
    sed -ri 's/^#(ServerName.*$)/1/' /apps/httpd24/conf/httpd.conf
    sed -ri 'N;22 a MANDATORY_MANPATH                       /apps/httpd24/man' /etc/man_db.conf

    echo PATH=/apps/httpd24/bin:$PATH >> /etc/profile.d/lamp.sh
    source  /etc/profile.d/lamp.sh

    cat > /usr/lib/systemd/system/httpd24.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
    #EnvironmentFile=/etc/sysconfig/httpd

    ExecStart=/apps/httpd24/bin/apachectl start
    ExecReload=/apps/httpd24/bin/apachectl graceful
    ExecStop=/apps/httpd24/bin/apachectl stop


    # We want systemd to give httpd some time to finish gracefully, but still want
    # it to kill httpd after TimeoutStopSec if something went wrong during the
    # graceful stop. Normally, Systemd sends SIGTERM signal right after the
    # ExecStop, which would kill httpd. We are sending useless SIGCONT here to give
    # httpd time to finish.
    KillSignal=SIGCONT
    PrivateTmp=true

    [Install]
    WantedBy=multi-user.target
    EOF
    systemctl daemon-reload
    systemctl enable --now  httpd24
    }
    install_php74(){
    cd
    tar xf php-7.4.10.tar.bz2
    cd php-7.4.10
    ./configure
    --prefix=/apps/php74
    --enable-mysqlnd
    --with-mysqli=mysqlnd
    --with-pdo-mysql=mysqlnd
    --with-openssl
    --with-zlib
    --with-config-file-path=/etc
    --with-config-file-scan-dir=/etc/php.d
    --enable-mbstring
    --enable-xml
    --enable-sockets
    --with-apxs2=/apps/httpd24/bin/apxs
    --enable-maintainer-zts
    --with-freetype-dir
    --with-jpeg-dir
    --with-png-dir
    --with-libxml-dir=/usr
    --disable-fileinfo
    make -j 4 && make install
    echo "PATH=/apps/php74/bin:$PATH" >> /etc/profile.d/lamp.sh
    . /etc/profile.d/lamp.sh
    cp php.ini-production /etc/php.ini
    echo addtype application/x-httpd-php .php >>/apps/httpd24/conf/httpd.conf
    echo addtype application/x-httpd-php-source .phps >>/apps/httpd24/conf/httpd.conf
    sed -ri 's/(DirectoryIndex) (index.html)/1 index.php 2/' /apps/httpd24/conf/httpd.conf
    systemctl daemon-reload
    systemctl restart httpd24
    }

    wordpress(){
    cd
    tar xf wordpress-5.4.2-zh_CN.tar.gz -C /data
    setfacl -R -m u:apache:rwx /data/wordpress/echo "include conf/extra/lamp.conf" >> /apps/httpd24/conf/httpd.confcat >/apps/httpd24/conf/extra/lamp.conf <<-EOFdocumentroot "/data/wordpress"<directory /data/wordpress>require all granted </directory>EOF
    systemctl restart httpd24.service
    }

    wget
    install_mariadb
    install_httpd24
    install_php74
    wordpress

  • 相关阅读:
    day09
    day8
    day 7
    day 6
    PYTHON 学习
    day 5 作业
    day04作业
    Day03作业及默写
    python 2020 day4
    (copy)python操作excel
  • 原文地址:https://www.cnblogs.com/guobang/p/13624162.html
Copyright © 2011-2022 走看看