Adding new hard drives on an installed Linux Server
September 16, 2009Here’s another good tutorials in adding HD in Linux
Ref: http://www.freelinuxtutorials.com/
—————————————————————————————————————
These are the steps on adding additional hard drives on a pre-installed Linux server.
Drives will be detected and can be checked thru the “dmesg” command.
[root@localhost ~]#fdisk /dev/cciss/c0d1
press n to create partition, just use the default settings for it
press w to write exit
3. Create ext3 filesystem
[root@localhost ~]# mkfs.ext3 /dev/cciss/c0d1p1
4. Mount that drive to test but first create a directory where to mount it.
[root@localhost ~]#mkdir /data
[root@localhost ~]#mount -t auto /dev/cciss/c0d1p1 /data
Here’s the continuation of the full post above
Quick tip: Adding new hard drives on an installed Linux Server
Posted in Quick Tips & Tricks by tux No Comments
These are the steps on adding additional hard drives on a pre-installed Linux server.
Drives will be detected and can be checked thru the “dmesg” command.
[root@localhost ~]#fdisk /dev/cciss/c0d1
press n to create partition, just use the default settings for it
press w to write exit
3. Create ext3 filesystem
[root@localhost ~]# mkfs.ext3 /dev/cciss/c0d1p1
4. Mount that drive to test but first create a directory where to mount it.
[root@localhost ~]#mkdir /data
[root@localhost ~]#mount -t auto /dev/cciss/c0d1p1 /data
5. Verify if its mounted already.
[root@localhost cciss]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
65G 2.2G 59G 4% /
/dev/cciss/c0d0p1 99M 12M 83M 12% /boot
tmpfs 1005M 0 1005M 0% /dev/shm
/dev/cciss/c0d1p1 135G 188M 128G 1% /data
6. We need to put the mount function on startup so in case of shutdown or reboot, the new HDD is still be recognized by the system
#vi /etc/fstab
Add this line:
/dev/cciss/c0d1p1 /data ext3 defaults 1 3
wherein:
/dev/cciss/c0d1p1 – device to be mounted
/data – mount point
ext3 – type of filesystem
defaults – mount options, Uses the default options that are rw, suid, dev, exec, auto, nouser, and async.
1 3 – dump and fsck options (5th column is dump options, checks and uses the number to decide if a filesystem should be backed up; 6th column is the order the filesystems should be checked by fsck.
Save and exit
7. Verify if the config is correct on /etc/fstab after changes
[root@localhost cciss]#mount –av
[root@localhost cciss]#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
65G 2.2G 59G 4% /
/dev/cciss/c0d0p1 99M 12M 83M 12% /boot
tmpfs 1005M 0 1005M 0% /dev/shm
/dev/cciss/c0d1p1 135G 188M 128G 1% /data
As you can see c0d1p1 already recognized on the system.
8. Reboot the server and check for errors, then issue again the “df” command to see if the new partition/drive is already there.
quick tip: rotating tomcat logs via cronolog
Posted in Quick Tips & Tricks by tux | No Comments
1.compile cronolog (http://cronolog.org) and install it on /usr/local/sbin
2. backup orig /usr/local/apache-tomcat-5.5.20/bin/catalina.sh on /root
3. edit lines on catalina.sh from
org.apache.catalina.startup.Bootstrap “$@” start \
>> “$CATALINA_BASE”/logs/catalina.out 2>&1 &
to
org.apache.catalina.startup.Bootstrap “$@” start 2>&1 \
| /usr/local/sbin/cronolog “$CATALINA_BASE”/logs/catalina.out.%Y-%m-%d >> /dev/null &
4. Removed the line
touch “$CATALINA_BASE”/logs/catalina.out
5. Restart web service
#/usr/local/tomcat/bin/shutdown.sh
# service httpd stop
# /usr/local/tomcat/bin/startup.sh
#service httpd start
TESTING
1. Check tomcat logs to see generated Catalina.out per day
# ls -la /usr/local/tomcat/logs
-rw-r–r– 1 root root 65607 Nov 6 14:55 catalina.out.2007-11-06
2. browse ww2.freelinuxtutorials.com and login using test account to see if tomcat is working
Installation of GeoIP Information for AWStats
Posted in Working with Servers by tux | No Comments
This is a continuation procedure for AWStats installation.
PROCEDURES:
GeoIP Information will show country information in AWStats.
1. Download the current GeoLite Country from the internet
1. #wget http://www.maxmind.com/download/geoip/database/GeoIP.dat.gz
2. Create GeoIP directory
# mkdir /usr/local/share/GeoIP
3. Move data files to directory and unzip.
#mv GeoIP.dat.gz /usr/local/share/GeoIP/
#gunzip /usr/local/share/GeoIP/GeoIP.dat.gz
4. Install the GeoIP program
#wget http://www.maxmind.com/download/geoip/api/c/GeoIP-1.4.3.tar.gz
#cd /usr/local/src
#tar zxvf GeoIP-1.4.3.tar.gz
#cd /usr/local/src/GeoIP-1.4.3
#./configure
#make
#make check
#make install
#vi /etc/ld.so.conf
add the line:
/usr/local/lib
#ldconfig
5. Install Geo::IP Perl Module
#wget http://www.maxmind.com/download/geoip/api/perl/Geo-IP-1.27.tar.gz
Installation and Configuration of AWStats on Apache Web Server
I found this using this while browsing the internet…Enjoy!
http://www.freelinuxtutorials.com/working-with-servers-or-daemon/installation-and-configuration-of-awstats-on-apache-web-server/
________________________________________________________________________________________________
Here are the steps in installing AWstats on Apache Web Server as your web log analyzer and statistics:
STEPS:
Assuming VirtualHost setting is already added on the httpd.conf, and the log is customized already for a combined log.
Example:
#<VirtualHost support.freelinuxtutorials.com:80>
ServerAdmin webmaster@support.freelinuxtutorials.com
DocumentRoot /home/www/support.freelinuxtutorials.com
ServerName support.freelinuxtutorials.com
ErrorLog /var/log/httpd/support.freelinuxtutorials.com-error_log
CustomLog /var/log/httpd/support.freelinuxtutorials.com-combined_log combined
If not httpd.conf should be modified to customized the log of a particular website
CustomLog /yourlogpath/yourlogfile common
to
CustomLog /yourlogpath/yourlogfile combined
1. Download the latest stable awstats.tar.gz from the internet or get it from PHMFILE server (\\phmfile\c$\MIS Operation Software\Installer & Application\awstats)
#cd /usr/local/
#wget http://prdownloads.sourceforge.net/awstats/awstats-6.7.tar.gz
2. Uncompress the tarball file and rename the directory to awstats
#tar zxvf awstats-6.7.tar.gz
#mv awstats-6.7 awstats
#cd awstats
#/tools/awstats_configure.pl
It will ask for series of questions, just input the necessary details.
Example:
a.
—– AWStats awstats_configure 1.0 (build 1.7) (c) Laurent Destailleur —–
This tool will help you to configure AWStats to analyze statistics for
one web server. You can try to use it to let it do all that is possible
in AWStats setup, however following the step by step manual setup
documentation (docs/index.html) is often a better idea. Above all if:
- You are not an administrator user,
- You want to analyze downloaded log files without web server,
- You want to analyze mail or ftp log files instead of web log files,
- You need to analyze load balanced servers log files,
- You want to ‘understand’ all possible ways to use AWStats…
Read the AWStats documentation (docs/index.html).
—–> Running OS detected: Linux, BSD or Unix
—–> Check for web server install
Enter full config file path of your Web server.
Example: /etc/httpd/httpd.conf
Example: /usr/local/apache2/conf/httpd.conf
Example: c:\Program files\apache group\apache\conf\httpd.conf
Config file path (’none’ to skip web server setup):
Input the location of your web config
/etc/httpd/conf/httpd.conf
b.
—–> Check and complete web server config file ‘/etc/httpd/conf/httpd.conf’
—–> Update model config file ‘/usr/local/awstats/wwwroot/cgi-bin/awstats.model.conf’
File awstats.model.conf updated.
—–> Need to create a new config file ?
Do you want me to build a new AWStats config/profile
file (required if first install) [y/N] ?Y
Type Y to create a new awstats config
c.
—–> Define config file name to create
What is the name of your web site or profile analysis ?
Example: www.mysite.com
Example: demo
Your web site, virtual server or profile name:
>www.mysite.com
wherein www.mysite.com is the name of your config file
d.
—–> Define config file path
In which directory do you plan to store your config file(s) ?
Default: /etc/awstats
Directory path to store config file(s) (Enter for default):
/etc/awstats
Specify the location you want to store your config file
—–> Add update process inside a scheduler
Sorry, configure.pl does not support automatic add to cron yet.
You can do it manually by adding the following command to your cron:
/usr/local/awstats/wwwroot/cgi-bin/awstats.pl -update -config=www.mysite.com
Or if you have several config files and prefer having only one command:
/usr/local/awstats/tools/awstats_updateall.pl now
Press ENTER to continue…
Press ENTER to continue (just manual set the crontab script once finish with the installation)
e.
A SIMPLE config file has been created: /etc/awstats/awstats.www.mysite.com.conf
You should have a look inside to check and change manually main parameters.
You can then manually update your statistics for ‘www.mysite.com’ with command:
> perl awstats.pl -update -config=www.mysite.com
You can also read your statistics for ‘www.mysite.com’ with URL:
> http://localhost/awstats/awstats.pl?config=www.mysite.com
Press ENTER to finish…
3. awstats_configure.pl will then add, if not already present, the following directives to your Apache configuration file
Inspect the httpd.conf file if not added, then add this lines:
#
# Directives to add to your Apache conf file to allow use of AWStats as a CGI.
# Note that path “/usr/local/awstats/” must reflect your AWStats Installation path.
#
Alias /awstatsclasses “/usr/local/awstats/wwwroot/classes/”
Alias /awstatscss “/usr/local/awstats/wwwroot/css/”
Alias /awstatsicons “/usr/local/awstats/wwwroot/icon/”
ScriptAlias /awstats/ “/usr/local/awstats/wwwroot/cgi-bin/”
#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory “/usr/local/awstats/wwwroot”>
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
4.Edit your awstats configuration file based on your web settings.
# vi /etc/awstats/awstats.www.mysite.com.conf
These are the following lines that need to modify
a. LogFile
b. LogType
c. LogFormat
c. SiteDomain
Example config file:
LogFile=”/var/log/httpd/support.freelinuxtutorials.com-combined_log”
LogType=W
LogFormat=1
SiteDomain=”www.mysite.com”
AllowToUpdateStatsFromBrowser=0 (optional, you can set 1 so you can update the stats via the Browser)
4. Update the statistics database. It is recommended that you update it manually via the command line since the process may be long and it’s easier to solve problems when you can see the command output
#usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.mysite.com –update
Update for config “/etc/awstats/awstats.mysite.conf”
With data in log file “/pathtoyourlog/yourlog.log”…
Phase 1 : First bypass old records, searching new record…
Searching new records from beginning of log file…
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)…
Jumped lines in file: 0
Parsed lines in file: 225730
Found 122 dropped records,
Found 87 corrupted records,
Found 0 old records,
Found 225521 new qualified records.
Note: to update the old log file, you just need to change the LogFile to the old log file you want to update.
Example:
On your /etc/awstats/awstats.www.mysite.com.conf
From
LogFile=”/var/log/httpd/support.freelinuxtutorials.com-combined_log”
To
LogFile=”/var/log/httpd/support.freelinuxtutorials.com-combined_log.1″
5. View Site Statistics
Access it using your favorite browser. Type
http://www.mysite.com/awstats/cgi-bin/awstats.pl?config=www.mysite.com
6. Create crontab script in order to update the log file analysis
#crontab –e
add this line
example:
0 * * * * /usr/local/awstats/wwwroot/cgi-bin/awstats.pl -config=www.mysite.com -update > /root/awstatsjob/awstats.log
7. You can follow “Installation of GeoIP Information for AWStats” documentation to have a country information on your web/mail/ftp statistics.
SETTING UP HTACCESS ON AWSTATS for ADDED SECURITY
1. Add these lines on httpd.conf to configure htaccess file
#vi /etc/httpd/conf/httpd.conf
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory “/usr/local/awstats/wwwroot”>
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
<Directory “/usr/local/awstats/wwwroot/cgi-bin”>
AllowOverride None
Options ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
AuthType basic
AuthName “NOC Authentication”
AuthUserFile /etc/awstats/awstats.htpasswd
<Files awstats.pl>
Require valid-user
</Files>
</Directory>
2. Configure htpasswd file
#cd /etc/awstats/
#htpasswd –c awstats.htpasswd username
New password:
Re-type new password:
Adding password for user username
3. Adding new users
To add new users, use the same command without the -c switch
#htpasswd awstats.htpasswd darwin
To delete users, open the htpasswd file and delete the line you want to remove
4. Test the configuration
Open the browser and then type the URL. If it is successful, you should get a dialog box prompting for your username and password. Type the username/password you configured on your htaccess file
SETUP AWSTATS for FTP LOG ANALYSIS
Since we are using vsFTPd as our FTP server, the log file is in xferlog format. Installation is just the same for web statistics except for awstats configuration where LogType is F (stand for FTP) and LogFormat based on your FTP log format
1. Check your ftp log format
#cd /var/log/
#less xferlog
Take a look at your FTP server log file. You must have a format that match the following example to use
Wed Jan 01 19:29:35 2001 1 192.168.1.1 102 /home/file1.txt b _ o r username ftp 0 * c
Example:
#less /var/log/xferlog
Sun Dec 16 19:57:13 2007 16 59.94.74.165 561976 /softphone/freelinuxtutorialsSetup.MSI b _ o
a IEUser@ ftp 0 * i
2. Setup AWStats to analyze FTP log
#vi /etc/awstats/awstats.ftp.conf
Modify the config file (lines below in bold are the important, others can stay in default)
LogFile=”/var/log/xferlog”
LogType=F
LogFormat=”%time3 %other %host %bytesd %url %other %other %method %other %logname %other %code
%other %other”
LogSeparator=”\s”
NotPageList=””
LevelForBrowsersDetection=0
LevelForOSDetection=0
LevelForRefererAnalyze=0
LevelForRobotsDetection=0
LevelForWormsDetection=0
LevelForSearchEnginesDetection=0
ShowLinksOnUrl=0
ShowMenu=1
ShowSummary=UVHB
ShowMonthStats=UVHB
ShowDaysOfMonthStats=HB
ShowDaysOfWeekStats=HB
ShowHoursStats=HB
ShowDomainsStats=HB
ShowHostsStats=HBL
ShowAuthenticatedUsers=HBL
ShowRobotsStats=0
ShowEMailSenders=0
ShowEMailReceivers=0
ShowSessionsStats=1
ShowPagesStats=PBEX
ShowFileTypesStats=HB
ShowFileSizesStats=0
ShowBrowsersStats=0
ShowOSStats=0
ShowOriginStats=0
ShowKeyphrasesStats=0
ShowKeywordsStats=0
ShowMiscStats=0
ShowHTTPErrorsStats=0
ShowSMTPErrorsStats=0


