lamp part 2
======================================================
DEBIAN - LAMP Part 2
======================================================
----------------------
1) webalizer stats
2) mrtg network stats
3) mysql setup
4) phpmyadmin setup
5) wiki setup
----------------------
======================================================
======================================================
======================================================
* WEBALIZER Stats setup
-----------------------
http://IPADR/webalizer/
With Webalizer you can generate "nice" (but a bit "old-style" maybe)
web-stats. http://www.mrunix.net/webalizer/
Every single hit on your webserver will add a line in the access_log
file: this is valid for any html, php, gif, css, js, jpg file.
Webalizer will read this file, and generate some statistics.
0) make sure the clock is correct on your system:
abbts1:~# ntpdate ch.pool.ntp.org
24 Feb 21:35:53 ntpdate[7740]: step time server 195.190.190.13 offset 1.727324 sec
1) abbts1:~# apt-get install webalizer
2) update: /etc/webalizer/webalizer.conf
set (and uncomment):
Incremental yes
-> this way it is possible to delete the access_log after stats
generation, and the figures will still be valid after. Otherwise
the current month stats would be resetted.
3) Create the output directory:
abbts1:~# mkdir -p /var/www/webalizer/
4) Run it manually to check everything is fine:
abbts1:# /usr/bin/webalizer -Q -d -c /etc/webalizer/webalizer.conf \
-o /var/www/webalizer/ /var/log/apache2/access.log
5) Now visit your stats:
http://IP_ADDRESS/webalizer/
6) Next step: make it run every 15 minutes, and check it is really
the case by monitoring /var/log/syslog and checking the date on
the /webalizer/ main page.
7) Password-protect the directory:
Add a file: /var/www/webalizer/.htaccess with:
# -------------------------
AuthUserFile /var/www/webalizer/.htpassztxy
AuthGroupFile /dev/null
AuthName 'Protected Area'
AuthType Basic
Require valid-user
# -------------------------
Create the password file:
abbts1:~# htpasswd -c /var/www/webalizer/.htpassztxy stats
New password:
Re-type new password:
Adding password for user stats
abbts1:~#
abbts1:~# cat /var/www/webalizer/.htpassztxy
stats:zR5CoqExROcag
abbts1:~#
And test again: http://IPADR/webalizer/ should now be
password-protected.
More information:
- man webalizer
- comments in the /etc/webalizer/webalizer.conf file
- http://www.webalizer.org/
======================================================
======================================================
======================================================
* MRTG Setup
MRTG - http://oss.oetiker.ch/mrtg/ - Tobias Oetiker (ETHZ)
The Multi Router Traffic Grapher, or just simply MRTG, is free
software for monitoring and measuring the traffic load on network
links. It allows the user to see traffic load on a network over
time in graphical form.
It was originally developed by Tobias Oetiker and Dave Rand to
monitor router traffic, but has developed into a tool that can
create graphs and statistics for almost anything.
1) Install SNMP daemon (Source for the Graphs)
SNMP = Simple Network Management Protocol:
http://en.wikipedia.org/wiki/Simple_Network_Management_Protocol
abbts1:~# apt-get install snmp snmpd mrtg
Update /etc/snmp/snmpd.conf and edit the access rights to let
mrtg get the information:
Replace
com2sec paranoid default public
by
com2sec readonly default public
abbts1:~# /etc/init.d/snmpd restart
abbts1:~# ps fawux|grep snmp
2) mrtg initial setup with 'cfgmaker' (part of MRTG tools)
abbts1:~# cfgmaker public@localhost > /etc/mrtg.cfg
abbts1:~#
And check if this lines is visible at the beginning of the file:
WorkDir: /var/www/mrtg
-> it's the output directory, where the files will be stored.
(create it if it doesn't exist yet on your system)
3) Run it few times (3x)
abbts1:~# env LANG=C /usr/bin/mrtg /etc/mrtg.cfg
You can then look at the generated files under:
http://IPADDR/mrtg/
4) Protect the mrtg directory as well by simply copying
the .htaccess file from webalizer/ to mrtg/ (no need to
copy the password file...)
5) Generate a nice HTML index: (indexmaker is also part of MRTG)
abbts1:~# indexmaker /etc/mrtg.cfg > /var/www/mrtg/index.html
6) Visit http://IPADR/mrtg/ again
7) And update again your crontab:
*/5 * * * * root env LANG=C /usr/bin/mrtg /etc/mrtg.cfg
8) Generate some high bandwidth usage (for example by uploading
several hundred MB of data via FTP or Samba) : after 5-10
minutes, you should see a "peak" on the graph.
More information:
- http://oss.oetiker.ch/mrtg/
- "new generation" : RRD, http://oss.oetiker.ch/rrdtool/
======================================================
======================================================
======================================================
* Basic MYSQL Setup
=================
abbts1:~# apt-get install mysql-server-5.0 (if not done last week)
- Change root password
abbts1:~#
abbts1:~# /etc/init.d/mysql start
Starting MySQL database server: mysqld ..
Checking for corrupt, not cleanly closed and upgrade needing tables..
abbts1:~#
Problem: 'root'-User has not password (if you haven't set one yet,
otherwise you can skip this part).
abbts1:~# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 5.0.32-Debian_7etch5-log Debian etch distribution
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> select * from user;
[...]
mysql> UPDATE user SET Password=PASSWORD('sqlabbts2o1o')
WHERE User LIKE 'root';
Query OK, 2 rows affected (0.01 sec)
Rows matched: 2 Changed: 2 Warnings: 0
Check:
mysql> select * from user
To validate the change (otherwise we would have to restart the
mysql server with /etc/init.d/mysql restart ):
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec)
mysql> exit
Bye
abbts1:~# mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost'
(using password: NO)
abbts1:~#
abbts1:~# mysql -u root -p
[...]
More information:
- man mysql, man mysqld
- http://dev.mysql.com/doc/refman/5.0/en/index.html : manual
- /etc/mysql/my.cnf : local configuration
======================================================
======================================================
======================================================
* PHPMYADMIN Setup (PMA)
================
phpMyAdmin is a free software tool written in PHP intended to
handle the administration of MySQL over the World Wide Web.
phpMyAdmin supports a wide range of operations with MySQL. The
most frequently used operations are supported by the user
interface (managing databases, tables, fields, relations,
indexes, users, permissions, etc), while you still have the
ability to directly execute any SQL statement.
abbts1:~# apt-get install phpmyadmin (if not installed yet)
abbts1:~# apt-cache show phpmyadmin
[...]
Version: 4:2.11.8.1-5+lenny3
[...]
-> this is quite old... We will try the newest version later (3.3.0-rc1)
Visit http://IP/phpmyadmin/ : it should display the login screen for PMA.
If it is not the case, you probably forgot to activate it for apache2, so
run: "dpkg-reconfigure phpmyadmin" , and select:
Webserver to reconfigure automatically: [x] apache2
http://IP/phpmyadmin/ should now display something: please
try to login as root.
But it's not installed in /var/www/phpmyadmin! The trick is done
with a config file included in apache setup:
abbts1:/etc/apache2/conf.d# ls -la
total 12
drwxr-xr-x 2 root root 4096 2008-02-19 00:41 .
drwxr-xr-x 7 root root 4096 2008-02-18 22:27 ..
-rw-r--r-- 1 root root 24 2008-02-12 12:52 charset
lrwxrwxrwx 1 root root 28 2008-02-19 00:41 phpmyadmin.conf ->
../../phpmyadmin/apache.conf
Have a short look at this file: the most important part is the:
"Alias /phpmyadmin /usr/share/phpmyadmin" line.
Since the debian-stable version of phpmyadmin is old, please get
the most recent update: http://www.phpmyadmin.net/ -> Download 3.3.0-rc1
(for example with lynx on your debian system, or get the file on your host
OS and copy it via scp).
Unpack it under /var/www/ and rename the directory to /pma/ instead of
/phpMyAdmin-3.3.0-rc1-all-languages/ . At the end you should be able
to login under http://IP/pma/ with your mysql root password.
Some PMA (phpMyAdmin) features only work if a special database named
'phpmyadmin' exists. Please create it according to:
http://IPADR/pma/Documentation.html#linked-tables :
1) create a DB 'phpmyadmin'
abbts1:~#
abbts1:~# cd /var/www/pma/scripts/
abbts1:/var/www/pma/scripts# less create_tables.sql
abbts1:/var/www/pma/scripts# cat create_tables.sql | mysql -u root -p
Enter password: ***********
abbts1:/var/www/pma/scripts#
Now under http://IPADR/pma/ (after a refresh) you
should se a new DB named 'phpmyadmin' with about 10 tables.
2) Create a mysql user/password: via PMA (click on the red 'SQL'
icon) or under the mysql console:
GRANT USAGE ON mysql.* TO 'pma'@'localhost' IDENTIFIED BY 'pmapass2010';
GRANT SELECT (
Host, User, Select_priv, Insert_priv, Update_priv, Delete_priv,
Create_priv, Drop_priv, Reload_priv, Shutdown_priv, Process_priv,
File_priv, Grant_priv, References_priv, Index_priv, Alter_priv,
Show_db_priv, Super_priv, Create_tmp_table_priv, Lock_tables_priv,
Execute_priv, Repl_slave_priv, Repl_client_priv
) ON mysql.user TO 'pma'@'localhost';
GRANT SELECT ON mysql.db TO 'pma'@'localhost';
GRANT SELECT ON mysql.host TO 'pma'@'localhost';
GRANT SELECT (Host, Db, User, Table_name, Table_priv, Column_priv)
ON mysql.tables_priv TO 'pma'@'localhost';
then:
GRANT SELECT, INSERT, UPDATE, DELETE ON
phpmyadmin.* TO 'pma'@'localhost';
and:
FLUSH PRIVILEGES;
3) Last step: update the phpmyadmin configuration:
abbts1:~# vi /var/www/pma/config.inc.php
<?php
$i=0;
$i++;
$cfg['blowfish_secret'] = 'some_random_text_123456_xyz';
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'cookie';
/* Server parameters */
$cfg['Servers'][$i]['host'] = 'localhost';
$cfg['Servers'][$i]['connect_type'] = 'tcp';
$cfg['Servers'][$i]['compress'] = false;
/* Select mysqli if your server has it */
$cfg['Servers'][$i]['extension'] = 'mysqli';
/* Optional: User for advanced features */
$cfg['Servers'][$i]['controluser'] = 'pma';
$cfg['Servers'][$i]['controlpass'] = 'pmapass2010';
/* Optional: Advanced phpMyAdmin features */
$cfg['Servers'][$i]['pmadb'] = 'phpmyadmin';
$cfg['Servers'][$i]['bookmarktable'] = 'pma_bookmark';
$cfg['Servers'][$i]['relation'] = 'pma_relation';
$cfg['Servers'][$i]['table_info'] = 'pma_table_info';
$cfg['Servers'][$i]['table_coords'] = 'pma_table_coords';
$cfg['Servers'][$i]['pdf_pages'] = 'pma_pdf_pages';
$cfg['Servers'][$i]['column_info'] = 'pma_column_info';
$cfg['Servers'][$i]['history'] = 'pma_history';
$cfg['Servers'][$i]['designer_coords'] = 'pma_designer_coords';
$cfg['Servers'][$i]['tracking'] = 'pma_tracking';
?>
4) Logout and Login again under /pma/ : no warning should be visible now.
5) Testing
5.1) Run this query in the DB mysql:
SELECT * FROM user WHERE user LIKE 'root';
and save it as "bookmark" named "abbots" in PMA.
It should then be visible in the phpmyadmin DB, table
pma_bookmark.
5.2) Create a new database "pmatest", and a new table "table1"
with 3 fields (at your choice). Then activate the "Tracking"
feature for this table.
Add another field, and some rows of data.
Then: "Tracking" -> Tracking Report.
All of this is saved in the phpmyadmin:pma_tracking table.
======================================================
======================================================
======================================================
* Wiki Installation: (wikipedia-like)
=====================================
A wiki is a page or collection of Web pages designed to enable
anyone who accesses it to contribute or modify content, using a
simplified markup language.[1][2] Wikis are often used to create
collaborative websites and to power community websites.
Good selection:
http://en.wikipedia.org/wiki/Comparison_of_wiki_software
Let's setup a wiki software "by hand": the newest version of
Mediawiki (based on the software used for wikipedia.org);
Please get mediawiki-1.15.1.tar.gz from
http://www.mediawiki.org/wiki/Download
abbts1:/var/www# wget
http://download.wikimedia.org/mediawiki/1.15/mediawiki-1.15.1.tar.gz
And then "RTFM" under:
http://www.mediawiki.org/wiki/Installation
and
http://www.mediawiki.org/wiki/Manual:Installation_guide
( http://www.mediawiki.org/wiki/Manual:Running_MediaWiki_on_Linux
as we don't use the debian packages this time )
abbts1:/var/www# tar xvzf mediawiki-1.15.1.tar.gz
abbts1:/var/www# mv mediawiki-1.15.1 wiki
abbts1:/var/www# mv mediawiki-1.15.1.tar.gz /usr/local/src/
visit http://IPADR/wiki/
and follow the guide... (use a valid mail address).
Please use "wikiuser" as user, "wikidb" as DB name, a
password of your choice, and let the Setup create the DB and User
for you (it will require the mysql root password).
Next: Log In, and modify your "Main_Page".
Then, create a page "About Me" ( http://IP/wiki/index.php/AboutMe ),
and add one or more pictures on it. To make this work, you will need to
activate file upload, and to create a wiki user account:
Then activate the file upload:
$wgEnableUploads = true;
in LocalSettings.php
( abbts1:/var/www/wiki# chmod a+rwx images/ )
At the end, link your new "About Me" page on the Main_Page.
Have a nice day! :-)
======================================================
======================================================
======================================================