Strolen's World · Legacy archive
eAccelerator
-
eAccelerator
#1Updated to Eaccelerator 0.9.3 Final Release
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.
The instructions in this How-To is a bit different to the official one, because the directories are a bit different - I couldn't get this to work using the instructions from the official guide itself. I also point to the module file in a different directory in php.ini - the default one in the official instructions didn't work for me.
NOTE: I couldn't get mmcache to work with PHP 4.3.11 as well. eaccelerator works.
Follow the instructions to install or to upgrade from mmcache.
Installation:
UPGRADING:
1) To upgrade eaccelerator:
Just download the NEW version of eaccelerator and recompile - same instructions as installating.
NOTE the CHANGES to the directory path in php.ini
2) To upgrade PHP versions:
You need to DELETE the eaccelerator directory that has been compiled, re-untar the eaccelerator gzip file and RE-INSTALL and recompile eaccelerator for every NEW version of PHP.
1) Login as root in SSH
2) Run the following commands in the following order:
cd /
mkdir ea
cd ea
wget http://kent.dl.sourceforge.net/sourceforge/eaccelerator/eaccelerator-0.9.3.tar.gz
tar xvzf eaccelerator-0.9.3.tar.gz
cd eaccelerator-0.9.3
export PHP_PREFIX="/usr"
$PHP_PREFIX/bin/phpize
./configure --enable-eaccelerator=shared --with-php-config=$PHP_PREFIX/bin/php-config
make
make install
3) Edit php.ini - usually it's /etc/php.ini or /usr/local/lib/php.ini
Find this:
;Windows Extensions
Above this, comment out or remove the PHPA or mmcache lines if you have them. Replace them with this:
To install as a ZEND extension:
zend_extension="/ea/eaccelerator-0.9.3/modules/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
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.3/modules/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
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"
4) Create the cache directory by doing the following at the command line
mkdir /tmp/eaccelerator
chmod 0777 /tmp/eaccelerator
5) Restart Apache
service httpd restart
Done!
6) Optional - upload ea.php file
I modified the eaccelerator.php file so that only you can control the eaccelerator config and see the stats.
Edit ea.php - change 1 to your userid.
Upload to your forum directory.
When you link to ea.php you can see your eaccelerator stats like this:
eAccelerator 0.9.3
eAccelerator support enabled
Caching Enabled true
Optimizer Enabled true
Memory Size 33,554,396 Bytes
Memory Available 22,675,372 Bytes
Memory Allocated 10,879,024 Bytes
Cached Scripts 101
Removed Scripts 0
Cached Keys 0 -
Re: eAccelerator
#2VPSes are really hard to use with the memory restrictions and CPU limitations...but with some optimization they can definitely serve your websites fast!
MySQL Optimization
Here are my suggested settings for the my.cnf file. This should work well for a VPS with 256-512MB RAM.
Code:
max_connections = 400
key_buffer = 16M
myisam_sort_buffer_size = 32M
join_buffer_size = 1M
read_buffer_size = 1M
sort_buffer_size = 2M
table_cache = 1024
thread_cache_size = 286
interactive_timeout = 25
wait_timeout = 1000
connect_timeout = 10
max_allowed_packet = 16M
max_connect_errors = 10
query_cache_limit = 1M
query_cache_size = 16M
query_cache_type = 1
tmp_table_size = 16M
skip-innodb
[mysqld_safe]
open_files_limit = 8192
quick
max_allowed_packet = 16M
key_buffer = 32M
sort_buffer = 32M
read_buffer = 16M
write_buffer = 16M
In order to make things even faster, you can customize these settings specifically for your VPSs' usage. There's a great howto on InterWorx's forum for this --> http://www.interworx.com/forums/showthread.php?p=2346
Lastly, I recommend installing mytop to help you monitor your usage...
Code:
wget http://dll.elix.us/mytop-1.4.tar.gz
tar -zxvf mytop-1.4.tar.gz
cd mytop-1.4
perl Makefile.PL
make
make test
make install
Once that's done, just enter in "mytop" .
PHP & Apache Optimization
I strongly recommend installing eAccelerator. There's an easy to follow howto here: http://forum.ev1servers.net/showthre...t=eaccelerator. If you use the default cache dir for eAccelerator (/tmp/eaccelerator) make sure you check it reguarily and clean it every once and a while. (it can really get quite large from my experience)
For httpd.conf I suggest:
Timeout 200
KeepAlive On
maxKeepAliveRequests 100
KeepAliveTimeout 3
MinSpareServers 10
MaxSpareServers 20
StartServers 15
MaxClients 250
MaxRequestsPerChild 0
HostnameLookups Off
You can use ab to benchmark your Apache before and after you make changes.
ab -c 5 -n 20 somephpbasedsiteonyourserver.com/file.php
I suggest doing 2 or 3 tests like that to get an average.
If you want to check the Apache error log, try this -->
cat /usr/local/apache/logs/error_log
Monitoring Usage
On a Virtuozzo VPS you can use cat /proc/usr_beancounters to output your usage of the VZ parameters. You should pay most attention to oomguarpages and privmpages. (although anything with a failure is generally bad)
You can find the amount of connections to Apache with this command:
netstat -nt | grep :80 | wc -l
To find the amount of Apache processes use this command:
ps -A | grep httpd | wc -l (this will show the process count)
ps -aux | grep httpd (this will show the actual processes)
To find the amount of MySQL processes use this command:
ps -A | grep mysql | wc -l (this will show the process count)
ps -aux | grep mysql (this will show the actual processes)
Just simply using top (standard view) or top -c (will show the actual command being used and/or location of each process as opposed to just the name) can help you monitor your VPS usage very wel.
To see your disk space usage, try using this command --> df -h
Mitigating (D)DOS
If you're being DDOS'd or DOS'd you can use this command:
netstat -ntu | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n
That will help you see how many connections each IP address has in total to your server.
There's a very decent script you can use to automate the banning of IP addresses available here --> http://forums.deftechgroup.com/showthread.php?t=825
Although I haven't tried it myself, I suggest you take a look at Scrutinizer as well which sounds very useful --> http://www.solutix.ch/cgi-bin/index.pl
Spam Assassin
Spam Assassin can take up a lot of memory and make it really hard to host just a few sites on a VPS, but there is a way around this...
Login to WHM as root, scroll down to "cPanel 10.8.1-R15" (it may be slightly different depending on what version you are using) then goto "Addon Modules" and install "spamdconf". Once it's done, refresh the WHM page, scroll down to "Add-ons" on the nav bar and then click on 'Setup Spamd Startup Configuration". Set "Maximum Children" to "2". Then hit Submit. Wait a few seconds (15-30, but usually less) for exim to restart and you're done .
cPanel Tweak Setings
Login to WHM as root, and under "Server Configuration" on the nav bar hit "Tweak Settings".
Here are some suggested settings:
Default catch-all/default address behavior for new accounts. fail will generally save the most CPU time.
- Use "FAIL". If you already have some accounts setup not to use "FAIL" (by default it will not) then run this command to convert to FAIL from BLACKHOLE --> perl -pi -e "s/:blackhole:/:fail:/g;" /etc/valiases/*
Mailman
- Mailman tends to use a lot of resources, so if you don't need cpanel mailing lists then uncheck this.
Number of minutes between mail server queue runs (default is 60).:
- You may want to set this to 180 to reduce load.
Track the origin of messages sent though the mail server by adding the X-Source headers (exim 4.34+ required)
- This is just generally a good idea. So check this.
Analog Stats
- I find this useless, so uncheck this. If you want to delete the existing analog stats files just run this command --> rm -rf /home/*/tmp/analog/*
Awstats Reverse Dns Resolution
- Make sure this is unchecked, I find it pretty much useless for most users.
Awstats Stats
- You can check this if you need a robust stats software that integrates with cPanel, if you don't need it, then don't check it. *Note most hosting clients will want to use this. If you want to delete the existing awstats stats files just run this command --> rm -rf /home/*/tmp/awstats/*
Webalizer Stats
- Not many hosting clients will want to use this so, you can uncheck this to reduce load. If you want to delete the existing webalizer stats files just run this command --> rm -rf /home/*/tmp/webalizer/*
Delete each domain's access logs after stats run
- Make sure this is checked, otherwise disk space usage can really rack up!
That's about it for now, I may do some more later....
-------------------
wait_timeout -- you may want to set this it a lower number (like 100 or even less) if your MySQL is used more intensively. 400 is good if your MySQL isn't used a lot, therefore you can afford some more open processes..
---------------------
Originally Posted by vantasticman7
I will be running only about 15 sites, 10 of which have MSQL databases on. No forms or large downloads. Mostly Blogs and brochure ware.
Van
Try this for the httpd.conf settings:
Timeout 150
KeepAlive Off
MinSpareServers 3
MaxSpareServers 6
StartServers 2
MaxClients 150
MaxRequestsPerChild 0
HostnameLookups Off
I'll have a MySQL config ready a little later.
But, I have a question...are these sites popular?
Timeout 150
KeepAlive Off
MinSpareServers 4
MaxSpareServers 8
StartServers 3
MaxClients 150
MaxRequestsPerChild 0
HostnameLookups Off
That should work better. Also, get rid of unneeded modules to lower the Apache footprint.
---------------------------
-
Re: eAccelerator
#3Rather than writing a Perl script, you can just use find:
/usr/bin/find /tmp -user www -atime +1 -name 'eaccelerator*' -delete
That would delete files that haven't been accessed in a day. Throw that in a crontab, and you're good to go. -
Re: eAccelerator
#4http://www.theadminzone.com/forums/forumdisplay.php?f=106 -
Re: eAccelerator
#5explains settings and what to change
http://www.interworx.com/forums/showthread.php?p=2346
this
links to this
http://www.databasejournal.com/features/mysql/article.php/10897_1402311_3 -
Re: eAccelerator
#6;eaccelerator.allowed_admin_path = "/home/strolen/public_html/phpsysinfo"
;extension="/ea/eaccelerator-0.9.4/modules/eaccelerator.so"
;extension="/usr/local/lib/php/extensions/no-debug-non-zts-20060613/"
;extension="eaccelerator.so"
;zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20060613/eaccel$
;eaccelerator.shm_size="16"
;eaccelerator.cache_dir="/tmp/eaccelerator"
;eaccelerator.enable="1"
;eaccelerator.optimizer="1"
;eaccelerator.check_mtime="1"
;eaccelerator.debug="0"
;eaccelerator.filter="!/home/strolen/public_html/art !/home/afsa658"
;eaccelerator.shm_max="0"
;eaccelerator.shm_ttl="60"
;eaccelerator.shm_prune_period="100"
;eaccelerator.shm_only="0"
;eaccelerator.compress="1"
;eaccelerator.compress_level="9"
-
Re: eAccelerator
#7http://www.vbulletin.com/forum/showthread.php?t=75878 -
Re: eAccelerator
#8:/usr/local/lib/php/extensions/no-debug-non-zts-20060613/
-
Re: eAccelerator
#9bump -
Re: eAccelerator
#10
./configure --without-eaccelerator-use-inode --with-eaccelerator-content-caching
zend_extension="/usr/local/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/eaccelerator"
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"