declare independence from your it department sysadmin skills for symfony developers
DESCRIPTION
A Symfony/web developer is not complete without knowing server administration. When looking for a job, it is quite likely that you will be required to know about systtem administration.TRANSCRIPT
Declare Independence from your IT department
Sysadmin skills for Symfony developers
June 8, 2012 - Symfony Live ParisPablo Godel @pgodel
Friday, June 8, 2012
- Why SysAdmin Skills- Introduction to LAMP- Hosting options- Linux distributions- Installing PHP options- Deploying PHP- Various production tips- Monitoring- Backups
Agenda
Friday, June 8, 2012
Who Am I?
⁃ Born in Argentina, living in the US since 1999⁃ PHP & Symfony developer
⁃ Founder of the original PHP mailing list in spanish ⁃ Master of the parrilla
Friday, June 8, 2012
Who Am I?
⁃ Born in Argentina, living in the US since 1999⁃ PHP & Symfony developer
⁃ Founder of the original PHP mailing list in spanish ⁃ Master of the parrilla
Friday, June 8, 2012
Friday, June 8, 2012
⁃ Founded ServerGrove Networks in 2005
⁃ Provider of web hosting specialized in PHP, Symfony, ZendFramework, and others
⁃ Now with servers in Europe (and USA)
⁃ Mongohosting.com under beta!
ServerGrove!
Friday, June 8, 2012
⁃ Very active open source supporter through codecontributions and usergroups/conference sponsoring
Community is our teacher
Friday, June 8, 2012
Sysadmin Skills
Who needs them?
Friday, June 8, 2012
Text
IT is busy / Different PrioritiesFriday, June 8, 2012
!Rocket ScienceFriday, June 8, 2012
Lack of controlFriday, June 8, 2012
Less downtimeFriday, June 8, 2012
Better PerformanceFriday, June 8, 2012
What do you prefer?Friday, June 8, 2012
Or this?Friday, June 8, 2012
An example...
I s. I ’ s L. E Cs , .
Friday, June 8, 2012
LAMPWhat is
Friday, June 8, 2012
Friday, June 8, 2012
Friday, June 8, 2012
LAMPFriday, June 8, 2012
LAMPFriday, June 8, 2012
LAMPFriday, June 8, 2012
LAMP Scott Beale
Friday, June 8, 2012
LNMPFriday, June 8, 2012
LAMPFriday, June 8, 2012
LAPPFriday, June 8, 2012
LANMMPPFriday, June 8, 2012
LANMMPPWhy?
Friday, June 8, 2012
Why LANMMPP
Proven
Friday, June 8, 2012
Stable
Why LANMMPP
Friday, June 8, 2012
Secure
Why LANMMPP
Friday, June 8, 2012
Why LANMMPP
Free
Friday, June 8, 2012
Free*
Why LANMMPP
Friday, June 8, 2012
Inexpensive
Why LANMMPP
Friday, June 8, 2012
Easily Available
Why LANMMPP
Friday, June 8, 2012
Hosting Options
Friday, June 8, 2012
Hosting OptionsShared Hosting
- Inexpensive- Widely available- Easy to use- No maintenance- No updates- Instant provisioning- DNS/Email services
- Shared resources- No/Limited Shell- Many restrictions- No control- Fixed versions - Multitude of CPs
+ -
Friday, June 8, 2012
Hosting OptionsDedicated Servers
- Full control- No sharing- Best performance- Software / Hardware to specs
- Hard to plan- Software updates- SysAdmin skills- Expensive to start- Parts replacements- Control Panel licenses
+ -
Friday, June 8, 2012
Hosting OptionsVirtual Servers / VPS
- Shared resources- Software updates- SysAdmin skills- Limited/No CP- Lack of email
-
Friday, June 8, 2012
Hosting OptionsVirtual Servers / VPS
- Inexpensive- Widely available- Choice of OS- Root access- Full shell- Fast provisioning- Custom software
- Custom configurations- Snapshots- Multiple Envs
+ +
Friday, June 8, 2012
Hosting OptionsCloud Hosting
Depends on implementation
+ -
Friday, June 8, 2012
Hosting OptionsCloud Hosting
Some are a shared hosting with a fancy new name
Friday, June 8, 2012
Hosting OptionsCloud Hosting
Some are a shared hosting with a fancy new nameOthers let you start small and scale easily
Friday, June 8, 2012
Hosting OptionsCloud Hosting
Some are a shared hosting with a fancy new nameOthers let you start small and scale easilyGets really expensive at scale
Friday, June 8, 2012
Hosting OptionsCloud Hosting
Most suffer from some of the shared hosting problems:- vendor lock-in- lack of control- high learning curve- limited environment
Friday, June 8, 2012
Hosting Options
Which one to choose?
Friday, June 8, 2012
Hosting OptionsWhich one to choose?
I T D E P E N D S
Friday, June 8, 2012
Linux Distributions
Friday, June 8, 2012
DistributionsRedHat based
- Fedora- RedHat Enterprise Linux (RHEL)- CentOS- Scientific Linux
Friday, June 8, 2012
DistributionsDebian based
- Debian- Ubuntu
Friday, June 8, 2012
DistributionsOthers
- Gentoo- Slackware- OpenSuse- Archlinux- any many many more!
http://distrowatch.com/http://en.wikipedia.org/wiki/Linux_distribution
Friday, June 8, 2012
DistributionsKey differences- Configuration files- Package Manager- Managing Services- Software versions- Updates
Friday, June 8, 2012
DistributionsKey differences
- Configuration files
CentOS
Ubuntu
/etc/sysconfig/network-scripts/ifcfg-eth0
/etc/network/interfaces
Friday, June 8, 2012
DistributionsKey differences
- Package Manager
CentOS
Ubuntu
yum install php-cli
apt-get install php5
Friday, June 8, 2012
DistributionsKey differences
- Package Manager
CentOS
Ubuntu
yum search php-cli
apt-cache search php
Friday, June 8, 2012
DistributionsKey differences
- Managing Services
CentOS
Ubuntu
service restart httpdchkconfig --list httpdchkconfig httpd on
service restart apache2sudo update-rc.d apache2 enable
Friday, June 8, 2012
DistributionsKey differences
- Software versions
CentOS
Ubuntu
httpd-2.2.3
apache-2.2.17
Friday, June 8, 2012
DistributionsKey differences
- Updates
CentOS 5.x
Ubuntu 11
PHP 5.1.6
PHP 5.3.5
Friday, June 8, 2012
DistributionsKey similarities
- Based on Linux Kernel
- Screwed up or ancient PHP- Lack of PHP extensions
Friday, June 8, 2012
DistributionsWhich one to choose?
I T D E P E N D S
Friday, June 8, 2012
DistributionsWhich one to choose?
- Best feeling- Previous experience- Workplace selection- Coworker / friend knowledge
Friday, June 8, 2012
DistributionsTest Drive
Virtual Machines:
- VirtualBox- Parallels- VMware- VPS
Friday, June 8, 2012
Installing PHP
Friday, June 8, 2012
Installing PHPCentOS
yum install php php-cliyum install php-libxml
Friday, June 8, 2012
Installing PHPCentOS
Third Party Repositories- Remi RPMhttp://blog.famillecollet.com/- Webtatichttp://www.webtatic.com/- ServerGrove: PHP 5.3.13 / 5.4.3 (always latest)http://repos.servergrove.com
Friday, June 8, 2012
Installing PHPCentOS
Third Party Repositories
cd /etc/yum.repos.d/wget http://repos.servergrove.com/servergrove-centos-5/servergrove-centos-5.repoyum install php53 # or php54
Friday, June 8, 2012
Installing PHPUbuntu
apt-get install php5 libapache2-mod-php5apt-get install php5-libxml
Friday, June 8, 2012
Installing PHPUbuntu
Third Party Repositories
- Dotdeb:http://www.dotdeb.org/- ServerGrove: (always latest)http://repos.servergrove.com
PHP 5.3.13 / 5.4.3
Friday, June 8, 2012
Installing PHPUbuntu
Third Party Repositories
echo “deb http://repos.servergrove.com/servergrove-ubuntu-natty natty main” >> /etc/apt/sources.list.d/servergrove.listapt-get install php53 # or php54
Friday, June 8, 2012
Installing PHPFrom Source
wget http://us2.php.net/get/php-5.4.3.tar.bz2/from/www.php.net/mirrortar jxvf php-5.4.3.tar.bz2cd php-5.4.3./configure make && make install
Friday, June 8, 2012
Installing PHPRecompiling
php -i |grep configure./configure '--with-apxs2=/usr/sbin/apxs' '--prefix=/usr/local/php53' '--with-config-file-scan-dir=/etc/php53/conf.d' '--enable-bcmath' '--enable-ctype' '--enable-exif' '--enable-mbstring' '--enable-ftp' '--enable-intl' '--enable-sockets' '--enable-sysvmsg' '--enable-pcntl' '--with-bz2' '--with-curl' '--with-gettext' '--with-gd' '--enable-gd-native-ttf' '--enable-exif' '--with-freetype-dir=/usr' '--with-jpeg-dir=/usr' '--with-t1lib=/usr' '--with-mcrypt' '--with-openssl' '--with-kerberos' '--with-iconv' '--with-xsl' '--with-xmlrpc' '--with-zlib' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-pdo-mysql=mysqlnd'make && make install
Friday, June 8, 2012
Installing PHPCompiling for Apache
./configure '--with-apxs2=/usr/sbin/apxs' make && make install
Friday, June 8, 2012
Installing PHPCompiling for Nginx / PHP-FPM
./configure '--enable-fpm' make && make install
Friday, June 8, 2012
Installing PHPCompiling extension
./configure --with-curl --enable-ftpmake && make install
Friday, June 8, 2012
Installing PHPCompiling extension
(dynamic)
cd ext/curlphpize./configure make && make installecho “extension=curl.so” >> php.ini
Friday, June 8, 2012
Installing PHPCompiling extension
http://pecl.php.net/
Friday, June 8, 2012
Installing PHPCompiling extension
(PECL)pecl install apc# orpecl download apctar zxvf APC-3.1.9.tgzcd APC-3.19phpize./configure make && make installecho “extension=apc.so” >> php.ini
Friday, June 8, 2012
Automate!
- Chef- Puppet- ...
Installing PHP
Friday, June 8, 2012
Installing PHPConfiguration
/etc/php/php.ini/etc/php5/cli/php.ini
/usr/local/lib/php.ini
Default location
Other common locations
/etc/php5/apache2/php.ini
Friday, June 8, 2012
Installing PHPConfiguration
php -i | grep php.iniConfiguration File (php.ini) Path => /usr/local/php5/libLoaded Configuration File => /usr/local/php5-20110426-093151/lib/php.iniScan this dir for additional .ini files => /usr/local/php5/php.dAdditional .ini files parsed => /usr/local/php5/php.d/10-extension_dir.ini,
Friday, June 8, 2012
Installing PHPConfiguration
php -i | grep mongo/usr/local/php5/php.d/50-extension-mongo.ini,mongomongo.allow_empty_keys => 0 => 0mongo.allow_persistent => 1 => 1mongo.auto_reconnect => 1 => 1mongo.chunk_size => 262144 => 262144mongo.cmd => $ => $mongo.default_host => localhost => localhostmongo.default_port => 27017 => 27017
Friday, June 8, 2012
Installing PHPConfiguration
[PHP Modules]apcbcmathbz2Corectypecurldatedomereg
php -m
Friday, June 8, 2012
Installing PHPConfiguration
php.iniextension_dir=/usr/lib/php/extensions/no-debug-non-zts-20090626
extension=apc.soextension=mongo.so
Friday, June 8, 2012
Installing PHPConfiguration
php.ini
php -i | grep extension_dirextension_dir => /usr/local/php5/lib/php/extensions/no-debug-non-zts-20090626
Friday, June 8, 2012
Installing PHPConfiguration
php.ini
date.timezone=UTCdisplay_errors = offlog_errors = onerror_log = /var/log/php.log
Friday, June 8, 2012
Installing PHPConfiguration
Securitymemory_limit = 128Mmax_execution_time = 30display_errors = offexpose_php = offmail.log = /var/log/phpmails.logdisable_functions = execallow_url_fopen = off
Friday, June 8, 2012
Installing PHPConfiguration
File uploads on .htaccessphp_value memory_limit 128Mphp_value max_file_uploads 20php_value max_input_time -1php_value post_max_size 8Mphp_value upload_max_filesize 2Mphp_value max_execution_time 0
AllowOverride=All in Apache!Friday, June 8, 2012
Installing PHPConfiguration
Apache
php_value date.timezone UTCphp_flag display_errors 1php_value memory_limit 128Mphp_value max_execution_time 0
Donʼt forget to restart ApacheFriday, June 8, 2012
Installing PHPWeb Server User
- apache- nobody- www-data- ftp / ssh user (sometimes)
Possible users
Permissions issues with clear cache and uploads, Anyone?
Friday, June 8, 2012
Installing PHPWeb Server User
Fix:
Permissions issues with clear cache and uploads, Anyone?
rm -rf app/cache/*rm -rf app/logs/*
sudo chmod +a "www-data allow delete,write,append,file_inherit,directory_inherit" app/cache app/logssudo chmod +a "`whoami` allow delete,write,append,file_inherit,directory_inherit" app/cache app/logs
http://symfony.com/doc/current/book/installation.html
Friday, June 8, 2012
Deploying PHP
Friday, June 8, 2012
Deploying PHPBefore going live
Make sure ntpd is installed and running to ensure accurate server time
yum install ntpchkconfig ntpd onntpdate pool.ntp.org
Friday, June 8, 2012
Deploying PHPBefore going live
- Limit access by IP
<Location /admin> Order Deny,Allow Deny from all Allow from 1.2.3.4</Location>
Friday, June 8, 2012
Deploying PHPBefore going live
- Add HTTP Authentication
<Location /admin> Require valid-user AuthType Basic AuthName "SG" AuthUserFile /path/users</Location>
Friday, June 8, 2012
Deploying PHPBefore going live
- Quiet down Apache
ServerTokens Prod
Friday, June 8, 2012
Deploying PHPBefore going live
RewriteEngine On
RewriteRule ^\.htaccess$ - [F]
RewriteCond %{REQUEST_FILENAME} -fRewriteRule ^.*$ - [NC,L]
RewriteCond %{REQUEST_URI} !^/web/.*$RewriteRule ^(.*)$ /web/$1
Move document root with .htaccess
Friday, June 8, 2012
Deploying PHPBefore going live
- Case senstive filesystem
IPCheck_Form_Index_Login != IpCheck_Form_Index_Login
/path/to/file/IpCheck_Form_Index_Login.php<?php class IPCheck_Form_Index_Login {...
Friday, June 8, 2012
Deploying PHP- server-side vi- plain old FTP- SFTP- scp- rsync + ssh- git- tar / gzip- rpm / deb packages- capistrano / capifony
Friday, June 8, 2012
Deploying PHP- server-side vi- plain old FTP- SFTP- scp- rsync + ssh- git- tar / gzip- rpm / deb packages- capistrano / capifony
Friday, June 8, 2012
Deploying PHPEffing Package Management
https://github.com/jordansissel/fpm
Build packages for multiple platforms (deb, rpm, etc) with great ease and sanity.
fpm -s dir -t rpm -n "sfapp" -v 1.0 /var/www/sfapp
fpm -s dir -t deb -a all -n sfapp -v 1.0 /etc/apache2/conf.d/my.conf /var/www/sfapp
Friday, June 8, 2012
Deploying PHPCapifony
- multiple servers- multiple environments- setup shared folders (vendors, cache, logs, etc)- copy files- update vendors- multi versions- rollback- restart apache
Friday, June 8, 2012
Deploying PHP
Automate!
Friday, June 8, 2012
DNS TipsThe Power of the hosts file
Friday, June 8, 2012
DNS Tips
/etc/hosts
10.0.1.1 www.lottery.com
The Power of the hosts file
Friday, June 8, 2012
DNS Tips
/etc/hosts
10.0.1.1 example1.com example2.com
The Power of the hosts file
Friday, June 8, 2012
DNS TipsVirtual Document Root
UseCanonicalName Off
VirtualDocumentRoot /var/www/vhosts/%0/web
<Location /var/www/vhosts> AllowOverride All Options +FollowSymLinks</Location>
example.com => /var/www/vhosts/example.com/webexample2.com => /var/www/vhosts/example2.com/web
Friday, June 8, 2012
DNS TipsNameservers/Expiration
whois servergrove.com...Name Servers: ns1.servergrove.com ns2.servergrove.com ns3.servergrove.com
Creation date: 19 May 2005 23:34:36Expiration date: 19 May 2014 23:34:00
Friday, June 8, 2012
DNS TipsDNS records
dig -t A google.com;; ANSWER SECTION:google.com. 184 IN A 74.125.230.227google.com. 184 IN A 74.125.230.228google.com. 184 IN A 74.125.230.229google.com. 184 IN A 74.125.230.230google.com. 184 IN A 74.125.230.231google.com. 184 IN A 74.125.230.232google.com. 184 IN A 74.125.230.233google.com. 184 IN A 74.125.230.238google.com. 184 IN A 74.125.230.224google.com. 184 IN A 74.125.230.225google.com. 184 IN A 74.125.230.226
Friday, June 8, 2012
DNS TipsDNS records
dig -t A servergrove.eu @ns1.servergrove.com;; ANSWER SECTION:servergrove.eu. 3600 IN A 149.5.47.100
Friday, June 8, 2012
DNS Tipstraceroute
traceroute google.com
traceroute to google.com (173.194.37.33), 30 hops max, 40 byte packets 1 2.69-195-222.static.servergrove.com (69.195.222.2) 0.360 ms 0.365 ms 0.432 ms 2 t0-1-0-5.br2.mia.terremark.net (66.165.161.45) 1.558 ms 1.546 ms 1.532 ms 3 core1-1-0-0.mia.net.google.com (198.32.124.133) 0.238 ms 0.224 ms 0.230 ms 4 209.85.253.74 (209.85.253.74) 0.266 ms 0.283 ms 0.312 ms 5 209.85.254.252 (209.85.254.252) 12.764 ms 12.757 ms 12.749 ms 6 64.233.175.92 (64.233.175.92) 14.177 ms 14.257 ms 14.359 ms 7 atl14s07-in-f1.1e100.net (173.194.37.33) 13.653 ms 13.606 ms 13.618 ms
Friday, June 8, 2012
DNS Tipsmtr
Friday, June 8, 2012
Monitoring
Friday, June 8, 2012
Monitoring
<Location /server-status> SetHandler server-status Order deny,allow Deny from all Allow from .your_domain.com</Location>
ExtendedStatus On
Apache Requests
Friday, June 8, 2012
MonitoringApache Requests
Friday, June 8, 2012
Monitoring
- Cacti- Ganglia- Zabbix- collectd- statsd / StatsDBundle- graphite
Friday, June 8, 2012
Monitoringstatsd / StatsDBundle / Graphite
Friday, June 8, 2012
MonitoringCPU / Memory / IO
top
Friday, June 8, 2012
MonitoringIO
iotop
Friday, June 8, 2012
MonitoringNetwork
iptraf
Friday, June 8, 2012
MonitoringHandling logs
- Centralize logs with syslog
error_log = syslog
- Monolog supports syslog- logstash, logster, loggly, logio
Friday, June 8, 2012
Speeding up
Friday, June 8, 2012
Speeding up
- nginx/php-fpm- APC- Memcache- nginx reverse proxy cache- Varnish
Friday, June 8, 2012
Backups
Friday, June 8, 2012
Backups
- rsync- rdiff-backup- Unison- Bacula- Amanda
Friday, June 8, 2012
Backups
Donʼt forget to backup your DB!
Friday, June 8, 2012
Reading List
- Automating UNIX and Linux Administration- Running Linux - Learning the bash Shell: Unix Shell Programming
Friday, June 8, 2012
The End
Questions?Sysadmin skills for Symfony developers
Friday, June 8, 2012
Thank you!
Sysadmin skills for Symfony developers
https://joind.in/6605
Pablo Godel @pgodel
Feedback Please!
Friday, June 8, 2012