advanced web hosting

42

Upload: ovh

Post on 15-Apr-2017

951 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: Advanced Web Hosting
Page 2: Advanced Web Hosting

AdvancedWeb hosting

Vincent Cassé @vcasse

Webhosting lead techOVH

Page 3: Advanced Web Hosting

Our offers

Perso

- 5 websites- 100 Gb disk

- 1 x 200 Mb db- Anti DDOS

Kimsufi

- 1 website- 1 Gb disk

- 1 x 100 Mb db- Anti DDOS

Pro

- 10 websites- 250 Gb disk

- 3 x 400 Mb db1 x 2Gb db

- Anti DDOS- SSH access

Performance

- ∞ websites- 500 Gb disk

- 3 x 800 Mb db1 x 4 Gb db

- 1 privateSql- SSH access- dedicated

Page 4: Advanced Web Hosting

A small application to deploy

https://rondcoin.ovh

Page 5: Advanced Web Hosting

Laravel

- Framework PHP to don’t reinvent the wheel- Use a lot of existing PHP library and composer- Just few hours to develop the “rond coin” app- https://github.com/ovh/summit2016-webhosting-example-rondcoin

Page 6: Advanced Web Hosting

How to deploy this application?

Page 7: Advanced Web Hosting

Order a web hosting

Page 8: Advanced Web Hosting

FTP?

Page 9: Advanced Web Hosting

SSH

­ From “pro” offer­ PHP cli and Git installed­ https://github.com/ovh/webhosting­ssh­bashrc

Page 10: Advanced Web Hosting

Deploy the code by SSH

$ ssh [email protected]:Welcome to [email protected] (fpm/5.6/prod/legacy) ~ $ git clone https://github.com/ovh/summit2016­webhosting­example­rondcoin.gitCloning into summit2016­webhosting­example­rondcoin...remote: Counting objects: 133, done.remote: Compressing objects: 100% (99/99), done.remote: Total 133 (delta 19), reused 133 (delta 19), pack­reused 0Receiving objects: 100% (133/133), 153.26 KiB, done.Resolving deltas: 100% (19/19), done.

 

Page 11: Advanced Web Hosting

Deploy the code: get composer

$ php ­r "copy('https://getcomposer.org/installer', 'composer­setup.php');"$ php ­r "if (hash_file('SHA384', 'composer­setup.php') === 'e115a8dc7871f15d853148a7fbac7da27d6c0030b848d9b3dc09e2a0388afed865e6a3d6b3c0fad45c48e2b5fc1196ae') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer­setup.php'); } echo PHP_EOL;"$ php composer­setup.php$ php ­r "unlink('composer­setup.php');"

 

Page 12: Advanced Web Hosting

Deploy the code: install libraries

$ php composer.phar install$ cp .env.example .env$ php artisan key:generate

 

Page 13: Advanced Web Hosting

What is multisite?

- Link multiple domains or subdomains- For tech: like add a virtualhost- No isolation

Page 14: Advanced Web Hosting

Laravel structure

.envapi/app/artisanassets/bootstrap/composer.jsonconfig/database/public/resources/routes/storage/tests/vendor/

Page 15: Advanced Web Hosting

Edit the ‘rondcoin.ovh’ multisite

Page 16: Advanced Web Hosting

What about the database?

Page 17: Advanced Web Hosting

Get the private SQL

­ Better max_connexions­ No neighbors issues­ Dedicated resources (CPU / RAM)­ For performance offer: 1 privateSQL included

Page 18: Advanced Web Hosting

Activate the privateSQL

Page 19: Advanced Web Hosting

Create the user and database

Page 20: Advanced Web Hosting

Create the user and database

Page 21: Advanced Web Hosting

Update laravel

$ vim .env…DB_CONNECTION=mysqlDB_HOST=your_db_hostDB_PORT=your_db_portDB_DATABASE=your_db_nameDB_USERNAME=your_db_userDB_PASSWORD=your_db_password…

$ php artisan migrate

 

Page 22: Advanced Web Hosting

Rondcoin.ovh is up!

Page 23: Advanced Web Hosting

Deploy theAPI

Page 24: Advanced Web Hosting

API?

Page 25: Advanced Web Hosting

Laravel: add a new endpoint

$ ls -al public/.htaccesscss/favicon.icofonts/index.phpjs/robots.txtupload/

$ ls -al api/.htaccessindex.php

Page 26: Advanced Web Hosting

Add a multisite

Page 27: Advanced Web Hosting

API is ready!

https://api.rondcoin.ovh/api/offer

Page 28: Advanced Web Hosting

Add aCDN

Page 29: Advanced Web Hosting

Content Delivery Network

- Store your static content all around the world- Images / JS / CSS load fastest- Included into ‘performance’ offer

Page 30: Advanced Web Hosting

Activate your CDN

Page 31: Advanced Web Hosting

Create a ‘assets’ multisite

Page 32: Advanced Web Hosting

Activate cache on static content

$ vim public/.htaccess...# Cache des images durant 1 mois<FilesMatch "\.(jpg|jpeg|png|gif)$">Header set Cache­Control "max­age=2592000, public"</FilesMatch>

# Cache des javascript et CSS durant 1 mois<FilesMatch "\.(js|css)$">Header set Cache­Control "max­age=2592000, public"

Page 33: Advanced Web Hosting

Update laravel template

$ vim resources/views/layout/app.blade.php… <!­­ Styles ­­><link href="http://assets.rondcoin.ovh/css/app.css" rel="stylesheet">

… <!­­ Scripts →<script src="http://assets.rondcoin.ovh/js/app.js"></script>

Page 34: Advanced Web Hosting

Environmentconfiguration

Page 35: Advanced Web Hosting

Change your PHP

https://www.ovh.com/fr/a1948.php7-nouveautes-deja-le-moment-migrer

Page 36: Advanced Web Hosting

Update the .ovhconfig

$ vim ~/.ovhconfig; pour plus d'informations sur ce fichier:; http://www.ovh.com/fr/g1175.format_du_point_ovhconfig

app.engine=phpapp.engine.version=7.1

http.firewall=noneenvironment=productioncontainer.image=stable

 

Page 37: Advanced Web Hosting

RAMcache

Page 38: Advanced Web Hosting

Architecture

Webserver

privateSQL

Webserver

Filer

Page 39: Advanced Web Hosting

Store cache in /tmp

- /tmp is mount in RAM- Reduce latency to get data from filerzs- Can divide by two the load of the webpage

Page 40: Advanced Web Hosting

Store laravel cache in /tmp

$ vim config/cache.php…'file' => [       'driver' => 'file',       'path' => '/tmp',],

$ vim config/session.php…'files' => '/tmp',

$ vim config/view.php…'compiled' => '/tmp',

Page 41: Advanced Web Hosting

Another tips

- Use “cron” for asynchronous tasks- You can see all your logs in logs.clusterXXX.hosting.ovh.net- Use “boost” if you have previsible load peaks- Check external connexions from PHP (APIs like twitter...)

Page 42: Advanced Web Hosting

Vincent Cassé

@vcasse