欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

CentOS 7.2配置Apache服務(wù)httpd(下)

 更新時(shí)間:2016年11月17日 16:56:57   作者:shaonbean  
這篇文章主要為大家詳細(xì)介紹了CentOS 7.2配置Apache服務(wù) httpd上篇,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

一、Perl + mod_perl

安裝mod_perl使Perl腳本速度快

[1] 安裝mod_perl
# 從EPEL安裝
[root@linuxprobe ~]# yum --enablerepo=epel -y install mod_perl
[2] 配置PerlRun模式,總是將Perl解釋器放在RAM上。 
[root@linuxprobe ~]# vi /etc/httpd/conf.d/perl.conf
# line 15: 取消注釋 ( check codes and output warnings to logs )

PerlSwitches -w
# line 24: 取消注釋

PerlSwitches -T
# line 30-36: 取消注釋像下面一樣

Alias /perl /var/www/perl
<Directory /var/www/perl> # the directory for mod_perl environment

  SetHandler perl-script # processes files as perl-scripts under this directory

#  AddHandler perl-script .cgi
# set specific extension if do do not want to processes all files as CGI

#  PerlResponseHandler ModPerl::Registry
  PerlResponseHandler ModPerl::PerlRun
# specify PerlRun mode

  PerlOptions +ParseHeaders
  Options +ExecCGI
</Directory>
# line 43-49: 取消注釋并添加如下信息

<Location /perl-status>
  SetHandler perl-script
  PerlResponseHandler Apache2::Status
  Require ip 127.0.0.1 10.1.1.1/24
# add access permission

#  Order deny,allow
#  Deny from all
#  Allow from .example.com
</Location>
[root@linuxprobe ~]# systemctl restart httpd

[3] 創(chuàng)建測(cè)試腳本以確保設(shè)置不是ploblem。如果顯示如下所示的結(jié)果,就可以。 
[root@linuxprobe ~]# mkdir /var/www/perl
[root@linuxprobe ~]# vi /var/www/perl/test-mod_perl.cgi

#!/usr/bin/perl

use strict;
use warnings;

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 $a = 0;
&number();

print "</div>\n</body>\n</html>";

sub number {
  $a++;
  print "number \$a = $a";
}

[root@linuxprobe ~]# chmod 705 /var/www/perl/test-mod_perl.cgi 
#客戶端瀏覽器訪問(wèn):http://linuxprobe.org/perl/test-mod_perl.cgi

[4]  配置在RAM上具有代碼緩存的注冊(cè)表模式

[root@linuxprobe ~]# vi /etc/httpd/conf.d/perl.conf
Alias /perl /var/www/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] 訪問(wèn)作為[4]節(jié)的示例的測(cè)試腳本,然后變量通過(guò)重新加載而增加,因?yàn)樽兞勘桓咚倬彺嬖赗AM上。所以有必要編輯注冊(cè)表模式的代碼,這里瀏覽器沒刷新一次,$a值加一。

[root@linuxprobe ~]# vi /var/www/perl/test-mod_perl.cgi

#!/usr/bin/perl

use strict;
use warnings;

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 $a = 0;

&number($a
);

print "</div>\n</body>\n</html>";

sub number {

  my($a) = @_;

  $a++;
  print "number \$a = $a";
}

[6]順便說(shuō)一下,可以看到mod_perl的狀態(tài)來(lái)訪問(wèn)“http://(主機(jī)名或IP地址)/ perl-status”。

二、PHP + PHP-FPM

安裝PHP-FPM使PHP腳本速度快

[1]安裝PHP,請(qǐng)參考這里。   
[2]安裝PHP-FPM。  
[root@linuxprobe ~]# yum -y install php-fpm
[3]   配置Apache httpd。
[root@linuxprobe ~]# vi /etc/httpd/conf.d/php.conf
# line 5: change like follows
<FilesMatch \.php$>
#
  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]創(chuàng)建phpinfo并訪問(wèn)它,然后如果“FPM / FastCGI”顯示,它是確定。  
[root@linuxprobe ~]# echo '<?php phpinfo(); ?>' > /var/www/html/info.php 

三、Python + mod_wsgi

安裝mod_wsgi(WSGI:Web服務(wù)器網(wǎng)關(guān)接口),使Python腳本更快

[1] 安裝mod_wsgi .
[root@linuxprobe ~]# yum -y install mod_wsgi
[2] 例如,將mod_wsgi配置為可以訪問(wèn)/ test_wsgi,后端是/var/www/html/test_wsgi.py.
[root@linuxprobe ~]# vi /etc/httpd/conf.d/wsgi.conf
# create new

WSGIScriptAlias /test_wsgi /var/www/html/test_wsgi.py
[root@linuxprobe ~]# systemctl restart httpd

[3] 創(chuàng)建您在上面設(shè)置的測(cè)試腳本.
[root@linuxprobe ~]# vi /var/www/html/test_wsgi.py
# create new

def application(environ,start_response):
  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 [html]

[4]配置如果你使用Django。 ([參考安裝Django](http://blog.csdn.net/wh211212/article/details/52992413))例如,在“wang”下?lián)碛械摹?home/wang/ venv/testproject”下配置“testapp”

[root@linuxprobe ~]# vi /etc/httpd/conf.d/django.conf
# create new

WSGIDaemonProcess testapp python-path=/home/wang/venv/testproject:/home/wang/venv/lib/python2.7/site-packages
WSGIProcessGroup testapp
WSGIScriptAlias /django /home/wang/venv/testproject/testproject/wsgi.py

<Directory /home/wang/venv/testproject>
  Require all granted
</Directory>

[root@linuxprobe ~]# systemctl restart httpd 

四、訪問(wèn)日志分析器:AWstats

安裝AWstats,它報(bào)告http日志以分析對(duì)http服務(wù)器的訪問(wèn)。

[1] 安裝AWstats。 

# install from EPEL
[root@linuxprobe ~]# yum --enablerepo=epel -y install awstats
# awstats.(hostname).conf是自動(dòng)生成的
[root@linuxprobe ~]# vi /etc/awstats/awstats.linuxprobe.org.conf
# line 122: change
# if your config for log format in httpd.conf is 'combined' Set here '1'
# If log-config is 'common' set here '4', but in this case, some informations can't be get (browser info and so on)
LogFormat=1
# line 153: specify your hostname
SiteDomain="linuxprobe.org
# line 168: set IP address you'd like to exclude
HostAliases="localhost 127.0.0.1 REGEX[server\.world$] REGEX[^10\.1\.1\.]
"
[root@linuxprobe ~]# vi /etc/httpd/conf.d/awstats.conf
# line 30: IP address you permit to access
Require ip 10.1.1.0/24

[root@linuxprobe ~]# systemctl restart httpd
# generate reports ( reports are updated for hourly by Cron )

[root@linuxprobe ~]# /usr/share/awstats/linuxproberoot/cgi-bin/awstats.pl -config=linuxprobe.org -update

Create/Update database for config "/etc/awstats/awstats.linuxprobe.org.conf" by AWStats version 7.4 (build 20150714)
From data in log file "/var/log/httpd/access_log"...
Phase 1 : First bypass old records, searching new record...
Searching new records from beginning of log file...
Phase 2 : Now process new records (Flush history on disk after 20000 hosts)...
Jumped lines in file: 0
Parsed lines in file: 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]訪問(wèn)“http://(您的服務(wù)器的名稱或IP地址/)/awstats/awstats.pl”,然后顯示以下屏幕,可以看到httpd日志報(bào)告。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Linux下yum常用命令匯總

    Linux下yum常用命令匯總

    yum(全稱為 Yellow dog Updater, Modified)是一個(gè)在Fedora和RedHat以及SUSE中的Shell前端軟件包管理器?;禦PM包管理,能夠從指定的服務(wù)器自動(dòng)下載RPM包并且安裝,可以自動(dòng)處理依賴性關(guān)系,并且一次安裝所有依賴的軟體包,無(wú)須繁瑣地一次次下載、安裝。
    2014-11-11
  • ubuntu20.04連接wifi的方法(2種)

    ubuntu20.04連接wifi的方法(2種)

    這篇文章主要介紹了ubuntu20.04連接wifi的方法(2種),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • 詳解Centos7.2安裝Nginx實(shí)現(xiàn)負(fù)載平衡

    詳解Centos7.2安裝Nginx實(shí)現(xiàn)負(fù)載平衡

    本篇文章主要介紹了詳解Centos7.2安裝Nginx實(shí)現(xiàn)負(fù)載平衡,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-03-03
  • Apache中使非偽靜態(tài)url跳轉(zhuǎn)到偽靜態(tài)url的方法

    Apache中使非偽靜態(tài)url跳轉(zhuǎn)到偽靜態(tài)url的方法

    這篇文章主要介紹了Apache中使非偽靜態(tài)url跳轉(zhuǎn)到偽靜態(tài)url的方法,主要是在使用.htaccess時(shí)的問(wèn)題,需要的朋友可以參考下
    2015-07-07
  • Linux系統(tǒng)(CentOS7安裝)安裝JDK8的教程詳解

    Linux系統(tǒng)(CentOS7安裝)安裝JDK8的教程詳解

    這篇文章主要介紹了Linux系統(tǒng)(CentOS7安裝)安裝JDK8的教程,本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-01-01
  • 我常用的一些linux命令小結(jié)

    我常用的一些linux命令小結(jié)

    linux命令熟練掌握后對(duì)效率提升有多大,這篇文章主要介紹了我常用的一些linux命令小結(jié),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2019-01-01
  • Linux 下解壓 rar 文件的方法

    Linux 下解壓 rar 文件的方法

    這篇文章主要介紹了Linux 下解壓 rar 文件的方法,需要的朋友可以參考下
    2018-07-07
  • Linux 系統(tǒng)下安裝JDK1.8的教程詳解

    Linux 系統(tǒng)下安裝JDK1.8的教程詳解

    這篇文章主要介紹了Linux 系統(tǒng)下安裝JDK1.8的教程詳解,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2018-11-11
  • 詳解虛擬機(jī)下CentOS 6.5配置IP地址的三種方法

    詳解虛擬機(jī)下CentOS 6.5配置IP地址的三種方法

    本篇文章主要介紹了虛擬機(jī)下CentOS 6.5配置IP地址的三種方法,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下。
    2017-03-03
  • Apache中配置支持CORS(跨域資源共享)實(shí)例

    Apache中配置支持CORS(跨域資源共享)實(shí)例

    這篇文章主要介紹了Apache中配置支持CORS(跨域資源共享)實(shí)例,本文給出了一個(gè)完整的apache、PHP、JavaScript結(jié)合實(shí)現(xiàn)的跨域資源共享實(shí)例,需要的朋友可以參考下
    2015-01-01

最新評(píng)論