RHCE Work With Apache HTTPD Web Service Part 6-Integrating Dynamic Web Content Serving PHP content Dev Ops Lanka

Hello Friends previous lesson we have discuss how to serve dynamic web content and serving CGI scripts using Apache HTTPD.if you missed that lesson you can quick go through that lesson

https://devopslanka.com/2018/02/06/rhce-work-apache-httpd-web-service-part-5-intergrating-dynamic-web-content-dev-ops-lanka/

Today lesson we are discuss about how to serve php content in apache httpd and serving dynamic python content.

Serving Dynamic PHP content in Apache HTTPD

For serving php content we need module called mod_php lets install mod_php

after installing mod_php now im changing directory to /var/www/devops and there is already index.html file so i have rename index.html as index.123 and create index.php file there

now /var/www/devops/index.php file like this

then restart apache httpd

Then navigate to

https://devopslanka.com

now its showing php file

Serving Dynamic Python Content in Apache HTTPD

Python script also can be served via old CGI method but there is new Protocol Called WSGI(Web Server Gateway Interface) using this protocol.Apache HTTPD can server python script also.To do this there is two main step

  1. Install mod_wsgi package
  2. Add WSGIScriptAlias

Install mod_wsgi

After that add WSGIScriptAlias to the virtual host file

easy way to do this is using readme file

example says

and sample wsgi file should like this myapp.wsgi

so lets create sample example there and add it to our virtual host file

lets make directory

And create myapp.wsgi file there

now add to virtual host file

add this block below of the virtual host file

 

checked with httpd -t syntax ok

restart apache httpd

Now everything is ok now navigate to

https://devopslanka.com/myapp/

but this is showing error Forbidden

When you analize error log for apache httpd you can see “client denied by server configuration ..”

 

Client denied by server configuration wsgi Solved

To fix this issue in RHEL7

comment these lines in this block

#Order allow,deny

#Allow from all and add Require all granted line

Then restart apache httpd

Now navigate to https://devopslanka.com/myapp

Its working Perfectly.

If you like this post please share on facebook,twitter and google plus.if you have any question please leave a comment below i’m happy to help you.See you in a another post

Have a Good Day

Sameera Dissanayaka

 

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *