Hello,
Well I'm sure by now most of you have read the Web Server Optimization Guide by Shaw Networks. It came in handy for me when I was first starting out, I reduced my load & memory usage by tonnes. I thought I would make a new thread with an updated How-To.
Recommended Tools/Programs:
Putty - Free SSH Client - http://www.putty.nl/download.html
WinSCP - Free SFTP and SCP Client - http://winscp.net/eng/index.php
MySQL Optimization:
BACKUP:
cp /etc/my.cnf /etc/my.cnf.backup
Use Pico (pico /etc/my.cnf) or Download via WinSCP for editing,
Delete everything that is currently in the file and add the following...
Code:
Code:[mysqld] port = 3306 socket = /var/lib/mysql/mysql.sock skip-locking skip-innodb query_cache_limit=8M query_cache_size=256M query_cache_type=1 max_connections=500 max_user_connections=100 interactive_timeout=60 wait_timeout=60 connect_timeout=30 thread_cache_size=128 key_buffer=16M join_buffer=1M max_allowed_packet=16M table_cache=1024 record_buffer=1M sort_buffer_size=2M read_buffer_size=2M max_connect_errors=100 # Try number of CPU's*2 for thread_concurrency thread_concurrency=2 myisam_sort_buffer_size=64M #log-bin server-id=1 [mysqldump] quick max_allowed_packet = 16M [mysql] no-auto-rehash [isamchk] key_buffer = 256M sort_buffer_size = 256M read_buffer = 2M write_buffer = 2M [myisamchk] key_buffer = 256M sort_buffer_size = 256M read_buffer = 2M write_buffer = 2M [mysqlhotcopy] interactive-timeoutTo Save: CTRL-X Restart Service: "service mysqld restart" or "service mysql restart" or "/etc/rc.d/init.d/mysql restart"
HTTP/APACHE Optimization:
BACKUP:
cp /usr/local/apache/conf/httpd.conf /usr/local/apache/conf/httpd.conf.backup
Use Pico (pico /usr/local/apache/conf/httpd.conf) or Download via WinSCP for editing,
Change the following settings in your httpd.conf...
Set "Timeout" value to "Timeout 60"
Set "KeepAlive" to "KeepAlive on"
Set "KeepAliveTimeout" to "KeepAliveTimeout 3"
Set "MinSpareServers" to "MinSpareServers 16"
Set "MaxSpareServers" to "MaxSpareServers 32"
Set "MaxRequestsPerChild" to "MaxRequestsPerChild 256"
Set "HostnameLookups" to "HostnameLookups Off"
Note:
These settings will not work under all server environments its recommended that you tweak around with the numbers until your web server is running 100% please read Apache documentation before changing any settings so you know what you are changing http://httpd.apache.org/docs/
To Save: CTRL-X
Restart Service: "service httpd restart" or "/etc/rc.d/init.d/httpd restart"
Installing eAccelerator:
eAccelerator is a further development from mmcache PHP Accelerator & Encoder. It increases performance of PHP scripts by caching them in compiled state, so that the overhead of compiling is almost completely eliminated. http://eaccelerator.net/
If you run CPanel please visit eAccelerator auto installer - for cPanel : Technical and Security Tutorials : Web Hosting Talk for an auto-installer which will do all the hard work for you.
Run the following in SSH.
Code:
Edit your PHP.INI file and at the bottom add...Code:cd / mkdir ea cd ea wget http://optusnet.dl.sourceforge.net/s...-0.9.5.tar.bz2 bunzip2 eaccelerator-0.9.5.tar.bz2 tar -xvf eaccelerator-0.9.5.tar cd eaccelerator-0.9.5 export PHP_PREFIX="/usr" $PHP_PREFIX/bin/phpize ./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config make make install mkdir /phpcache chmod 0777 /phpcache
Code:
Restart Service: "service httpd restart" or "/etc/rc.d/init.d/httpd restart"Code:To install as a ZEND extension: zend_extension="/ea/eaccelerator-0.9.5/modules/eaccelerator.so" eaccelerator.shm_size="16" eaccelerator.cache_dir="/phpcache" eaccelerator.enable="1" eaccelerator.optimizer="1" eaccelerator.check_mtime="1" eaccelerator.debug="0" eaccelerator.filter="" eaccelerator.shm_max="0" eaccelerator.shm_ttl="0" eaccelerator.shm_prune_period="0" eaccelerator.shm_only="0" eaccelerator.compress="1" eaccelerator.compress_level="9" OR to install as a PHP extension: extension="/ea/eaccelerator-0.9.5/modules/eaccelerator.so" eaccelerator.shm_size="16" eaccelerator.cache_dir="/phpcache" eaccelerator.enable="1" eaccelerator.optimizer="1" eaccelerator.check_mtime="1" eaccelerator.debug="0" eaccelerator.filter="" eaccelerator.shm_max="0" eaccelerator.shm_ttl="0" eaccelerator.shm_prune_period="0" eaccelerator.shm_only="0" eaccelerator.compress="1" eaccelerator.compress_level="9"
For a great tutorial on Optimizing host.conf & sysctl.conf visit..
http://www.eth0.us/node/104
Common SSH Commands visit..
http://www.webhostgear.com/35.html
How to block an IP using iptables visit..
http://www.netadmintools.com/part216.html
There are currently 11 users browsing this thread. (0 members and 11 guests)
Bookmarks