CentOS 7.2 Configure Apache service httpd (next) _linux

Source: Internet
Author: User
Tags fpm install php perl interpreter php script phpinfo require

One, Perl + mod_perl

Install Mod_perl to make Perl scripts faster

[1] Install Mod_perl # from Epel install [root@linuxprobe ~]# yum--enablerepo=epel-y Install] mod_perl [2] Configure the Perlrun mode, always place the Perl interpreter on RAM. [Root@linuxprobe ~]# vi/etc/httpd/conf.d/perl.conf # line 15: Uncomment (check codes and output warnings to logs) Perlswi Tches-w # line 24: Uncomment Perlswitches-t # line 30-36: Uncomment the same alias/perl/var/www/perl as the following <DIRECTORY/VAR/WWW/PERL&G T

# 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 don't want to processes all files as CGI # Perlresponseh Andler modperl::registry perlresponsehandler Modperl::P erlrun # Specify Perlrun mode perloptions +ParseHeaders Opti ONS +execcgi </Directory> # line 43-49: Uncomment and add the following information <Location/perl-status> SetHandler perl-script perlre  Sponsehandler 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] Create test scripts to ensure that the settings are not ploblem. 
If you show the results shown below, you can. [Root@linuxprobe ~]# Mkdir/var/www/perl [root@linuxprobe ~]# vi/var/www/perl/test-mod_perl.cgi #!/usr/bin/perl use str
ICT

Use warnings;
print "content-type:text/html\n\n";
print " 

[4] A registry pattern configured with code caching on RAM

[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::P erlrun # comment out

  perloptions +parseheaders
  Options +execcgi
</ Directory>
[root@linuxprobe ~]# systemctl Restart httpd 

[5] Access the test script as an example of the [4] section, and then the variable is incremented by reloading because the variable is cached on RAM. So it is necessary to edit the registry mode code, where the browser did not refresh once, $a value plus one.

[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 " 
 

[6] By the way, you can see the state of the mod_perl to access the http://(hostname or IP address)/perl-status.

Second, PHP + php-fpm

Install PHP-FPM to make PHP script faster

[1] Install PHP, please refer to here.   
[2] install PHP-FPM.  
[root@linuxprobe ~]# yum-y Install php-fpm
[3]   Configure 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] creates phpinfo and accesses it, and then if "fpm/fastcgi" is displayed, it is OK.  
[Root@linuxprobe ~]# Echo ' <?php phpinfo ()?> ' >/var/www/html/info.php 

Three, Python + Mod_wsgi

Install MOD_WSGI (wsgi:web Server gateway Interface) to make Python scripts faster

[1] Install MOD_WSGI.
[Root@linuxprobe ~]# yum-y Install Mod_wsgi
[2] For example, the MOD_WSGI is configured to be accessible/TEST_WSGI, and the backend is/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] Create the test script that you set up above.
[Root@linuxprobe ~]# vi/var/www/html/test_wsgi.py
# Create new

def application (environ,start_response):
  status = ' OK '
  html = '  
 

[4] Configuration if you use Django. ([Reference installation Django] (http://blog.csdn.net/wh211212/article/details/52992413) For example, under "Wang" owned "/home/wang/venv/ TestProject Configure "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 

Iv. Access Log Analyzer: AWstats

Installs Awstats, which reports HTTP logs to analyze access to HTTP servers.

[1] Install Awstats.

# Install from Epel [root@linuxprobe ~]# yum--enablerepo=epel-y install Awstats # awstats. (hostname). conf is automatically generated [root@l  Inuxprobe ~]# 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-case, some informations can ' t being get (BR Owser info and so in) 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 addresses you permit to access Require IP 10.1.1.0/24 [Root@linuxprobe ~]# systemctl Restart httpd # Generate reports (reports are updated for hourly to Cron) [Root@linuxp Robe ~]#/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 the 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, Fo

 und 0 corrupted records, Found 0 old records, Found 165 new qualified.

[2] Access the http://(your server name or IP address/)/awstats/awstats.pl, and then display the following screen to see the httpd log report.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.