SlideShare a Scribd company logo
1 of 33
Download to read offline
professional services for the web
                        consultancy design development hosting training support




Saturday, March 2, 13
Making your
                        cheap VM fly!



Saturday, March 2, 13
The slides
                        Download them here:

                        http://www.codeenigma.com/sites/default/files/field/
                        blog-uploads/vm.pdf




Saturday, March 2, 13
Getting started
                        What do you need?

                        A virtual server - you can buy one (e.g. Linode, Rackspace)
                        or you can run one on your computer (e.g. VMWare)

                        I’m using VirtualBox




Saturday, March 2, 13
Why would you do that?!



Saturday, March 2, 13
VirtualBox because...
                        One reason:

                        VAGRANT!

                        It makes setting up a VM on your computer very easy

                        http://vagrantup.com
                        http://www.vagrantbox.es




Saturday, March 2, 13
VirtualBox because...
                        Quick plug:

                        16:30

                        Room BG104

                        Vagrant: A Crash Course
                        with Marcus Deglos




Saturday, March 2, 13
Choose a base OS
                        Assuming Linux here

                        You could use Ubuntu, Redhat, Debian, Mint, blah blah blah

                        We’re using CentOS...




Saturday, March 2, 13
THAT’S IT! I’M LEAVING!!



Saturday, March 2, 13
Don’t go, here’s why...
                        I’m lazy

                        It doesn’t really matter

                        I’ll do a quick Ubuntu / Debian run through at the end

                        Please stay!




Saturday, March 2, 13
OK, let’s go...
                        To prepare, we have:

                        1. Downloaded a basic CentOS base box for Vagrant

                        2. Brought up the network interface

                        3. Installed yum-priorities

                        4. Installed nano (I know, but I hate vim!)



Saturday, March 2, 13
OK, let’s go...
                        We also installed a couple of repositories for CentOS:
                        (Note, order is important.)

                        1. EPEL
                        rpm --import https://fedoraproject.org/static/0608B895.txt

                        rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm



                        2. Remi
                        rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi

                        rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm




Saturday, March 2, 13
OK, let’s go...
                        See also this excellent HOWTO which, though modified, is
                        the basis for what I am demonstrating:

                        http://www.howtoforge.com/installing-nginx-with-php5-
                        and-php-fpm-and-mysql-support-on-centos-6.3




Saturday, March 2, 13
The database
                        At Code Enigma we use Percona, because it’s fully MySQL
                        compatible but significantly quicker.

                        Percona keep their own Linux repositories:
                        rpm --import http://www.percona.com/downloads/RPM-GPG-KEY-percona

                        rpm -ivh http://www.percona.com/downloads/percona-release/percona-
                        release-0.0-1.x86_64.rpm




Saturday, March 2, 13
The database
                        Don’t forget to assign the new Percona repo a priority!

                        Then we can install and start the database server:
                        yum install Percona-Server-client-55 Percona-Server-server-55 -y

                        service mysql start



                        Secure it and make sure it comes back after reboot:
                        mysql_secure_installation

                        chkconfig --levels 235 mysql on




Saturday, March 2, 13
The web server
                        Here we use Nginx, which is much faster than Apache but
                        there is one important thing you should know:

                        • No .htaccess files!
                        All that stuff that comes with Drupal - it needs to go in
                        your Nginx server configuration




Saturday, March 2, 13
The web server
                        Nginx is in the EPEL repository, so install away!

                        yum install nginx -y



                        Yup, that’s it!

                        Note, in CentOS the web root directory is in an odd place:

                        /usr/share/nginx/html




Saturday, March 2, 13
But what about PHP?
                        Indeed, there is no PHP ‘module’ equivalent for Nginx.

                        Instead we use PHP-FPM, a packaged version of FastCGI

                        This is available for CentOS in the ‘Remi’ repository




Saturday, March 2, 13
But what about PHP?
                        The standard set of packages needs a slight tweak:

                        DON’T use php-mysql

                        DO use php-mysqlnd instead
                        yum install php-fpm php-cli php-mysqlnd php-gd php-imap php-ldap php-odbc php-pear
                        php-xml php-xmlrpc php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql
                        php-shout php-snmp php-soap php-tidy -y




Saturday, March 2, 13
But what about PHP?
                        Then there’s APC, opcode caching for PHP
                        yum install php-pecl-apc -y



                        And finally, let’s make sure these services start!
                        chkconfig --levels 235 nginx on
                        chkconfig --levels 235 php-fpm on




Saturday, March 2, 13
Configuration time
                        With all the building blocks in place, it’s time to configure!

                        1. The firewall - let’s allow HTTP traffic:
                        /etc/sysconfig/iptables

                        -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
                        -A INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT




Saturday, March 2, 13
Configuration time
                        2. PHP configuration:
                        APC needs 128M RAM (shm_size) to be effective
                        http://2bits.com/articles/importance-tuning-apc-sites-high-number-drupal-modules.html



                        3. Nginx configuration:
                        - Drupal .htaccess file rules
                        - FastCGI configuration
                        - We have a consolidated configuration file




Saturday, March 2, 13
Configuration time
                        /etc/php.d/apc.ini


                        [...]
                        ; The size of each shared memory segment, with M/G suffixe
                        apc.shm_size=128M
                        [...]


                        /etc/nginx/nginx.conf

                        [...]
                        worker_processes 4;
                        [...]
                        keepalive_timeout 2;
                        [...]




Saturday, March 2, 13
Configuration time
                        /etc/nginx/conf.d/default.conf

                        location / {
                          root   /usr/share/nginx/html;
                          index index.php index.html index.htm;
                        }


                    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
                    #
                    location ~ .php$ {
                      root           /usr/share/nginx/html;
                      try_files $uri =404;
                      fastcgi_pass   127.0.0.1:9000;
                      fastcgi_index index.php;
                      fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                      include        fastcgi_params;
                    }




Saturday, March 2, 13
Configuration time
                    /etc/nginx/conf.d/default.conf

                    # deny access to .htaccess files, if Apache's document root
                    # concurs with nginx's one
                    #
                    location ~ /.ht {
                      deny all;
                    }




Saturday, March 2, 13
Let’s Drupal!
                        Create a database, then:
                        wget http://ftp.drupal.org/files/projects/drupal-7.20.tar.gz
                        tar -zxvf drupal-7.20.tar.gz

                        sudo mv drupal-7.20 /usr/share/nginx/
                        sudo mv /usr/share/nginx/html /usr/share/nginx/html_old
                        sudo mv /usr/share/nginx/drupal-7.20 /usr/share/nginx/html

                        sudo mkdir /usr/share/nginx/html/sites/default/files
                        sudo cp /usr/share/nginx/html/sites/default/default.settings.php /usr/share/nginx/
                        html/sites/default/settings.php




Saturday, March 2, 13
Let’s Drupal!
                        REMEMBER there are some very specific Nginx
                        configurations for Drupal:

                        http://wiki.nginx.org/Drupal




Saturday, March 2, 13
OK, but where’s Varnish?
                        Good question!

                        Less than 4GB RAM
                        Varnish does more harm than good!




Saturday, March 2, 13
Other bits
                        What about drush?

                        http://packages.codeenigma.com/debian/pool/main/

                        What about Ubuntu / Debian?

                        All of these packages are available in the ‘dotdeb’ repo:
                        http://www.dotdeb.org/
                        http://www.webhostingtalk.com/showthread.php?t=1025286




Saturday, March 2, 13
Other bits
                        Don’t forget memcached!

                        http://drupal.org/project/memcache

                        Highly recommended as a replacement cache back-end

                        Available in all ‘major’ Linux repositories

                        We usually give memcached 512M RAM



Saturday, March 2, 13
questions?



Saturday, March 2, 13
Those slides again
                        http://www.codeenigma.com/sites/default/files/field/
                        blog-uploads/vm.pdf




Saturday, March 2, 13
professional services for the web
                        consultancy design development hosting training support




Saturday, March 2, 13

More Related Content

What's hot

Nuxeo5 - Continuous Integration
Nuxeo5 - Continuous IntegrationNuxeo5 - Continuous Integration
Nuxeo5 - Continuous IntegrationPASCAL Jean Marie
 
PXEless Discovery with Foreman
PXEless Discovery with ForemanPXEless Discovery with Foreman
PXEless Discovery with ForemanStephen Benjamin
 
LSA2 - 01 Virtualization with KVM
LSA2 - 01 Virtualization with KVMLSA2 - 01 Virtualization with KVM
LSA2 - 01 Virtualization with KVMMarian Marinov
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Praguetomasbart
 
An example Hadoop Install
An example Hadoop InstallAn example Hadoop Install
An example Hadoop InstallMike Frampton
 
Modern CPUs and Caches - A Starting Point for Programmers
Modern CPUs and Caches - A Starting Point for ProgrammersModern CPUs and Caches - A Starting Point for Programmers
Modern CPUs and Caches - A Starting Point for ProgrammersYaser Zhian
 
Bpug mcollective 20140624
Bpug mcollective 20140624Bpug mcollective 20140624
Bpug mcollective 20140624Johan De Wit
 
Hadoop 2.2.0 Multi-node cluster Installation on Ubuntu
Hadoop 2.2.0 Multi-node cluster Installation on Ubuntu Hadoop 2.2.0 Multi-node cluster Installation on Ubuntu
Hadoop 2.2.0 Multi-node cluster Installation on Ubuntu 康志強 大人
 
RPM: Speed up your deploy
RPM: Speed up your deployRPM: Speed up your deploy
RPM: Speed up your deployfcrippa
 
Dockerizing WordPress
Dockerizing WordPressDockerizing WordPress
Dockerizing WordPressdotCloud
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Jian-Hong Pan
 
SiteGround Tech TeamBuilding
SiteGround Tech TeamBuildingSiteGround Tech TeamBuilding
SiteGround Tech TeamBuildingMarian Marinov
 
MAASとJujuでつくるOpenStack環境構築入門 IceHouse対応版 - OpenStack最新情報セミナー 2014年10月
MAASとJujuでつくるOpenStack環境構築入門 IceHouse対応版 - OpenStack最新情報セミナー 2014年10月MAASとJujuでつくるOpenStack環境構築入門 IceHouse対応版 - OpenStack最新情報セミナー 2014年10月
MAASとJujuでつくるOpenStack環境構築入門 IceHouse対応版 - OpenStack最新情報セミナー 2014年10月VirtualTech Japan Inc.
 
Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04SANTIAGO HERNÁNDEZ
 
LSA2 - 02 Control Groups
LSA2 - 02   Control GroupsLSA2 - 02   Control Groups
LSA2 - 02 Control GroupsMarian Marinov
 
pfSense Installation Slide
pfSense Installation SlidepfSense Installation Slide
pfSense Installation SlideSopon Tumchota
 
Lamp configuration u buntu 10.04
Lamp configuration   u buntu 10.04Lamp configuration   u buntu 10.04
Lamp configuration u buntu 10.04mikehie
 
Automatic Configuration Management for Kamailio and Asterisk in the era of Pu...
Automatic Configuration Management for Kamailio and Asterisk in the era of Pu...Automatic Configuration Management for Kamailio and Asterisk in the era of Pu...
Automatic Configuration Management for Kamailio and Asterisk in the era of Pu...Digium
 

What's hot (20)

Nuxeo5 - Continuous Integration
Nuxeo5 - Continuous IntegrationNuxeo5 - Continuous Integration
Nuxeo5 - Continuous Integration
 
PXEless Discovery with Foreman
PXEless Discovery with ForemanPXEless Discovery with Foreman
PXEless Discovery with Foreman
 
LSA2 - 01 Virtualization with KVM
LSA2 - 01 Virtualization with KVMLSA2 - 01 Virtualization with KVM
LSA2 - 01 Virtualization with KVM
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
An example Hadoop Install
An example Hadoop InstallAn example Hadoop Install
An example Hadoop Install
 
Hadoop 3.1.1 single node
Hadoop 3.1.1 single nodeHadoop 3.1.1 single node
Hadoop 3.1.1 single node
 
Modern CPUs and Caches - A Starting Point for Programmers
Modern CPUs and Caches - A Starting Point for ProgrammersModern CPUs and Caches - A Starting Point for Programmers
Modern CPUs and Caches - A Starting Point for Programmers
 
Bpug mcollective 20140624
Bpug mcollective 20140624Bpug mcollective 20140624
Bpug mcollective 20140624
 
Hadoop 2.2.0 Multi-node cluster Installation on Ubuntu
Hadoop 2.2.0 Multi-node cluster Installation on Ubuntu Hadoop 2.2.0 Multi-node cluster Installation on Ubuntu
Hadoop 2.2.0 Multi-node cluster Installation on Ubuntu
 
RPM: Speed up your deploy
RPM: Speed up your deployRPM: Speed up your deploy
RPM: Speed up your deploy
 
Dockerizing WordPress
Dockerizing WordPressDockerizing WordPress
Dockerizing WordPress
 
Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021Let's trace Linux Lernel with KGDB @ COSCUP 2021
Let's trace Linux Lernel with KGDB @ COSCUP 2021
 
SiteGround Tech TeamBuilding
SiteGround Tech TeamBuildingSiteGround Tech TeamBuilding
SiteGround Tech TeamBuilding
 
MAASとJujuでつくるOpenStack環境構築入門 IceHouse対応版 - OpenStack最新情報セミナー 2014年10月
MAASとJujuでつくるOpenStack環境構築入門 IceHouse対応版 - OpenStack最新情報セミナー 2014年10月MAASとJujuでつくるOpenStack環境構築入門 IceHouse対応版 - OpenStack最新情報セミナー 2014年10月
MAASとJujuでつくるOpenStack環境構築入門 IceHouse対応版 - OpenStack最新情報セミナー 2014年10月
 
Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04Tested install-isp config3-ubuntu-16-04
Tested install-isp config3-ubuntu-16-04
 
LSA2 - 02 Control Groups
LSA2 - 02   Control GroupsLSA2 - 02   Control Groups
LSA2 - 02 Control Groups
 
pfSense Installation Slide
pfSense Installation SlidepfSense Installation Slide
pfSense Installation Slide
 
Lamp configuration u buntu 10.04
Lamp configuration   u buntu 10.04Lamp configuration   u buntu 10.04
Lamp configuration u buntu 10.04
 
Kickstart
KickstartKickstart
Kickstart
 
Automatic Configuration Management for Kamailio and Asterisk in the era of Pu...
Automatic Configuration Management for Kamailio and Asterisk in the era of Pu...Automatic Configuration Management for Kamailio and Asterisk in the era of Pu...
Automatic Configuration Management for Kamailio and Asterisk in the era of Pu...
 

Similar to Make your cheap VM fly

Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...addame
 
Deploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTDeploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTJoshua Thijssen
 
Nginx [engine x] and you (and WordPress)
Nginx [engine x] and you (and WordPress)Nginx [engine x] and you (and WordPress)
Nginx [engine x] and you (and WordPress)Justin Foell
 
Bundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPMBundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPMAlexander Shopov
 
Using filesystem capabilities with rsync
Using filesystem capabilities with rsyncUsing filesystem capabilities with rsync
Using filesystem capabilities with rsyncHazel Smith
 
Install tomcat 5.5 in debian os and deploy war file
Install tomcat 5.5 in debian os and deploy war fileInstall tomcat 5.5 in debian os and deploy war file
Install tomcat 5.5 in debian os and deploy war fileNguyen Cao Hung
 
CloudOpen North America 2013: Vagrant & CFEngine
CloudOpen North America 2013: Vagrant & CFEngineCloudOpen North America 2013: Vagrant & CFEngine
CloudOpen North America 2013: Vagrant & CFEngineNick Anderson
 
RabbitMQ Server - cheat sheet -
RabbitMQ Server - cheat sheet -RabbitMQ Server - cheat sheet -
RabbitMQ Server - cheat sheet -Naoto MATSUMOTO
 
10 Million hits a day with WordPress using a $15 VPS
10 Million hits a day  with WordPress using a $15 VPS10 Million hits a day  with WordPress using a $15 VPS
10 Million hits a day with WordPress using a $15 VPSPaolo Tonin
 
How tos nagios - centos wiki
How tos nagios - centos wikiHow tos nagios - centos wiki
How tos nagios - centos wikishahab071
 
[MathWorks] Versioning Infrastructure
[MathWorks] Versioning Infrastructure[MathWorks] Versioning Infrastructure
[MathWorks] Versioning InfrastructurePerforce
 
Nginx as a Revers Proxy for Apache on Ubuntu
Nginx as a Revers Proxy for Apache on UbuntuNginx as a Revers Proxy for Apache on Ubuntu
Nginx as a Revers Proxy for Apache on Ubuntuabdullah roomi
 
How To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in UbuntuHow To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in UbuntuWirabumi Software
 
9 steps to install and configure postgre sql from source on linux
9 steps to install and configure postgre sql from source on linux9 steps to install and configure postgre sql from source on linux
9 steps to install and configure postgre sql from source on linuxchinkshady
 
Percona Cluster Installation with High Availability
Percona Cluster Installation with High AvailabilityPercona Cluster Installation with High Availability
Percona Cluster Installation with High AvailabilityRam Gautam
 
Java App On Digital Ocean: Deploying With Gitlab CI/CD
Java App On Digital Ocean: Deploying With Gitlab CI/CDJava App On Digital Ocean: Deploying With Gitlab CI/CD
Java App On Digital Ocean: Deploying With Gitlab CI/CDSeun Matt
 
Ruby and Rails Packaging to Production
Ruby and Rails Packaging to ProductionRuby and Rails Packaging to Production
Ruby and Rails Packaging to ProductionFabio Kung
 

Similar to Make your cheap VM fly (20)

Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
Montreal On Rails 5 : Rails deployment using : Nginx, Mongrel, Mongrel_cluste...
 
161208
161208161208
161208
 
Deploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APTDeploying and maintaining your software with RPM/APT
Deploying and maintaining your software with RPM/APT
 
Nginx [engine x] and you (and WordPress)
Nginx [engine x] and you (and WordPress)Nginx [engine x] and you (and WordPress)
Nginx [engine x] and you (and WordPress)
 
Bundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPMBundling Packages and Deploying Applications with RPM
Bundling Packages and Deploying Applications with RPM
 
Using filesystem capabilities with rsync
Using filesystem capabilities with rsyncUsing filesystem capabilities with rsync
Using filesystem capabilities with rsync
 
Install tomcat 5.5 in debian os and deploy war file
Install tomcat 5.5 in debian os and deploy war fileInstall tomcat 5.5 in debian os and deploy war file
Install tomcat 5.5 in debian os and deploy war file
 
grate techniques
grate techniquesgrate techniques
grate techniques
 
CloudOpen North America 2013: Vagrant & CFEngine
CloudOpen North America 2013: Vagrant & CFEngineCloudOpen North America 2013: Vagrant & CFEngine
CloudOpen North America 2013: Vagrant & CFEngine
 
RabbitMQ Server - cheat sheet -
RabbitMQ Server - cheat sheet -RabbitMQ Server - cheat sheet -
RabbitMQ Server - cheat sheet -
 
10 Million hits a day with WordPress using a $15 VPS
10 Million hits a day  with WordPress using a $15 VPS10 Million hits a day  with WordPress using a $15 VPS
10 Million hits a day with WordPress using a $15 VPS
 
How tos nagios - centos wiki
How tos nagios - centos wikiHow tos nagios - centos wiki
How tos nagios - centos wiki
 
[MathWorks] Versioning Infrastructure
[MathWorks] Versioning Infrastructure[MathWorks] Versioning Infrastructure
[MathWorks] Versioning Infrastructure
 
Xen time machine
Xen time machineXen time machine
Xen time machine
 
Nginx as a Revers Proxy for Apache on Ubuntu
Nginx as a Revers Proxy for Apache on UbuntuNginx as a Revers Proxy for Apache on Ubuntu
Nginx as a Revers Proxy for Apache on Ubuntu
 
How To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in UbuntuHow To Install Openbravo ERP 2.50 MP43 in Ubuntu
How To Install Openbravo ERP 2.50 MP43 in Ubuntu
 
9 steps to install and configure postgre sql from source on linux
9 steps to install and configure postgre sql from source on linux9 steps to install and configure postgre sql from source on linux
9 steps to install and configure postgre sql from source on linux
 
Percona Cluster Installation with High Availability
Percona Cluster Installation with High AvailabilityPercona Cluster Installation with High Availability
Percona Cluster Installation with High Availability
 
Java App On Digital Ocean: Deploying With Gitlab CI/CD
Java App On Digital Ocean: Deploying With Gitlab CI/CDJava App On Digital Ocean: Deploying With Gitlab CI/CD
Java App On Digital Ocean: Deploying With Gitlab CI/CD
 
Ruby and Rails Packaging to Production
Ruby and Rails Packaging to ProductionRuby and Rails Packaging to Production
Ruby and Rails Packaging to Production
 

Make your cheap VM fly

  • 1. professional services for the web consultancy design development hosting training support Saturday, March 2, 13
  • 2. Making your cheap VM fly! Saturday, March 2, 13
  • 3. The slides Download them here: http://www.codeenigma.com/sites/default/files/field/ blog-uploads/vm.pdf Saturday, March 2, 13
  • 4. Getting started What do you need? A virtual server - you can buy one (e.g. Linode, Rackspace) or you can run one on your computer (e.g. VMWare) I’m using VirtualBox Saturday, March 2, 13
  • 5. Why would you do that?! Saturday, March 2, 13
  • 6. VirtualBox because... One reason: VAGRANT! It makes setting up a VM on your computer very easy http://vagrantup.com http://www.vagrantbox.es Saturday, March 2, 13
  • 7. VirtualBox because... Quick plug: 16:30 Room BG104 Vagrant: A Crash Course with Marcus Deglos Saturday, March 2, 13
  • 8. Choose a base OS Assuming Linux here You could use Ubuntu, Redhat, Debian, Mint, blah blah blah We’re using CentOS... Saturday, March 2, 13
  • 9. THAT’S IT! I’M LEAVING!! Saturday, March 2, 13
  • 10. Don’t go, here’s why... I’m lazy It doesn’t really matter I’ll do a quick Ubuntu / Debian run through at the end Please stay! Saturday, March 2, 13
  • 11. OK, let’s go... To prepare, we have: 1. Downloaded a basic CentOS base box for Vagrant 2. Brought up the network interface 3. Installed yum-priorities 4. Installed nano (I know, but I hate vim!) Saturday, March 2, 13
  • 12. OK, let’s go... We also installed a couple of repositories for CentOS: (Note, order is important.) 1. EPEL rpm --import https://fedoraproject.org/static/0608B895.txt rpm -ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm 2. Remi rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm Saturday, March 2, 13
  • 13. OK, let’s go... See also this excellent HOWTO which, though modified, is the basis for what I am demonstrating: http://www.howtoforge.com/installing-nginx-with-php5- and-php-fpm-and-mysql-support-on-centos-6.3 Saturday, March 2, 13
  • 14. The database At Code Enigma we use Percona, because it’s fully MySQL compatible but significantly quicker. Percona keep their own Linux repositories: rpm --import http://www.percona.com/downloads/RPM-GPG-KEY-percona rpm -ivh http://www.percona.com/downloads/percona-release/percona- release-0.0-1.x86_64.rpm Saturday, March 2, 13
  • 15. The database Don’t forget to assign the new Percona repo a priority! Then we can install and start the database server: yum install Percona-Server-client-55 Percona-Server-server-55 -y service mysql start Secure it and make sure it comes back after reboot: mysql_secure_installation chkconfig --levels 235 mysql on Saturday, March 2, 13
  • 16. The web server Here we use Nginx, which is much faster than Apache but there is one important thing you should know: • No .htaccess files! All that stuff that comes with Drupal - it needs to go in your Nginx server configuration Saturday, March 2, 13
  • 17. The web server Nginx is in the EPEL repository, so install away! yum install nginx -y Yup, that’s it! Note, in CentOS the web root directory is in an odd place: /usr/share/nginx/html Saturday, March 2, 13
  • 18. But what about PHP? Indeed, there is no PHP ‘module’ equivalent for Nginx. Instead we use PHP-FPM, a packaged version of FastCGI This is available for CentOS in the ‘Remi’ repository Saturday, March 2, 13
  • 19. But what about PHP? The standard set of packages needs a slight tweak: DON’T use php-mysql DO use php-mysqlnd instead yum install php-fpm php-cli php-mysqlnd php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy -y Saturday, March 2, 13
  • 20. But what about PHP? Then there’s APC, opcode caching for PHP yum install php-pecl-apc -y And finally, let’s make sure these services start! chkconfig --levels 235 nginx on chkconfig --levels 235 php-fpm on Saturday, March 2, 13
  • 21. Configuration time With all the building blocks in place, it’s time to configure! 1. The firewall - let’s allow HTTP traffic: /etc/sysconfig/iptables -A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT -A INPUT -m state --state NEW -p tcp --dport 443 -j ACCEPT Saturday, March 2, 13
  • 22. Configuration time 2. PHP configuration: APC needs 128M RAM (shm_size) to be effective http://2bits.com/articles/importance-tuning-apc-sites-high-number-drupal-modules.html 3. Nginx configuration: - Drupal .htaccess file rules - FastCGI configuration - We have a consolidated configuration file Saturday, March 2, 13
  • 23. Configuration time /etc/php.d/apc.ini [...] ; The size of each shared memory segment, with M/G suffixe apc.shm_size=128M [...] /etc/nginx/nginx.conf [...] worker_processes 4; [...] keepalive_timeout 2; [...] Saturday, March 2, 13
  • 24. Configuration time /etc/nginx/conf.d/default.conf location / { root /usr/share/nginx/html; index index.php index.html index.htm; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # location ~ .php$ { root /usr/share/nginx/html; try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } Saturday, March 2, 13
  • 25. Configuration time /etc/nginx/conf.d/default.conf # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # location ~ /.ht { deny all; } Saturday, March 2, 13
  • 26. Let’s Drupal! Create a database, then: wget http://ftp.drupal.org/files/projects/drupal-7.20.tar.gz tar -zxvf drupal-7.20.tar.gz sudo mv drupal-7.20 /usr/share/nginx/ sudo mv /usr/share/nginx/html /usr/share/nginx/html_old sudo mv /usr/share/nginx/drupal-7.20 /usr/share/nginx/html sudo mkdir /usr/share/nginx/html/sites/default/files sudo cp /usr/share/nginx/html/sites/default/default.settings.php /usr/share/nginx/ html/sites/default/settings.php Saturday, March 2, 13
  • 27. Let’s Drupal! REMEMBER there are some very specific Nginx configurations for Drupal: http://wiki.nginx.org/Drupal Saturday, March 2, 13
  • 28. OK, but where’s Varnish? Good question! Less than 4GB RAM Varnish does more harm than good! Saturday, March 2, 13
  • 29. Other bits What about drush? http://packages.codeenigma.com/debian/pool/main/ What about Ubuntu / Debian? All of these packages are available in the ‘dotdeb’ repo: http://www.dotdeb.org/ http://www.webhostingtalk.com/showthread.php?t=1025286 Saturday, March 2, 13
  • 30. Other bits Don’t forget memcached! http://drupal.org/project/memcache Highly recommended as a replacement cache back-end Available in all ‘major’ Linux repositories We usually give memcached 512M RAM Saturday, March 2, 13
  • 32. Those slides again http://www.codeenigma.com/sites/default/files/field/ blog-uploads/vm.pdf Saturday, March 2, 13
  • 33. professional services for the web consultancy design development hosting training support Saturday, March 2, 13