Putting It All Together January 9, 2011 by CW Cyrix Last Updated: 2011/04/26 [0426] Added notes regarding PHP and MySQL during a major MySQL upgrade. Install Apache 2.2 or 2.3 Install MySQL 5.1 or 5.5 Install PHP 5.2 or 5.3 *NOTES* [If upgrading to a major MySQL release (e.g. 5.0 to 5.1, 5.1 to 5.5, 4.1 to 5.1), you will have to recompile and reinstall PHP5 with the tag --with-mysql=[DIR] pointing to the current MySQL directory, if you used MySQL's external library and not PHP's mysqlnd driver. This is because symbolic links within PHP and MySQL's libraries were established while compiling PHP and there is a very high possibility that things were broken in the MySQL upgrading process, thus in turn, causing MySQL to not start and Apache giving a 500 Internal Server error. Example: error.log [Tue Apr 26 18:58:21.685891 2011] [core:error] [pid 16875:tid 2910473072] [client 192.168.1.165:2290] Premature end of script headers: php-cgi /home/ami-sapphire/php/bin/php-cgi: error while loading shared libraries: libmysqlclient.so.16: cannot open shared object file: no such file or directory access.log 192.168.1.195 - - [26/Apr/2011:18:58:21 -0400] "GET /phpinfo.php HTTP/1.1" 500 654 Epic head scratcher for a beginner, hence the note.] [skip-locking in MySQL has been officially deprecated as of MySQL 5.1 and REMOVED as of MySQL 5.5. It has been changed to skip-external-locking as of 5.1. You can get away with it in 5.1, it will just spit out a warning about it. Change it accordingly when upgrading MySQL to 5.5! Otherwise, you will get something like this: 110110 19:24:36 InnoDB: Using Linux native AIO 110110 19:24:36 InnoDB: Initializing buffer pool, size = 256.0M 110110 19:24:36 InnoDB: Completed initialization of buffer pool 110110 19:24:36 InnoDB: highest supported file format is Barracuda. 110110 19:24:36 InnoDB: 1.1.4 started; log sequence number 8607838993 110110 19:24:36 [ERROR] /usr/sbin/mysqld: unknown option '--skip-locking' 110110 19:24:36 [ERROR] Aborting 110110 19:24:36 InnoDB: Starting shutdown... 110110 19:24:37 InnoDB: Shutdown completed; log sequence number 8607838993 110110 19:24:37 [Note] /usr/sbin/mysqld: Shutdown complete Yeah. Doesn't help that the default files haven't had this changed in 5.5.] ---- Instructions for setting up httpd.conf (from Apache 2.2) Works for v2.3 as well! 1. Find this starting around line 247: DirectoryIndex index.html Change it into this: DirectoryIndex index.html index.htm index.php *index.htm is optional. Unless, you are using FrontPage (WHY?!) or just like using the extension.* 2. Find this starting around line 347: AllowOverride None Options None Require all granted Either change it into this or copy and paste it under the original line: AllowOverride None Options None Require all granted *The line was simply replaced in Ami Sapphire's test server.* 3. Add this under number 2: # CUSTOM: Add PHP 5 parsing (via CGI) handler and action ScriptAlias /bin/ /path/to/php/bin/ AddHandler application/x-httpd-php5 .php Action application/x-httpd-php5 /bin/php-cgi/ AllowOverride All Options ExecCGI Order allow,deny Allow from all *Change the '/path/to' path to where your PHP installation is located.* *You can add .html to the AddHandler line as an option. However, that makes them run as a script as well, along with any statically-made HTML. Not a great security practice.* Instructions for setting up php.ini (from PHP 5.3) Optional settings: 1. Around Line 227: Turn 'short_open_tag = On' 2. Around Line 1504: Set a different path for 'session.cookie_path = / ', i.e. '/session-cookie' (omit quote) Instructions for setting up my.cnf (from MySQL 5.1 and 5.5) Optional; as uncommenting InnoDB enables you to use the InnoDB form database. From 1: skip-external-locking is enabled by default. -Disabled on Ami Sapphire's test server.- port is 3306 by default. socket is /tmp/mysql.sock by default. -Can either be default, /var/run/mysql/mysql.sock, /etc, wherever.- -It is /tmp/mysql.sock on Ami Sapphire's test server.- From 2: log-bin is mysql-bin and is enabled by default. -Disabled on Ami Sapphire's test server.- binlog_format is mixed and is enabled by default. -Disabled on Ami Sapphire's test server.- server id is 1 and is enabled by default. -Disabled on Ami Sapphire's test server.- From 3: innodb_data_home_dir is /usr/local/mysql/data and is disabled by default. -Enabled on Ami Sapphire's test server.- -It is /usr/amisaph/mysql/data on Ami Sapphire's test server.- innodb_data_file_path is ibdata1:10M:autoextend and is disabled by default. -Enabled on Ami Sapphire's test server.- innodb_log_group_home_dir is /usr/local/mysql/data and is disabled by default. -Enabled on Ami Sapphire's test server.- -It is /usr/amisaph/mysql/data on Ami Sapphire's test server.- -It once didn't work due to a typo on the path. It said this: /usr/amisaph/local/mysql/data. Took four hours to realize that gaffe.- innodb_buffer_pool_size is 16M and is disabled by default. -Enabled on Ami Sapphire's test server.- innodb_additional_mem_pool_size is 2M and is disabled by default. -Enabled on Ami Sapphire's test server.- innodb_log_file_size is 5M and is disabled by default. -Enabled on Ami Sapphire's test server.- innodb_log_buffer_size is 8M and is disabled by default. -Enabled on Ami Sapphire's test server.- innodb_flush_log_at_trx_commit is 1 and is disabled by default. -Enabled on Ami Sapphire's test server.- innodb_lock_wait_timeout is 50 and is disabled by default. -Enabled on Ami Sapphire's test server.- Examples from my-medium.cnf 1. # The MySQL server [mysqld] port = 3306 socket = /tmp/mysql.sock skip-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M 2. # Replication Master Server (default) # binary logging is required for replication log-bin=mysql-bin # binary logging format - mixed recommended binlog_format=mixed # required unique id between 1 and 2^32 - 1 # defaults to 1 if master-host is not set # but will not function as a master if omitted server-id = 1 3. # Uncomment the following if you are using InnoDB tables #innodb_data_home_dir = /usr/local/mysql/data #innodb_data_file_path = ibdata1:10M:autoextend #innodb_log_group_home_dir = /usr/local/mysql/data # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high #innodb_buffer_pool_size = 16M #innodb_additional_mem_pool_size = 2M # Set .._log_file_size to 25 % of buffer pool size #innodb_log_file_size = 5M #innodb_log_buffer_size = 8M #innodb_flush_log_at_trx_commit = 1 #innodb_lock_wait_timeout = 50 Examples from Ami Sapphire's my.cnf 1. # The MySQL server [mysqld] user = mysql basedir = /usr/local/mysql datadir = /usr/amisaph/mysql/data port = 3306 socket = /tmp/mysql.sock #skip-external-locking key_buffer_size = 16M max_allowed_packet = 1M table_open_cache = 64 sort_buffer_size = 512K net_buffer_length = 8K read_buffer_size = 256K read_rnd_buffer_size = 512K myisam_sort_buffer_size = 8M 2. # Replication Master Server (default) # binary logging is required for replication #log-bin=mysql-bin # binary logging format - mixed recommended #binlog_format=mixed # required unique id between 1 and 2^32 - 1 # defaults to 1 if master-host is not set # but will not function as a master if omitted #server-id = 1 3. # Uncomment the following if you are using InnoDB tables innodb_data_home_dir = /usr/amisaph/mysql/data innodb_data_file_path = ibdata1:10M:autoextend innodb_log_group_home_dir = /usr/amisaph/mysql/data # You can set .._buffer_pool_size up to 50 - 80 % # of RAM but beware of setting memory usage too high innodb_buffer_pool_size = 16M innodb_additional_mem_pool_size = 2M # Set .._log_file_size to 25 % of buffer pool size innodb_log_file_size = 5M innodb_log_buffer_size = 8M innodb_flush_log_at_trx_commit = 1 innodb_lock_wait_timeout = 50