Slide 1

Slide 1 text

Use PaaS service to host your web - with pagodabox Fundamental PHP & Web Development ! lecturer : Lucien Lee 李柏緯 Lecture 10

Slide 2

Slide 2 text

! Cloud Computing

Slide 3

Slide 3 text

Cloud Computing

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Paas •Provide API to deploy your service •You don’t set up a really remote environment. • Just use platform and set configuration. •Pay on demand

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

No content

Slide 8

Slide 8 text

Basic outline 1. Register With Pagoda Box 2. Create Your Application 3. Set Up Git 4. Create Your SSH Key 5. Deploy Your Code 6. Set Your Domain

Slide 9

Slide 9 text

Sign up

Slide 10

Slide 10 text

Create new app

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

? Git

Slide 13

Slide 13 text

Git

Slide 14

Slide 14 text

Why version control •Reversibility •Concurrency •History

Slide 15

Slide 15 text

Example

Slide 16

Slide 16 text

Git for Windows

Slide 17

Slide 17 text

Set Up SSH Keys 1. cd ~/.ssh 2. ssh-keygen -t rsa -C "[email protected]" 3. cat ~/.ssh/id_rsa.pub 4. copy and paste

Slide 18

Slide 18 text

Paste to Pagoda Box Account Settings

Slide 19

Slide 19 text

There is a GUI method

Slide 20

Slide 20 text

There is a GUI method

Slide 21

Slide 21 text

There is a GUI method

Slide 22

Slide 22 text

There is a GUI method

Slide 23

Slide 23 text

Some commands your need

Slide 24

Slide 24 text

git init initial to use git

Slide 25

Slide 25 text

git remote add pagoda SET REMOTE ADDRESS!

Slide 26

Slide 26 text

git push pagoda master DEPLOY!

Slide 27

Slide 27 text

Set environment configuring your app for Pagoda Box

Slide 28

Slide 28 text

BoxFile web1: name: albumapp shared_writable_dirs: [photo, thumbnail] php_date_timezone: Asia/Taipei php_extensions: [mysql, gd] php_file_uploads: "1" db1: name: albumdb type: mysql

Slide 29

Slide 29 text

? How to connect DB

Slide 30

Slide 30 text

Environment variables $link = mysql_connect( $_SERVER['DB1_HOST'], $_SERVER['DB1_USER'], $_SERVER[‘DB1_PASS'] );

Slide 31

Slide 31 text

Simple Case create Table in php file

Slide 32

Slide 32 text

Copy sql and query $sql_album = "CREATE TABLE IF NOT EXISTS `Album` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(128) NOT NULL, `Owner` varchar(32) NOT NULL, `Timestamp` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=6 ;"; ! mysql_query($sql_album);

Slide 33

Slide 33 text

Copy sql and query $sql_photo = "CREATE TABLE IF NOT EXISTS `Photo` ( `ID` int(11) NOT NULL AUTO_INCREMENT, `Name` varchar(128) NOT NULL, `Filename` varchar(64) NOT NULL, `Comment` text, `AlbumID` int(11) DEFAULT NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=25 ;"; ! mysql_query($sql_photo);

Slide 34

Slide 34 text

Copy sql and query $sql_user ="CREATE TABLE IF NOT EXISTS `User` ( `Account` varchar(32) NOT NULL, `Password` varchar(32) NOT NULL, `Name` varchar(32) NOT NULL, PRIMARY KEY (`Account`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;"; ! mysql_query($sql_user);

Slide 35

Slide 35 text

HOW TO MANAGE DB •You can use phpmyadmin too •Connect DB by tunnel.

Slide 36

Slide 36 text

… Go further, learn more

Slide 37

Slide 37 text

Security issue how to defense with cracker attack?

Slide 38

Slide 38 text

Use PDO to link DB Better way to connect DB

Slide 39

Slide 39 text

Try some Framework cakePHP, condeignIter, ZEND, YII…

Slide 40

Slide 40 text

Login with other sites Facebook, google, twitter…

Slide 41

Slide 41 text

Thank you guys!