一、Perl + mod_perl
安装mod_perl使Perl脚本速度快
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 | [1] # [root@linuxprobe # yum --enablerepo=epel -y install mod_perl [2] [root@linuxprobe # vi /etc/httpd/conf.d/perl.conf # PerlSwitches # PerlSwitches # Alias /perl
<Directory /var/www/perl > # the directory for mod_perl environment SetHandler perl-script # processes files as perl-scripts under this directory # # # PerlResponseHandler ModPerl::PerlRun # PerlOptions +ParseHeaders Options +ExecCGI < /Directory > # <Location /perl-status > SetHandler perl-script PerlResponseHandler Apache2::Status Require ip 127.0.0.1 10.1.1.1 /24 # # # # < /Location > [root@linuxprobe # systemctl restart httpd [3] [root@linuxprobe # mkdir /var/www/perl [root@linuxprobe # vi /var/www/perl/test-mod_perl.cgi #!/usr/bin/perl use use print "Content-type: text/html\n\n" ; print "<html>\n<body>\n" ; print "<div style=\"width:100%; font-size:40px; font-weight:bold; text-align:center;\">" ; my &number(); print "</div>\n</body>\n</html>" ; sub $a++; print "number \$a = $a" ; } [root@linuxprobe # chmod 705 /var/www/perl/test-mod_perl.cgi #客户端浏览器访问:http://linuxprobe.org/perl/test-mod_perl.cgi |
[4] 配置在RAM上具有代码缓存的注册表模式
12345678910111213 | [root@linuxprobe # vi /etc/httpd/conf.d/perl.conf Alias /perl
<Directory /var/www/perl > SetHandler perl-script PerlResponseHandler ModPerl::Registry # uncomment # PerlResponseHandler ModPerl::PerlRun # comment out PerlOptions +ParseHeaders Options +ExecCGI < /Directory > [root@linuxprobe # systemctl restart httpd |
[5] 访问作为[4]节的示例的测试脚本,然后变量通过重新加载而增加,因为变量被高速缓存在RAM上。所以有必要编辑注册表模式的代码,这里浏览器没刷新一次,$a值加一。
?12345678910111213141516171819202122232425 | [root@linuxprobe # vi /var/www/perl/test-mod_perl.cgi #!/usr/bin/perl use use print "Content-type: text/html\n\n" ; print "<html>\n<body>\n" ; print "<div style=\"width:100%; font-size:40px; font-weight:bold; text-align:center;\">" ; my &number($a ); print "</div>\n</body>\n</html>" ; sub my($a) = @_; $a++; print "number \$a = $a" ; } |
[6]顺便说一下,可以看到mod_perl的状态来访问“http://(主机名或IP地址)/ perl-status”。
二、PHP + PHP-FPM
安装PHP-FPM使PHP脚本速度快
123456789101112131415161718 | [1]安装PHP,请参考这里。 [2]安装PHP-FPM。 [root@linuxprobe # yum -y install php-fpm [3] [root@linuxprobe # vi /etc/httpd/conf.d/php.conf # <FilesMatch # SetHandler application /x-httpd-php SetHandler "proxy:fcgi://127.0.0.1:9000" < /FilesMatch > [root@linuxprobe # systemctl start php-fpm [root@linuxprobe # systemctl enable php-fpm [root@linuxprobe # systemctl restart httpd [4]创建phpinfo并访问它,然后如果“FPM [root@linuxprobe # echo '<?php phpinfo(); ?>' > /var/www/html/info.php |
三、Python + mod_wsgi
安装mod_wsgi(WSGI:Web服务器网关接口),使Python脚本更快
12345678910111213141516171819202122232425 | [1] [root@linuxprobe # yum -y install mod_wsgi [2] /var/www/html/test_wsgi .py. [root@linuxprobe # vi /etc/httpd/conf.d/wsgi.conf # WSGIScriptAlias /test_wsgi
.py [root@linuxprobe # systemctl restart httpd [3] [root@linuxprobe # vi /var/www/html/test_wsgi.py # def status = '200 OK' html = '<html>\n'
'<body>\n'
'<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">\n'
'mod_wsgi Test Page\n' \ '</div>\n'
'</body>\n'
'</html>\n' response_header = [( 'Content-type' , 'text/html' )] start_response(status,response_header) return
|
1234567891011121314 | [4]配置如果你使用Django。 //blog .csdn.net /wh211212/article/details/52992413 ))例如,在“wang”下拥有的“ /home/wang/
/testproject ”下配置“testapp” [root@linuxprobe # vi /etc/httpd/conf.d/django.conf # WSGIDaemonProcess /home/wang/venv/testproject : /home/wang/venv/lib/python2 .7 /site-packages WSGIProcessGroup WSGIScriptAlias /django
.py <Directory /home/wang/venv/testproject > Require all granted < /Directory > [root@linuxprobe # systemctl restart httpd |
四、访问日志分析器:AWstats
安装AWstats,它报告http日志以分析对http服务器的访问。
[1] 安装AWstats。
1234567891011121314151617181920212223242526272829303132333435 | # [root@linuxprobe # yum --enablerepo=epel -y install awstats # [root@linuxprobe # vi /etc/awstats/awstats.linuxprobe.org.conf # # # LogFormat=1 # SiteDomain="linuxprobe.org # HostAliases="localhost " [root@linuxprobe # vi /etc/httpd/conf.d/awstats.conf # Require /24 [root@linuxprobe # systemctl restart httpd # [root@linuxprobe # /usr/share/awstats/linuxproberoot/cgi-bin/awstats.pl -config=linuxprobe.org -update Create /Update
for
"/etc/awstats/awstats.linuxprobe.org.conf"
From in
file
... Phase Searching file ... Phase history
Jumped in
: 0 Parsed in
: 165 Found 0 dropped records, Found 0 comments, Found 0 blank records, Found 0 corrupted records, Found 0 old records, Found 165 new qualified records. |
[2]访问“http://(您的服务器的名称或IP地址/)/awstats/awstats.pl”,然后显示以下屏幕,可以看到httpd日志报告。
以上就是本文的全部内容,希望对大家的学习有所帮助。