+ All Categories
Home > Documents > Easy Apache Configuration

Easy Apache Configuration

Date post: 24-Mar-2015
Category:
Upload: ricardohernande111
View: 271 times
Download: 3 times
Share this document with a friend
38
EasyApache 3: PHP Configuration John “J.D.” Lightsey
Transcript
Page 1: Easy Apache Configuration

EasyApache 3:PHP Configuration

John “J.D.” Lightsey

Page 2: Easy Apache Configuration

Disclaimers

All trademarks used in this presentation are the property of their respective owners.

Page 3: Easy Apache Configuration

Introduction

# stat /proc/self

Linux developer and administrator - May 2000Debian Developer - Dec 2004cPanel Linux/BSD Developer - Mar 2007

Page 4: Easy Apache Configuration

Introduction

Overview:

Much of this talk is covered in the online documentation

http://www.cpanel.net/support/docs/ea/ea3/

Page 5: Easy Apache Configuration

Introduction

Outline:

EasyApache 1 vs EasyApache 3PHP HandlersEasyApache 3 IntegrationOrganizationToolsExtensionsDual PHPLooking Forward

Page 6: Easy Apache Configuration

cPanel and PHP

EasyApache 1: Organization

Single PHP versionPHPSuexecSuexec

Page 7: Easy Apache Configuration

cPanel and PHP

EasyApache 1: Advantages

Easy to understandEasy to hand tweakLong lifespan

Page 8: Easy Apache Configuration

cPanel and PHP

EasyApache 1: Disadvantages

Inflexible– During Apache build– Post build configurationNot forward looking– PHP4 will be EOL soon– FastCGI

Page 9: Easy Apache Configuration

cPanel and PHP

EasyApache 3: Core PHP improvements

Configurable dual PHP installsFlexible– During build– After buildImproved security

Page 10: Easy Apache Configuration

PHP Request Cycle

Apache and PHP:

Apache ServerRequest

Response

MIME Type

Handler

Context

Handler

Page 11: Easy Apache Configuration

PHP Handlers

DSOSuPHPFCGIDCGI

Page 12: Easy Apache Configuration

PHP Handlers

DSO:

Confusing name (libphp/mod_php/dso)‏Always runs PHP as nobodyFastest handlerHigh familiarity for users and administrators– Apache directives– Permissions

Page 13: Easy Apache Configuration

PHP Handlers

DSO Drawbacks:

Low securityDifficult to run both PHP versions as DSO

RECOMMENDED

Page 14: Easy Apache Configuration

PHP Handlers

SuPHP:

Higher security replacement for PHPSuexecRuns PHP as the user (regardless of suexec setting)‏Very configurableVery secureSimple dual-PHP setup

Page 15: Easy Apache Configuration

PHP Handlers

SuPHP Drawbacks:

SlowDoesn't handle DSO style Apache directivesSecurity checks may confuse some users

RECOMMENDED

Page 16: Easy Apache Configuration

PHP Handlers

FCGID (FastCGI):

Designed to be the best of DSO and SuPHPRuns PHP as the user or nobody depending on

suexec settingFast

Page 17: Easy Apache Configuration

PHP Handlers

FCGID (FastCGI) Drawbacks:

Complicated to configure• http://fastcgi.coremail.cn/

High memory usagePrevents users from accessing the cPanel PHP

selectorDoesn't handle DSO style Apache directives

NOT RECOMMENDED

Page 18: Easy Apache Configuration

PHP Handlers

CGI:

Intended as a fallback of last resortDoesn't require additional Apache modulesRuns PHP as the user or nobody depending on

suexec setting

Page 19: Easy Apache Configuration

PHP Handlers

CGI Drawbacks:

SlowLow SecurityDoesn't handle DSO style Apache directivesDoesn't handle ~userdir properly

NOT RECOMMENDED

Page 20: Easy Apache Configuration

PHP Handlers

Best Practices:

Speed: One version of PHP via DSOSecurity: One version of PHP via SuPHPFlexibility: Two versions of PHP via SuPHPAdvanced: Two versions of PHP via FCGID

Page 21: Easy Apache Configuration

Integration with EasyApache 3

First contact:

EA3 BuildProcess

Apache/PHP Build

Apache Config generated

Default PHP Handler Set

Test/Revert EA3 Build

EasyApache 3 Configuration

Post install PHP Configuration

Page 22: Easy Apache Configuration

Integration with EasyApache 3

EasyApache 3 Configuration:

Too many options to cover in detailMost important– Apache MPM: Use prefork– Apache Mod_suPHP (enable)‏– PHP DiscardPath (disable)‏– PHP Versioning (disable)‏– PHP Dual DSO (disable)‏

Page 23: Easy Apache Configuration

Integration with EasyApache 3

Default PHP Handler:

Reuse existing defaultsFallbacks– SuPHP– FastCGI– DSO– CGI– NoneSuexec defaults to on

Page 24: Easy Apache Configuration

Integration with EasyApache 3

Post install PHP configuration:

See tools...

Page 25: Easy Apache Configuration

Organization

Configuration files:

/usr/local/apache/conf/– httpd.conf– php.conf– php.conf.yaml– php(4|5).htaccess/opt/suphp/etc/suphp.conf/home/<user>/.htaccess

Page 26: Easy Apache Configuration

Tools

rebuild_phpconfWebHost Manager PHP and Suexec Configurationupdate_php_mime_typescPanel PHP Selectorphpextensionmgr

Page 27: Easy Apache Configuration

Tools

/usr/local/cpanel/bin/rebuild_phpconf

The WebHost Manager PHP and Suexec configration tool is a wrapper around this programSets– Default PHP version– PHP Handlers– Suexec

Page 28: Easy Apache Configuration

Tools

WebHost Manager PHP and Suexec configuration tool:

Service Configuration → Configure PHP and Suexec

Page 29: Easy Apache Configuration

Tools

/usr/local/cpanel/bin/update_php_mime_types

Iterates through home directories checking PHP AddHandler lines in .htaccess filesRecursion depth is adjustable in Tweak SettingsMarker comment

# Use PHP4 as defaultAddHandler application/x-httpd-php4 .php

Page 30: Easy Apache Configuration

Tools

cPanel X3 PHP configuration tool:

Software/Services → PHP Configuration

Page 31: Easy Apache Configuration

Tools

/scripts/phpextensionmgr

Replacement for installzendopt that handles all EasyApache 3 supplied loadable PHP extensionsDocumentation included (try --help or --man)‏Easy path for adding or removing an extension

without rebuilding Apache and PHP

Page 32: Easy Apache Configuration

PHP Extensions

In general:

Use phpextensionmgrEvery extension consumes memory/CPUcPanel provided configuration should always be safe

and functional

Page 33: Easy Apache Configuration

PHP Extensions

Security:

Suhosin– http://www.hardened-php.net/suhosin/– Designed to protect against bad scripts, not bad

users– Generally recommended

Page 34: Easy Apache Configuration

PHP Extensions

Performance:

eAccelerator– http://eaccelerator.net/Zend Optimizer– http://www.zend.com/

DSO/FCGID required

Page 35: Easy Apache Configuration

PHP Extensions

Source Obfuscation:

Zend Optimizer– http://www.zend.com/eAccelerator– http://eaccelerator.net/IonCube Loader– http://www.ioncube.com/loaders.phpSourceGuardian– http://www.sourceguardian.com/

Page 36: Easy Apache Configuration

Dual PHP

Use mod_suphp!

Dual DSO is possible but not recommended– Loadable extensions– Handlers– Directives

Page 37: Easy Apache Configuration

Looking Forward

On the horizon for EasyApache 3 and PHP

PHP 6Reorganized install locationsFaster buildsBetter integration of dual/triple installs with WebHost

Manager and cPanel toolsWhat's missing?– http://bugzilla.cpanel.net/

Page 38: Easy Apache Configuration

Questions?


Recommended