In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article will explain in detail how to speed up the execution of PHP in CentOS Apache database processing. The content of the article is of high quality, so the editor shares it for you as a reference. I hope you will have a certain understanding of the relevant knowledge after reading this article.
CentOS Apache for the computer players commonly used software, and then I will learn and in-depth study of CentOS Apache, here with you to discuss the use of CentOS Apache, I hope to be useful to you. Tried Lighttpd for a period of time, the performance is really good, the original use of CentOS Apache can only run to 6K/S, after switching to Lighttpd, the performance has nearly doubled.
Just running PHP seems to be very unstable, a little longer database processing time will lead to 500 errors in Lighttpd, that is to say, in order to make Lighttpd play a better performance, in addition to optimizing the program or optimizing the program, as much as possible to speed up the execution of PHP, coupled with eAccelerator performance will be greatly improved.
After talking about so many advantages, let's talk about some recent experiences of the company, the PHP program has been optimized so that it can no longer be optimized, but sometimes 500 errors will occur when you manipulate the database (such as executing mysqldump), and it is easy to occur when the concurrent volume is very large.
At this point, the performance of Lighttpd is not as stable as CentOS Apache, so I came up with a compromise: let CentOS Apache handle the PHP program, and other static pages (including images, software, etc.) are all handled by Lighttpd. And the implementation method is to achieve through mod_proxy, CentOS Apache to do front-end processing or Lighttpd to do front-end processing, anyway, these two have a mod_proxy module, basically the same.
The following is the separation of dynamic pages and static pages using CentOS Apache (port 80) and Lighttpd (port 81) under CentOS 4.4 system. CentOS Apache can be installed by default (yum install apache), and there are many installation documents on the Internet, so I won't introduce it any more.
Install Lighttpd v1.4.13
# yum install pcre-devel # cd / usr/local/src # wget http://www.lighttpd.net/download/lighttpd-1.4.13.tar.gz # tar-zxvf lighttpd-1.4.13.tar.gz # cd lighttpd-1.4.13 #. / configure-with-pcre # make # make install # cd doc # cp sysconfig.lighttpd / etc/sysconfig/lighttpd # cp rc.lighttpd.redhat / etc/init.d/lighttpd # chkconfig Lighttpd on # mkdir-p / etc/lighttpd # cp lighttpd.conf / etc/lighttpd/ # mkdir / var/log/lighttpd # touch / var/log/lighttpd/access.log # touch / var/log/lighttpd/error.log # chown-R apache:apache / var/log/lighttpd # vi / etc/init.d/lighttpd change lighttpd= "/ usr/sbin/lighttpd" to lighttpd= "/ usr/local/sbin/lighttpd"
Edit the configuration file lighttpd.conf of Lighttpd and roughly modify it as follows:
Server.modules = ("mod_access", "mod_simple_vhost" "mod_accesslog") server.document-root = "/ var/www/html" server.errorlog = "/ var/log/lighttpd/error.log" accesslog.filename = "/ var/log/lighttpd/access.log" server.port = 81 server.bind = "localhost" simple-vhost.server-root = "/ var/www/html/" simple-vhost.default-host = "" simple-vhost.document-root = "/" server.username = "apache" server.groupname = "apache"
At this point, the Lighttpd is basically configured, and the execute / etc/init.d/lighttpd start starts listening on port 81. Next, configure CentOS Apache. All you need to do is to open the mod_rewrite and mod_proxy modules, and roughly modify them as follows:
LoadModule rewrite_module modules/mod_rewrite.so LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so LoadModule proxy_connect_module modules/mod_proxy_connect.so ServerAdmin webmaster@sofee.cn DocumentRoot / var/www/html/test.sofee.cn ServerName test.sofee.cn RewriteEngine On # RewriteLog logs/rewrite_log # RewriteLogLevel 1 RewriteRule "^ / (. *). (js | css | htm | html | swf | gif | jpg | png | ico | exe | zip | rar)) $" http://0.0.0.0:81/$1" [P QSA,L] RewriteRule "^ / (. *)" $0 "[L] ProxyRequests Off ProxyPreserveHost On ProxyReceiveBufferSize 16384 ProxyTimeout 300 ProxyPassReverse / http://0.0.0.0:81/
At this point, CentOS Apache has also been configured, execute / etc/init.d/httpd start to start listening on port 80. To enable mod_proxy to perform better, you can also add a mod_cache module:
LoadModule cache_module modules/mod_cache.so LoadModule disk_cache_module modules/mod_disk_cache.so LoadModule mem_cache_module modules/mod_mem_cache.so CacheEnable mem / MCacheSize 10240 MCacheMaxObjectCount 100 MCacheMinObjectSize 1 MCacheMaxObjectSize 2048 CacheRoot / var/cache/mod_proxy CacheEnable disk / CacheDirLevels 5 CacheDirLength 3 So much for sharing about how CentOS Apache database processing speeds up the execution of PHP. I hope the above content can be of some help to you and learn more knowledge. If you think the article is good, you can share it for more people to see.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.