User:Tobiasco/server
terminal
- w:grep (filtering)
- w:apache
- start: /usr/sbin/httpd2
- stop: kill -TERM `cat /var/run/httpd2.pid`
- restart: /etc/init.d/apache2 restart
- show servers, hosts: httpd2 -S
- q (quit)
- cd
- mv <filename1> <filename2> (move)
- cp (copy)
- find -name
- ls -la | grep <something>
- vi
- ps , ps -e (show processes)
- grep video.tango.info access.log | wc
- grep ist ein suchprogragm. fuettern mit textfile, (hier access.log) suchen nach regex (hier video.tango.info) , pipe output an naechstes programm wc
vi
- help, i (insert mode), hjkl (curser move in non insert mode), w (write),
- a (insert append mode)
- $ (go to line end)
- A (line end append)
hardware
cat /proc/cpuinfo cat /proc/meminfo hdparm -i fdisk -l
paper notes
- CTRL C zum abrechen eines befehls
- top -> prozesse zeigen (geht bei mir nicht)
- ps prozesse vom terminal
- ps -ef komplette liste
- siehe auch "man ps"
- in liste pts/0 erster terminaluser, pts/1 ggf zweiter
- pwd wo bin ich
- man bzip2
- tar -cf einname /home
- gzip einname
- ls -la = listing zeigen
- sftp subdomain.example.com
- cd/
- get einname.gz
- exit
- gunzip einname.gz
- mv einname /
time
http://www.debian.org/doc/manuals/system-administrator/ch-sysadmin-time.html
date --set 1998-11-02 date --set 21:08:0
change server timezone:
dpkg-reconfigure tzdata
ntp
http://ntp.isc.org/bin/view/Servers/NTPPoolServers
...For this reason, you should make sure that your libc6 package is kept reasonably up to date. This package, from Debian GNU/Linux 2.2 onwards, contains the timezone data.
/etc/ntp.conf
logfile /var/log/xntpd driftfile /var/lib/ntp/ntp.drift statsdir /var/log/ntpstats/ statistics loopstats peerstats clockstats filegen loopstats file loopstats type day enable filegen peerstats file peerstats type day enable filegen clockstats file clockstats type day enable server ntp.somedomain.something server ntp.something.else
server 0.de.pool.ntp.org server 1.de.pool.ntp.org server 2.de.pool.ntp.org
apache
- /etc/apache2/vhosts
- copy vhost.template
- save as myown.conf
- /etc/apache2/conf.d
- add mod rewrite like the others that are allready there
- /etc/sysconfig/ - belongs to suse, written by yast. better not touch, could be overwritten
- sites and modules: http://www.debian-administration.org/articles/207
- a2enmod rewrite ssl php5.1
- mod_rewrite: http://www.debian-administration.org/articles/136
- a2enmod rewrite ssl php5.1
httpd.config
add own config in (/etc/apache2/httpd.conf.local) putting its name into APACHE_CONF_INCLUDE_FILES in /etc/sysconfig/apache2
or /etc/sysconfig/apache2 e.g.
"/etc/apache2/my_conf/" "/etc/apache2/virtual_hosts/*.conf" "local/*.conf /srv/www/virtual/"
APACHE_CONF_INCLUDE_DIRS=""
modules
- vhosts.d
mod_rewrite
/etc/apache2/sysconfig.d/loadmodule.conf (look whether loaded)
LoadModule rewrite_module /usr/lib/apache2-prefork/mod_rewrite.so
if line not exists in loadmodule.conf then /etc/sysconfig/apache2, search variable APACHE_MODULES and add "rewrite"
APACHE_MODULES="access actions alias auth auth_dbm autoindex cgi dir env expires include log_config mime negotiation setenvif ssl suexec userdir php4 rewrite"
- httpd.include (may have vhost settings)
- http://forum.mamboserver.com/archive/index.php/t-24040.html
- http://lists.netfielders.de/pipermail/typo3-project-civserv/2005-October/000037.html
PHP
apt-get install php5.1
- additional: libapache2-mod-php5.1 php5.1-common
- suggest: php-pear php5.1-curl php5.1-exif php5.1-ftp php5.1-gd php5.1-gettext php5.1-mysql php5.1-sqlite
- recommended: php5.1-session php5.1-cli php5.1-cgi
- found myself: php5-mbstring
mysql
http://dev.mysql.com/doc/refman/4.1/en/unix-post-installation.html
mysql_install_db mysqld_safe & bg (restart order in background) /usr/bin/mysqladmin -u root passwd <password>
mysql -u root -p /etc/init.d/mysql restart|start|stop
#:mysql -p(asuserroot) Enterpassword:<enterwithoutpassword> mysql> use mysql; mysql> delete from userwhere User= ; mysql> delete from dbwhere User= ; mysql> update usersetPassword= Password('some_passwd')where User='root'; mysql> flushprivileges; mysql> exit;
show databases; use <dbname>; source ./dump.sql
ctrl+c=termianal run stop
http://dev.mysql.com/doc/refman/5.0/en/default-privileges.html shell> mysql -u root mysql> SET PASSWORD FOR @'localhost' = PASSWORD('newpwd');
slow log
/var/lib/mysql/......-slow.log
Load Backups
mysql -p mysql> source ./backup20060524.sql
utf8
mysql> show variables like '%character%';
http://www.fngtps.com/2007/02/ruby-and-mysql-encoding-flakiness
"/etc/mysql/my.cnf"
[client] default-character-set = utf8 [mysqld] character_set_server = utf8
set global character_set_client=utf8; set global character_set_connection=utf8; set global character_set_results=utf8; set global character_set_server=utf8; set global collation_connection=utf8_general_ci; set global collation_server=utf8_general_ci;
mail von Hauke
Folgendes habe ich am mysql-Server rum manipuliert: In der Unix-Shell: mysqladmin -u root -p shutdown mysqld_safe --user=root --log-slow-queries --log & mysql -p Dann in mysql: set global long_query_time=1; exit Dann kann man sich in der Unix-Shell wieder die Ergebnisse ansehen: more ./var/lib/mysql/h814862-slow.log mysqladmin -p variables Jetzt werden in der log-Datei alle mysql-Befehle protokolliert, die länger als 1 Sekunde benötigen. Generell müssen wir noch daran denken, das gigantisch werdende log-File ./var/lib/mysql/h814862.log gelegentlich zu löschen. (Dort werden alle mysql-Befehle mitprotokolliert, um theoretisch backups machen zu können.) Bei mir auf dem Rechner zuhause gibt es auch für die hmap mysql Befehle, die gelegentlich länger dauern, aber auf dem virtual host taucht die hmap bisher nicht auf. Da gibt es von Dir noch ein paar Befehle die so um die 3 Sekunden dauern. Aber jetzt können wir diese indentifizieren!
ftp
ftp open example.org get <filename> put mget mput
exim
- dpkg-reconfigure exim4-config
- select options with key up+down
- Internet Server - Mail gets sent and received directly over SMTP
logs
- 1995-07 http://www.w3.org/Daemon/User/Config/Logging.html#common_logfile_format
- http://www.w3.org/TR/WD-logfile.html
- awstats
# LogFormat = 1 # LogFormat = "%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot" %host Client hostname or IP address (or Sender host for mail log) %other Means another field %logname Authenticated login/user with format: alex %time1 Date and time with format: [dd/mon/yyyy:hh:mm:ss +0000] or [dd/mon/yyyy:hh:mm:ss] %time2 Date and time with format: yyyy-mm-dd hh-mm-ss %time3 Date and time with format: Mon dd hh:mm:ss or Mon dd hh:mm:ss yyyy %time4 Date and time with unix timestamp format: dddddddddd %methodurl Method and URL with format: "GET /index.html HTTP/x.x" %code Return code status (with format for web log: 999) %bytesd Size of document in bytes %refererquot Referer page with format: "http://from.com/from.htm" %uaquot User agent with format: "Mozilla/4.0 (compatible, ...)"
Common Log Format (CLF) "%h %l %u %t \"%r\" %>s %b" Common Log Format with Virtual Host "%v %h %l %u %t \"%r\" %>s %b" NCSA extended/combined log format "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" Referer log format "%{Referer}i -> %U" Agent (Browser) log format "%{User-agent}i"
%...h Remote host %...l Remote logname (from identd, if supplied). This will return a dash unless IdentityCheck is set On. %...u Remote user (from auth; may be bogus if return status (%s) is 401) %...t Time the request was received (standard english format) %...{format}t The time, in the form given by format, which should be in strftime(3) format. (potentially localized) %...r First line of request %...b Size of response in bytes, excluding HTTP headers. In CLF format, i.e. a '-' rather than a 0 when no bytes are sent. %...{Foobar}i The contents of Foobar: header line(s) in the request sent to the server. %...v The canonical ServerName of the server serving the request. %...s Status. For requests that got internally redirected, this is the status of the *original* request --- %...>s for the last.
- t.i old
%v %l %u %t \"%r\" %>s %b