CSS Basics

By | AGIX Discussion, Scripting HowTo's | No Comments

This article explains how CSS (style sheets) work to enhance websites. Essentially CSS is used to change the way content is displayed in a web browser.

Get more tips here http://www.w3schools.com/css/

Web browsers know what do to when text is marked-up. But you can change that with CSS. The following is a simple way to use CSS but it’s not the only way. Put the following in the head tags.

<style>
h1 {
  color: #00ff00;
  font-family: serif;
}
</style>

So it would look like this in full:

<html>
<head>
<style>
h1 {
  color: #444444;
  font-family: serif;
}
</style>
</head>
<body>
<h1>This is the heading</h1>
This is the body. 
</body>
</html>

You will notice that the CSS has changed the heading style from defaults. Here are some other useful tips:

h1 {
  color: #444444;
  font-family: serif;
  font-size: 40px;
}
body {
  color: #111111;
  font-family: serif;
  font-size: 25px;
  background-color: #eeeeee;
}
p {
  color: #000000;
  font-family: serif;
  font-size: 20px;
}

The above are ways to manipulate the standard display of browsers. However, you may want to have two types of fonts in the body of the page. Use “classes”.

<html>
<head>
<style>
.bigtext {
  color: #000000;
  font-family: serif;
  font-size: 20px;
}
.smalltext {
  color: #000000;
  font-family: serif;
  font-size: 10px;
}
</style>
</head>
<body>
<h1>This is the heading</h1>
<p class="bigtext">This is big. </p>
<p class="smalltext">This is small. </p>
</body>
</html>

The above method of including CSS in the HTML document is ok but not the best way. Imagine that you have hundreds of web pages that all need to use the same style. The above wouldn’t work well as you’d have to copy it to each HTML page. And making changes to CSS means making changes to every page.

A better method is to “include” the CSS from a CSS file that you have on your server. For example, put the CSS in a file called “style.css” and reference it like this:

<link rel="stylesheet" type="text/css" href="style.css">

The above should be within the head tags. Here’s an example. Create the file “style.css” in the same directory as the web page and put the following in it:

.bigtext {
  color: #000000;
  font-family: serif;
  font-size: 20px;
}
.smalltext {
  color: #000000;
  font-family: serif;
  font-size: 10px;
}

And create your HTML document like this:

<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css"> 
</head> 
<body> 
<h1>This is the heading</h1> 
<p class="bigtext">This is big. </p> 
<p class="smalltext">This is small. </p> 
</body> 
</html>

Login to PostgreSQL with PSQL on Redhat/CentOS

By | Uncategorized | No Comments

This article explains how to login to a PostgreSQL server using the psql tool on Redhat and/or CentOS.

You first need the psql tool:

yum install postgresql

Then use the format below to connect and login. Here we’ll use the username of ‘root’ and the hostname is ‘db.agix.com.au’.

psql -h db.agix.com.au -U root

Enter the password for the root user in the PostgreSQL database and you’re in.

Ldapsearch with Active Directory on Redhat/CentOS

By | All Linux HowTo's | No Comments

This article demonstrates how to get data out of Active Directory using Ldapsearch.

Install the tools:

yum install openldap*

A simple grab:

ldapsearch \
    -x -h ad.server.local \
    -D "myUserName" \
    -W \
    -b "dc=company,dc=local" \
    -s sub "(cn=*)" cn mail sn

The above will get all users within LDAP hosted on the “ldap.server.local” server using the username “myUserName”. You’d be prompted for the password.

Next we grab all attributes of the account with a common name “James Brown”:

ldapsearch \
    -x -h ad.server.local \
    -D "myUserName" \
    -W \
    -b "dc=company,dc=local" "cn=James Brown"\
    -s sub "(cn=*)" cn mail sn

The above will get all information out of LDAP with the common name (real name) “James Brown”.

Performance Profiles for Redhat with TuneD

By | All Linux HowTo's | No Comments

This article simply points to a great Blog post by the Redhat team. It demonstrates and explains how a system administrator can easily select a performance profile thereby adjusting the settings of a RHEL server to the job at hand.


http://servicesblog.redhat.com/2012/04/16/tuning-your-system-with-tuned/

Have a read. It’s worth it.

Install New Relic on Redhat or CentOS 64bit

By | All Linux HowTo's | No Comments

This article explains how to install New Relic on a Redhat or CentOS 64bit server.

rpm -Uvh https://yum.newrelic.com/pub/newrelic/el5/x86_64/newrelic-repo-5-3.noarch.rpm

And then:

yum install newrelic-sysmond

Edit the configuration file to add your key. Edit the “/etc/newrelic/nrsysmond.cfg” file.

license_key=REPLACE_WITH_REAL_KEY

Enable and restart New Relic:

chkconfig newrelic-sysmond on
service newrelic-sysmond restart

Install Redit on Redhat/CentOS

By | All Linux HowTo's | No Comments

This article explains how to install Redis on a Redhat or CentOS server. We have the EPEL repo already available on this server prior to starting this tutorial.

yum install redis

Edit the configuration file to bind it to the correct network interface. Only do this if you want other servers to connect to your Redis server. The configuration file is “/etc/redis.conf”:

bind 0.0.0.0

The above will have Redis listen on all interfaces.

Now enable it:

chkconfig redis on

Enable port “6379” through the firewall in “/etc/sysconfig/iptables”:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT

And restart the key services:

service redis restart
service iptables restart

Install Spamassassin on CentOS & Redhat

By | All Linux HowTo's | No Comments

This article demonstrates how to install Spamassassin on a CentOS or Redhat server. We’re starting with a working Postfix server.

Start by installing Spamassassin with Yum:

yum install spamassassin
useradd spamd

Add the following to the “/etc/postfix/master.cf” file. Add the following to the end of the first non-remarked line:

-o content_filter=spamassassin

Add the following to the end of the “/etc/postfix/master” file:

spamassassin unix - n n - - pipe flags=R user=spamd argv=/usr/bin/spamc -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}

Enable and restart Spamassassin:

service spamassassin restart
chkconfig spamassassin on

And restart Postfix:

service postfix restart

Install Postfix, Dovecot & Squirrelmail

By | All Linux HowTo's | No Comments

This article demonstrates how to install Postfix, Dovecot and Squirrelmail on Redhat/CentOS Linux.

yum install dovecot postfix httpd php mod_ssl openssl

Set things to start on boot:

chkconfig postfix on
chkconfig dovecot on
chkconfig httpd on

Make sure to permit ports 25, 80 and 443 through the firewall(s).

Edit the “/etc/postfix/main.cf” file and make these changes:

myhostname = mail.example.com
mydomain = example.com
myorigin = $myhostname
inet_interfaces = all
#inet_interface = localhost
mydestination = $mydomain, $myhostname, localhost.$mydomain, localhost
mynetworks = 192.168.0.0/16, 127.0.0.0/8

Edit the “/etc/dovecot/conf.d/10-mail.conf” file and make this change:

mail_location = mbox:~/mail:INBOX=/var/spool/mail/%u

Install Squirrelmail:

cd /tmp
wget http://downloads.sourceforge.net/project/squirrelmail/stable/1.4.22/squirrelmail-webmail-1.4.22.zip
unzip squirrelmail-webmail-1.4.22.zip
cd squirrelmail-webmail-1.4.22
./configure

At this stage you should follow the on-screen prompts to complete the Squirrelmail installation.
Now copy your Squirrelmail structure into the web server document root:

cp -rp /tmp/squirrelmail-webmail-1.4.22/* /var/www/html

Edit your “/etc/httpd/conf.d/ssl.conf” file accordingly:

DocumentRoot "/var/www/html/"
ServerName www.example.com:443

Consider setting a valid certificate for the HTTPS access to your web mail site.

Restart these services and do some testing. Monitor your “/var/log/maillog” for errors. Such as “tail -f /var/log/maillog”. Good luck.

service httpd restart
service dovecot restart
service postfix restart

Bug fix. If you get permission errors in the logs and can’t see new email, try this:

Error: chown(/home/myuser/mail/.imap/INBOX, -1, 12(mail)) failed: Operation not permitted (egid=1367(myuser), group based on /var/spool/mail/myuser)
Feb  5 07:36:42 dc dovecot: imap(myuser): Error: mkdir(/home/myuser/mail/.imap/INBOX) failed: Operation not permitted

This is to do with group ownership and permissions. There is a better way to resolve this than i’ve shown below and i will update this article shortly. However, it can be quickly solved with this:

chmod 0600 /var/spool/mail/*

VirtualBox for Ubuntu in 2 Minutes

By | All Linux HowTo's | No Comments

This article is not about installing or designing a virtual environment but simply about listing, starting and stopping virtual guests with the VirtualBox environment.

First you need to log into the host server and change to the “vboxadmin” user:

su - vboxadmin

List the running VM’s:

VBoxManage list runningvms

List all VM’s running or stopped:

VBoxManage list vms

To start a VM you first get it’s name from the listing commands above and then issue the following. In this example the VM name is “server1″:

VBoxManage startvm server1  --type headless

To stop the “server1″ VM:

VBoxManage controlvm server1 poweroff

The above command’s “poweroff” option can be replaced with any of the following:

pause, resume, reset ,poweroff, savestate

Contact AGIX Support

Level 2, 170 Greenhill Road
Parkside 5063 South Australia
Phone: (08) 7324 4429
or 0422 927 598
support@agix.com.au