一区二区三区在线-一区二区三区亚洲视频-一区二区三区亚洲-一区二区三区午夜-一区二区三区四区在线视频-一区二区三区四区在线免费观看

服務(wù)器之家:專注于服務(wù)器技術(shù)及軟件下載分享
分類導(dǎo)航

Linux|Centos|Ubuntu|系統(tǒng)進(jìn)程|Fedora|注冊表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服務(wù)器之家 - 服務(wù)器系統(tǒng) - Centos - CentOS 7.2配置Apache服務(wù)httpd(下)

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

2021-11-26 16:44shaonbean Centos

這篇文章主要為大家詳細(xì)介紹了CentOS 7.2配置Apache服務(wù) httpd上篇,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

一、perl + mod_perl

安裝mod_perl使perl腳本速度快

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
[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)建測試腳本以確保設(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
#客戶端瀏覽器訪問:http://linuxprobe.org/perl/test-mod_perl.cgi

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

[4]  配置在ram上具有代碼緩存的注冊表模式

?
1
2
3
4
5
6
7
8
9
10
11
12
13
[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] 訪問作為[4]節(jié)的示例的測試腳本,然后變量通過重新加載而增加,因?yàn)樽兞勘桓咚倬彺嬖趓am上。所以有必要編輯注冊表模式的代碼,這里瀏覽器沒刷新一次,$a值加一。

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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[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]順便說一下,可以看到mod_perl的狀態(tài)來訪問“http://(主機(jī)名或ip地址)/ perl-status”。

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

二、php + php-fpm

安裝php-fpm使php腳本速度快

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
[1]安裝php,請參考這里。  
[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并訪問它,然后如果“fpm / fastcgi”顯示,它是確定。 
[root@linuxprobe ~]# echo '<?php phpinfo(); ?>' > /var/www/html/info.php

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

三、python + mod_wsgi

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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[1] 安裝mod_wsgi .
[root@linuxprobe ~]# yum -y install mod_wsgi
[2] 例如,將mod_wsgi配置為可以訪問/ 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è)置的測試腳本.
[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]

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

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[4]配置如果你使用django。 ([參考安裝django](http://blog.csdn.net/wh211212/article/details/52992413))例如,在“wang”下?lián)碛械?ldquo;/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

四、訪問日志分析器:awstats

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

[1] 安裝awstats。 

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# install from epel
[root@linuxprobe ~]# yum --enablerepo=epel -y install awstats
# awstats.(hostname).conf是自動生成的
[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]訪問“http://(您的服務(wù)器的名稱或ip地址/)/awstats/awstats.pl”,然后顯示以下屏幕,可以看到httpd日志報(bào)告。

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

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持服務(wù)器之家。

原文鏈接:http://blog.csdn.net/wh211212/article/details/52994505

延伸 · 閱讀

精彩推薦
  • Centoscentos不小心刪除/root目錄該如何解決?

    centos不小心刪除/root目錄該如何解決?

    一些朋友最近在問小編centos不小心刪除/root目錄該如何解決?今天小編就為大家分享centos不小心刪除/root目錄解決辦法;希望對大家會有幫助,有需要的朋友...

    腳本之家8022019-05-29
  • CentosCentOS6.5下Redis安裝與配置詳細(xì)步驟

    CentOS6.5下Redis安裝與配置詳細(xì)步驟

    本篇文章主要介紹了CentOS6.5下Redis安裝與配置詳細(xì)步驟,詳細(xì)介紹redis單機(jī)單實(shí)例安裝與配置,服務(wù)及開機(jī)自啟動。有興趣的可以了解一下。...

    飛流11452021-12-24
  • CentosCentos7運(yùn)用/dev/shm進(jìn)行網(wǎng)站優(yōu)化

    Centos7運(yùn)用/dev/shm進(jìn)行網(wǎng)站優(yōu)化

    這篇文章主要介紹了LINUX中Centos7運(yùn)用/dev/shm進(jìn)行網(wǎng)站優(yōu)化相關(guān)知識點(diǎn),對此有興趣的朋友參考學(xué)習(xí)下。...

    彬菌9912022-03-02
  • Centoscentos 安裝與操作方法

    centos 安裝與操作方法

    這篇文章主要介紹了centos 安裝與操作方法,需要的朋友可以參考下...

    centos之家5272019-07-11
  • CentosCentOS 6.6實(shí)現(xiàn)永久修改DNS地址的方法

    CentOS 6.6實(shí)現(xiàn)永久修改DNS地址的方法

    這篇文章主要介紹了CentOS 6.6實(shí)現(xiàn)永久修改DNS地址的方法,涉及針對CentOS配置文件的相關(guān)設(shè)置技巧,具有一定參考借鑒價(jià)值,需要的朋友可以參考下 ...

    Linux社區(qū)4472020-08-21
  • CentosCentOS7設(shè)置日期和時(shí)間方法以及基本概念介紹

    CentOS7設(shè)置日期和時(shí)間方法以及基本概念介紹

    這篇文章主要介紹了CentOS7設(shè)置日期和時(shí)間方法以及基本概念介紹,本文講解使用CentOS7中的新命令timedatectl設(shè)置日期時(shí)間方法,需要的朋友可以參考下 ...

    CentOS之家6522019-09-19
  • CentosCentOS下Uptime命令詳解

    CentOS下Uptime命令詳解

    在Linux下,我們可以使用uptime命令,而且此命令不必使用root權(quán)限。uptime命令在系統(tǒng)中已經(jīng)默認(rèn)安裝了。今天小編為大家?guī)淼氖荂entOS下Uptime命令詳解;希望...

    CentOS之家11482019-06-19
  • CentosCentos 7開啟網(wǎng)卡自動獲取IP的詳細(xì)方法

    Centos 7開啟網(wǎng)卡自動獲取IP的詳細(xì)方法

    本篇文章主要介紹了Centos 7開啟網(wǎng)卡自動獲取IP的詳細(xì)方法,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧...

    凌鋒8972021-12-29
主站蜘蛛池模板: 啪啪模拟器 | 午夜综合网 | 青柠影视在线播放观看高清 | 亚洲无人区乱码中文字幕 | 国产91一区二区在线播放不卡 | 青草影院在线观看 | 视频一区二区三区在线 | 我的家教老师在线观看 | 亚洲26uuuu最新地址 | 深夜在线网站 | 韩国一级淫片特黄特刺激 | 免费日批视频 | 嫩交18xxxx | 蜜月aⅴ免费一区二区三区 蜜桃影像传媒推广 | 久久一本岛在免费线观看2020 | 色倩网站 | 草草视频免费在线观看 | 四虎精品视频在线永久免费观看 | 免费一级夫妻a | 日本人和黑人一级纶理片 | 亚洲精品国产AV成人毛片 | 999久久久免费精品国产牛牛 | 亚洲精品国产A久久久久久 亚洲精品福利一区二区在线观看 | 大胸孕妇孕交pregnantsex 大象视频污 | 日本大尺度激情做爰叫床 | 91av最新地址 | 久久精品无码人妻无码AV蜜臀 | 欧美帅老头oldmangay | 95在线观看精品视频 | 国产v日韩v欧美v精品专区 | 99热这里只有精品国产在热久久 | 日韩久久网 | 紧身牛仔裤美女被啪啪久久网 | 欧美成年黄网站色高清视频 | 国产精品久热 | 精品国产品国语在线不卡丶 | 国产一区二区三区四卡 | tk白嫩玉足脚心vk | 四虎com| a毛片久久免费观看 | 大团圆6全文在线阅读 |