Re: Optimum configuration for Apache and PHP
| From: | php at karsites dot net | Date: | Sat, 18 Mar 2006 14:49:53 +0000 |
| Subject: | Re: Optimum configuration for Apache and PHP | ||
| References: | 1 | Groups: | php.install |
| Request: | Send a blank email to php-install+get-17204@lists.php.net to get a copy of this message | ||
From what I've read in the documentation.
You can only use 1 type of Apache core MPM module at a time.
PHP is a bit fussy about the MPM you use under Linux.
PHP Manual
Chapter 4. Installation on Unix systems
Apache 2.0 on Unix systems
This section contains notes and hints specific to Apache
2.0 installs of PHP on Unix systems.
Warning
We do not recommend using a threaded MPM in production with
Apache2. Use the prefork MPM instead, or use Apache1. For
information on why, read the related FAQ entry on using
Apache2 with a threaded MPM
I think you need to use a php module for apache, - not CGI,
as AFAIK the Apache php module would be faster than the
external cgi program.
You can just use the php5 Apache module and tell it to run
in php 4 mode using the following php directive:
zend.ze1_compatibility_mode boolean (0 | 1)
// default is off - 0
zend.ze1_compatibility_mode 0
Enable compatibility mode with Zend Engine 1 (PHP 4). It
affects the cloning, casting, and comparing of objects.
This can be set anywhere, in the php.ini file, or on a page
by page basis. So in theory, you should be able to just use
php5, and switch into php4 mode as required.
You cannot use the Apache php4 and php5 modules together in
1 server instance.
PHP Manual
Appendix B. Migrating from PHP 4 to PHP 5
Table of Contents
What has changed in PHP 5
Backward Incompatible Changes
CLI and CGI
Migrating Configuration Files
New Functions
New Directives
Databases
New Object Model
Error Reporting
What has changed in PHP 5
PHP 5 and the integrated Zend Engine 2 have greatly
improved PHP's performance and capabilities, but great care
has been taken to break as little existing code as possible.
So migrating your code from PHP 4 to 5 should be very easy.
Most existing PHP 4 code should be ready to run without
changes, but you should still know about the few differences
and take care to test your code before switching versions in
production environments.
For php accelerators you may be able to use the following
with php5:
http://www.php-accelerator.co.uk/
They also sell a commercial php encoder, which is amazingly
fast, and reasonably priced.
http://www.ioncube.com/sa_encoder.php
You also need to be familiar with optimal database design
techniques, and how to write efficient SQL queries, and fine
tune and squeeze as much performance out of mysql as possible.
See chapter 7 from the mysql manual.
7. Optimization
7.1. Optimization Overview
7.1.1. MySQL Design Limitations and Tradeoffs
7.1.2. Designing Applications for Portability
7.1.3. What We Have Used MySQL For
7.1.4. The MySQL Benchmark Suite
7.1.5. Using Your Own Benchmarks
7.2. Optimizing SELECT and Other Statements
7.2.1. Optimizing Queries with EXPLAIN
7.2.2. Estimating Query Performance
7.2.3. Speed of SELECT Queries
7.2.4. WHERE Clause Optimization
7.2.5. Range Optimization
7.2.6. Index Merge Optimization
7.2.7. IS NULL Optimization
7.2.8. DISTINCT Optimization
7.2.9. LEFT JOIN and RIGHT JOIN Optimization
7.2.10. Nested Join Optimization
7.2.11. Outer Join Simplification
7.2.12. ORDER BY Optimization
7.2.13. GROUP BY Optimization
7.2.14. LIMIT Optimization
7.2.15. How to Avoid Table Scans
7.2.16. Speed of INSERT Statements
7.2.17. Speed of UPDATE Statements
7.2.18. Speed of DELETE Statements
7.2.19. Other Optimization Tips
7.3. Locking Issues
7.3.1. Locking Methods
7.3.2. Table Locking Issues
7.3.3. Concurrent Inserts
7.4. Optimizing Database Structure
7.4.1. Design Choices
7.4.2. Make Your Data as Small as Possible
7.4.3. Column Indexes
7.4.4. Multiple-Column Indexes
7.4.5. How MySQL Uses Indexes
7.4.6. The MyISAM Key Cache
7.4.7. MyISAM Index Statistics Collection
7.4.8. How MySQL Opens and Closes Tables
7.4.9. Drawbacks to Creating Many Tables in the Same Database
7.5. Optimizing the MySQL Server
7.5.1. System Factors and Startup Parameter Tuning
7.5.2. Tuning Server Parameters
7.5.3. Controlling Query Optimizer Performance
7.5.4. How Compiling and Linking Affects the Speed of MySQL
7.5.5. How MySQL Uses Memory
7.5.6. How MySQL Uses DNS
7.6. Disk Issues
7.6.1. Using Symbolic Links
I'm sure others on the list can add alot more to my 2 cents
worth.
HTH
Keith
In theory, theory and practice are the same;
in practice they are not.
To unsubscribe from this list, please see detailed
instructions already posted at:
http://marc.theaimsgroup.com/?l=php-install&m=114138567814319&w=2
On Sat, 18 Mar 2006 php@lmem.icsurselva.ch wrote:
> To: php-install@lists.php.net
> From: php@lmem.icsurselva.ch
> Subject: [PHP-INSTALL] Optimum configuration for Apache and PHP
>
> Hello all, We are building a new LAMP system, which will
> contain lots of virtualhosts (most of them are Typo3
> vhosts). Hardware: Processors: 2 x Xeon(TM) CPU 3.20GHz,
> 2048 KB (EM64T, HyperThreading) RAM: 4GB
>
> Im wondering what would be the best solution to setup apache and PHP
> (we want install php4 and php5 on the same machine)
> I thought about the following possibilities
> (Configuration_1)
> - apache2 compiled with "worker mpm" and "threads"
> - php compiled as "cgi" and "threads"
> ? what about fastcgi in this configuartion ?
> ? what about eaccelerator or pecl-apc in this configuartion ?
> (/Configuration_1)
>
> (Configuration_2)
> - apache2 compiled with "prefork mpm"
> - php compiled as "cgi"
> (all without threads)
> ? what about fastcgi in this configuartion ?
> ? what about eaccelerator or pecl-apc in this configuartion ?
> (/Configuration_2)
>
> (Configuration_3)
> - apache2 compiled with "prefork mpm"
> - php compiled as "mod_php"
> ? what about eaccelerator or pecl-apc in this configuartion ?
> (/Configuration_3)
>
>
> Which one is the way to go regarding stability,
> performance and security? How does mod_suphp affect
> performance and stability?
>
> Thanks for helping us.
>