Coder Social home page Coder Social logo

apache2's Introduction

Apache2

Storing Apache2 Logs

Step1: Installing Apache2 server:

sudo apt update

sudo apt install apache2

sudo echo "ServerName localhost" >> /etc/apache2/apache2.conf

sudo nano /etc/apache2/ports.conf # replace the Listen 80 with the 8079

sudo service apache2 start

Step2: Writing a bash script that checks the APACHE2 servers logs and compress them

nano apache2_log_compress.bash

    #!/bin/bash
    compress () {
            if [ "$(wc -l < $1)" -ge 20 ]
            then
                    DATE=`date +%d-%m-%y_%H-%M-%S`
                    sudo gzip -S "_$DATE.gz" $1
            fi

    }

    go_directory () {
            if [ -d "/var/log/apache2" ]
            then
                    if [ -f  "$1" ]
                    then
                            compress $1
                    fi
            fi
    }

    go_directory "/var/log/apache2/access.log"
    go_directory "/var/log/apache2/error.log"
    go_directory "/var/log/apache2/other_vhosts_access.log"

sudo chmod 764 apache2_log_compress.bash

Step 3: Setting a crontab

              crontab -e
            
              # runs per 1 minute.
              * 1 * * * /home/phyex/apache2_log_compress.bash 
              
              crontab -l 

apache2's People

Contributors

phyex0 avatar

Watchers

Duygu Ölmez avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.