Chapter 1: Preparing your Work Environment 7
Setting up a terminal emulator 7
Finding and downloading PuTTY 8
Creating a session 8
Working with PuTTY and the shell 10
Basic shell commands 11
File and directory management 11
User and group management 15
Superuser account 15
User accounts 15
Group management 17
Programs and processes 18
Starting an application 18
System services 19
Process management 20
Discovering the Linux filesystem 22
Directory structure 22
Special files and devices 25
Device types 25
Pseudo devices 26
Mounting a storage device 27
Files and inodes 28
EXT3 filesystem specifications 29
Filenames 29
Inodes 29
Atime, ctime, and mtime 30
Symbolic and hard links 31
File manipulation 32
Reading a file 33
Table of Contents
Editing a file 34
Compression and archiving 35
System administration tools 37
Running a command as Superuser 37
Su command 37
Sudo command 38
System verification and maintenance 39
Disk Free 39
Disk Usage 39
Free memory 40
Software packages 40
Package managers 40
Downloading and installing packages manually 41
Building from source 42
Files and permissions 43
Understanding file permissions 43
Directory permissions 43
Octal representation 44
Changing permissions 44
Changing ownership and group 45
Summary 46
Chapter 2: Downloading and Installing Nginx 47
Setting up the prerequisites
GCC — GNU Compiler Collection
PCRE library
zlib library
OpenSSL
Downloading Nginx
Websites and resources
Version branches
Features
Downloading and extracting
Configure options
The easy way
Path options
Prerequisites options
Module options Modules enabled by default
Modules disabled by default
Miscellaneous options
Configuration examples About the prefix switch
Regular HTTP and HTTPS servers
All modules enabled
47
48
49
50
50
51
51
52
53
54
55
55
56
58
59
59
60
61
62
63
63
64
[ ii ]
Table of Contents
Mail server proxy 64
Build configuration issues 65
Make sure you installed the prerequisites 65
Directories exist and are writable 65
Compiling and installing 66
Controlling the Nginx service 67
Daemons and services 67
User and group 68
Nginx command-line switches 68
Starting and stopping the daemon 69
Testing the configuration 69
Other switches 70
Adding Nginx as a system service 71
System V scripts 71
What is an init script? 73
Creating an init script for Nginx 73
Installing the script 75
Debian-based distributions 76
Red Hat-based distributions 76
Other miscellaneous modules 187
Stub status 187
Google-perftools 187
WebDAV 188
Third-party modules 189
Summary 190
Chapter 6: PHP and Python with Nginx 191
Introduction to FastCGI 192
Understanding the mechanism 192
Common Gateway Interface (CGI) 193
Fast Common Gateway Interface (FastCGI) 194
Main directives 195
FastCGI caching 201
Upstream blocks 204
Module syntax 205
Server directive 206
PHP with Nginx 207
Architecture 207
PHP-FPM 208
Setting up PHP and PHP-FPM 208
Downloading and extracting 208
Patching 209
Requirements 209
Building PHP 209
Post-install configuration 210
Running and controlling 210
Nginx configuration 211
Python and Nginx 212
Django 212
Setting up Python and Django 213
Python 213
Django 213
Starting the FastCGI process manager 214
Nginx configuration 215
Summary 215
Chapter 7: Apache and Nginx Together 217
Nginx as reverse proxy
Understanding the issue
The reverse proxy mechanism
Advantages and disadvantages
Nginx Proxy module
Main directives
217
218
219
220
221
222
[ vi ]
Table of Contents
Caching, buffering, and temporary files 225
Limits, timeouts, and errors 228
Other directives 229
Variables 230
Configuring Apache and Nginx 230
Reconfiguring Apache 231
Configuration overview 231
Resetting the port number 231
Accepting local requests only 232
하지만 곧 악몽이 되었고, 어찌할 바를 모르는 똥 마려운 강아지 마냥 안절부절 못하게 되었다.
SQLCipher 는 SQLite 를 위한 암호화 모듈이다. (맞지 않다. 아래에서 다시 설명하겠지만 복호화 모듈이라고 할 수 있다) SQLite 에 이미 암호화 기능이 있는데 왠 써드파티 암호화인가 하겠지만 SQLite 암호화는 엄연히 유료다. SQLite 가 원망스러운 부분으로 느껴지기도 하는 부분인데, 도대체 왜 암호화를 유료로 정책을 세운건지 이해할 수가 없다.
그래서 부득불 오픈 소스를 사용해야하는데, 대표적으로 SQLCipher 가 있다. 이외에 상용으로 나온 툴들이 있긴한데, 대부분 윈도우용의 DLL 파일만 팔거나, DLL 에 직접 DB 에 접속하게 하는 모듈이 포함된 제품이다.
사실 SQLCipher 는 암호화 모듈이 아니라, 복호화 모듈이라고 해야겠다. 왜냐하면 암호화는 SQLite 에서 ATTACH, DETTACH 로 작업을 하고 암호화 된 데이터 파일을 읽을 수 있게 하는게, SQLCipher 다.
처음에는 암호화를 SQLCipher 가 해주는 줄 알고 방향을 잘못 잡아서 한참을 헤맸다. 틀린 방향으로 한참을 가다보니 이 산이 아닌게로구나를 알게 되었을 때의 창피함이란... 역시 영어가 부족한 탓으로 스스로 애써 위안을 삼았다.
SQLCipher 에 대해서 몇 차례 계속 글을 올릴 예정인데, 가능하다면 스크린캐스트로 올려보도록 해야겠다.결론을 먼저 이야기하자면 SQLCipher 덕분에 암호화 뿐만이 아니라 만들어둔 데이터 조회가 더 빨라졌다.