ServerStatus Install Tutorial

Discussion in 'Tutorials' started by Mun, May 23, 2014.

  1. Mun

    Mun Administrator

    !!! I need to revamp this a little!!!!

    So I have had a few friends ask me to show them how to install ServerStatus on there servers. So I thought I would make a guide. First off, I assume that you have a basic grasp of a non GUI server console. As well as that you can follow instructions. This guide will be for 'Debian based' systems, so if you are using a different operating system you may have to change some commands or look up how to's for the operating system.

    Next assumption, I assume you already have a good idea on how to setup and install a web server of your choice, if this isn't the case I suggest you check out this thread WHT Install Nginx and PHP5-FPM on Debian

    Okay lets start!

    (1. Lets make sure your server is up to date. Lets exec the following code to check for updates and then upgrade those packages that may need upgrading.
    Code:
    apt-get update && apt-get upgrade
    (1a. If it asks you to chose Y/N then please chose yes, but make sure everything looks okay to upgrade.

    (2. I assume you have mysql installed, if you don't please run
    Code:
    apt-get update && apt-get -y install mysql-server
    (3. Now for security reasons I like to run my sites in there own containers, this is just a personal preference, but I suggest it. As such lets add a new user called uptime.
    Code:
    adduser uptime

    (4. Now lets download ServerStatus to the server. To do this lets do the following commands:
    Code:
    apt-get install unzip
    su uptime
    cd ~/
    mkdir logs && mkdir public_html
    wget https://github.com/mojeda/ServerStatus/archive/master.zip
    unzip master.zip
    mv ServerStatus-master/* ~/public_html/
    rm -r ServerStatus-master
    exit
    
    (5. After uploading lets create the database, user, and pass.
    Code:
    mysql -u root -p
    Enter password: <input password>
    
    mysql> create database uptime;
    mysql> grant all privileges on uptime.* to 'user'@'localhost' identified by 'Password';
    mysql> grant usage on uptime.* to 'user'@'localhost' identified by 'Password';
    mysql> quit;
    
    (6. Now lets go configure ServerStatus. It should be in ./includes/config.php. It looks like this:
    Code:
    
    <?php
    
    $host = 'localhost'; # If remote database change this.
    $user = 'user';
    $pass = 'Password';
    $data = 'uptime';
    $sSetting['refresh'] = "10000";
    
    mysql_connect($host, $user, $pass) or die(mysql_error());
    mysql_select_db($data) or die(mysql_error());
    $template = "./templates/default/";
    ?>
    
    (7. Alright, now lets add the table to our mysql database. To do this:
    Code:
    mysql -u root -p uptime < /home/uptime/public_html/sql/servers.sql
    
    (8. Now we need to go back into mysql and populate the fields.
    Code:
    mysql -u root -p
    
    mysql> use uptime;
    mysql> show tables;
    +------------------+
    | Tables_in_uptime |
    +------------------+
    | servers          |         !! If this isn't here, and it show no tables, then please repeat step #8.
    +------------------+
    1 row in set (0.00 sec)
    
    mysql> describe servers;
    
    +----------+-------------+------+-----+---------+----------------+
    | Field    | Type        | Null | Key | Default | Extra          |
    +----------+-------------+------+-----+---------+----------------+
    | id       | int(1)      | NO   | PRI | NULL    | auto_increment |
    | name     | varchar(65) | NO   |     | NULL    |                |
    | url      | varchar(65) | NO   |     | NULL    |                |
    | location | varchar(65) | NO   |     | NULL    |                |
    | host     | varchar(65) | NO   |     | NULL    |                |
    | type     | varchar(65) | NO   |     | NULL    |                |
    +----------+-------------+------+-----+---------+----------------+
    6 rows in set (0.01 sec)
    
    mysql> insert into servers (id, name, url, location, host, type) Values ('1', 'Server', 'www.lowendhelp.com', 'San Jose, CA', 'BlueVM.com', 'Web Server');
    !! Now you need to edit these values. You also don't have to use 'id' however I like it so that I can change the order, please make sure you don't use more then one id at a time otherwise it will freak out.
    !! You will also need to repeat this step as for all your servers.
    
    mysql> select * from servers;
    
    +----+--------------+----------------------------+----------------+--------------------+-----------------------+
    | id | name         | url                        | location       | host               | type                  |
    +----+--------------+----------------------------+----------------+--------------------+-----------------------+
    |  1 | Server   | www.lowendhelp.com   | San Jose, CA    | BlueVM.com         | Web Server           |
    +----+--------------+----------------------------+----------------+--------------------+-----------------------+
    1 rows in set (0.00 sec)
    
    mysql> quit;
    
    
    (9. Okay, now simply setup apache or nginx virtual host, or what ever you feel like and confirm the site is working properly. If it isn't double check all the steps, and then post below.


    (10. Finally you will need to upload uptime.php to your other servers that you wish to monitor. To do this remote into your other servers with ssh. Install apache or nginx, with php, if you don't already. Then for nginx:
    Code:
    cd /usr/share/nginx/html
    wget https://raw.github.com/mojeda/ServerStatus/master/uptime.php
    
    ...and for apache:
    Code:
    cd /var/www/
    wget https://raw.github.com/mojeda/ServerStatus/master/uptime.php
    
    Please note for the above, you can put in any folder but you may have to edit your vhost files in /etc/nginx/site-available or /etc/apache2/sites-available.

    To edit a mysql row in the case you need to change a value do this:
    Code:
    
    mysql -u root -p
    
    mysql> use uptime;
    mysql> select * from servers;
    !! Find what needs to be changed
    
    mysql> update servers set type='WWW Server' where id='1';
    
    mysql> select * from servers;
    !! confirm it has changed.
    mysql> quit;
    
    To delete a row in mysql:
    Code:
    mysql -u root -p
    
    mysql> use uptime;
    mysql> select * from servers;
    !! Find the row you wish to delete.
    
    mysql> delete from servers where id='1';
    mysql> select * from servers;
    !! Double check that is has been removed;
    
    mysql> quit;
    
    If you have issues with apache not showing anything, it is a possible issue with php not reading it has to process a php file. In that case edit /etc/apache2/mods-enabled/php5.conf, it should look like
    Code:
    
    <IfModule mod_php5.c>
        <FilesMatch "\.ph(p3?|tml)$">
            SetHandler application/x-httpd-php
        </FilesMatch>
        <FilesMatch "\.phps$">
            SetHandler application/x-httpd-php-source
        </FilesMatch>
        # To re-enable php in user directories comment the following lines
        # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
        # prevents .htaccess files from disabling it.
        <IfModule mod_userdir.c>
            <Directory /home/*/public_html>
                php_admin_value engine Off
            </Directory>
        </IfModule>
    </IfModule>
    
    
    However for some reason the above won't process .php files, don't ask me why, but to fix this edit the code to look like this
    Code:
    <IfModule mod_php5.c>
        <FilesMatch "\.ph(p3?|tml)$">
            SetHandler application/x-httpd-php
        </FilesMatch>
    # I added this
        <FilesMatch "\.php$">
            SetHandler application/x-httpd-php
        </FilesMatch>
    # To here
        <FilesMatch "\.phps$">
            SetHandler application/x-httpd-php-source
        </FilesMatch>
        # To re-enable php in user directories comment the following lines
        # (from <IfModule ...> to </IfModule>.) Do NOT set it to On as it
        # prevents .htaccess files from disabling it.
        <IfModule mod_userdir.c>
            <Directory /home/*/public_html>
                php_admin_value engine Off
            </Directory>
        </IfModule>
    </IfModule>
    
    and then restart apache with:
    Code:
    service apache2 restart
    
     
    maszd likes this.

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice