Installation eines Webservers
Grundlegene Installation von Apache, MySQL, PHP, PHPMyAdmin und Cacti
Emergen:
- USE-Variable ergänzen. Dazu die Datei /etc/make.conf entsprechend editieren:
# nano -w /etc/make.conf
USE="apache2 mysql pam ssl xml xml2"
- Das System auf die veränderte USE-Variable abstimmen:
# emerge --deep --newuse --update --verbose
Sollte nach jeder USE-Variabelenveränderung ausgeführt werden!
- Emergen von Apache, MySQL und PHP:
# emerge mod_php
Durch die USE-Variable hergestellte Abhängigkeiten reicht das emergen von mod_php!
Konfiguration des Apache:
- Apache konfigurieren. Dazu die Datei /etc/conf.d/apache2 entsprechend editieren:
# nano -w /etc/conf.d/apache2
APACHE2_OPTS="-D DEFAULT_VHOST -D PHP4 -D SSL"
(ggf. Werte ergänzen)
DocumentRoot /var/www/localhost/htdocs
(einkommentieren und ggf. andere Pfadangabe eintragen)
- Servernamen konfigurieren. Dazu die Datei /etc/conf.d/apache2 entsprechend editieren:
# nano -w /etc/apache2/httpd.conf
APACHE2_OPTS="-D PHP4 -D SSL"
- Konfiguration des Hostnames. Dazu die Datei /etc/hosts entsprechend editieren:
# nano -w /etc/hosts
127.0.0.1 myhostname
(ergänzen!) Ggf. auch in der Datei "/etc/apache2/httpd.conf" den Wert für "ServerName" konfigurieren.
- [optional] Apache zum default Runlevel hinzufügen:
# rc-update add apache2 default
Konfiguration von MySQL:
- Die Datenbank initialisieren:
# /usr/bin/mysql_install_db
- MySQL-Dienst/-Server starten:
# /etc/init.d/mysql start
- Auf MySQL-Server einloggen und root-Passwörter setzen:
# /usr/bin/mysql -u root
mysql>SET PASSWORD FOR 'root'@'localhost' = PASSWORD('your_new_password_here');
mysql>SET PASSWORD FOR 'root'@'your_hostname_or_dnsDomainName' = PASSWORD('its_new_password_here');
Nach setzen des root-Passworts kann man sich nur noch mit "# /usr/bin/mysql -u root -p" einloggen!
- [optional] Sicherheits-Script (stellt einige Fragen):
# mysql_secure_installation
- [optional] MySQL zum default Runlevel hinzufügen:
# rc-update add mysql default
Installation und Konfiguration von PHPMyAdmin:
- PHPMyAdmin in das Apache-localhost-Verzeichnis emergen:
# emerge phpmyadmin
Auswahl eines anderen Verzeichnisses mit "# /usr/sbin/webapp-config -I -h domain.tld -u root -d /phpmyadmin phpmyadmin 2.6.1_p2-r1".
- Konfiguration der MySQL-Daten von PHPMyAdmin:
# nano -w /var/www/localhost/htdocs/phpmyadmin/config.inc.php
Bei Auswahl eines anderen Verzeichnisses "# nano -w /var/www/domain.tld/htdocs/phpmyadmin/config.inc.php"!
$cfg['Servers'][$i]['host'] = 'localhost'; // MySQL hostname
$cfg['Servers'][$i]['controluser'] = ''; // MySQL control user settings (this user must have read-only
$cfg['Servers'][$i]['controlpass'] = ''; // access to the "mysql/user" and "mysql/db" tables)
$cfg['Servers'][$i]['user'] = ''; // MySQL user
$cfg['Servers'][$i]['password'] = ''; // MySQL password
- PHPMyAdmin aufrufen. In einem Browser folgende Adresse aufrufen:
http://localhost/phpmyadmin
Von anderen Rechnern: Anstelle von "localhost" die IP oder
eine andere entsprechend konfigurierte URL eingeben.
Installation und Konfiguration von Cacti:
- Cacti in das Apache-localhost-Verzeichnis emergen:
# emerge cacti
- SNMP installieren:
# emerge net-snmp
- Minimale SNMP-Konfig anlegen:
# nano -w /etc/snmp/snmpd.conf
# contact
syslocation "Zu hause unter meinem Schreibtisch"
syscontact "root@domain.tld"
# auth
rocommunity public
# disk monitoring
disk /
Ausführliche Konfigurationsdatei-Generierung mit "# snmpconf".
- SNMP starten:
# /etc/init.d/snmpd start
Die korrekte Funktionsweise kann per "# snmpwalk -v 1 -c public <IP>"
- cacti-Benutzer anlegen:
# groupadd cacti
# useradd -g cacti cacti
- Rechte für das cacti-Verzeichnis setzen:
# cd /var/www/localhost/htdocs
# chown -R cacti:cacti cacti/
Achtung: Dieser Schritt muss nach jedem cacti Reinstall/Update ausgeführt werden!
- MySQL-Datenbank hinzufügen:
# mysqladmin -u root -p create cacti
- Cacti-MySQL-Daten hinzufügen:
# mysql -u root -p cacti < /var/www/localhost/htdocs/cacti/cacti.sql
- Cacti-MySQL-Datenbank-Benutzer hinzufügen und "cacti" freigeben:
# mysql -u root -p mysql
mysql> grant all on cacti.* to cacti@localhost identified by 'Passw0rd';
mysql> flush privileges; quit;
- Cacti-Config konfigurieren:
# nano -w /var/www/localhost/htdocs/cacti/includes/config.php
$database_username = "cacti";
$database_password = "Passw0rd";
- Cronjob hinzufügen (alle 5 min):
# nano -w /etc/crontab
*/5 * * * * cacti /usr/bin/php /var/www/localhost/htdocs/cacti/poller.php > /dev/null 2>&1
- PHPMyAdmin aufrufen. In einem Browser folgende Adresse aufrufen:
http://localhost/cacti
Wenn alles richtig instelliert ist 2x "Weiter" und dann "Fertig" klicken. Login: admin, PW: admin
Erstellt am 24.10.2005 von Marcel Gehrmann
zurück zur Übersicht