How to Set up Apache Web Server to Utilize NFS Shared HTML+PHP5 Files

How to Set up Apache Web Server to Utilize NFS Shared HTML+PHP5 Files

11:18, 07.03.2024

Article Content
arrow

  • Setting Up the NFS Client Configuration
  • Configuring /etc/idmapd.conf for the NFS Client
  • Mounting NFS File Systems via /etc/fstab
  • Apache Software Installation
  • Installing Required PHP5 and Its Modules
  • Enabling Memcached Support for PHP5
  • Extracting Real Source IP for Forwarded HTTP Requests
  • Setting Up iptables to Allow Access to the Web Server
  • Activating Apache Server
  • Integration of Apache Web Server with NFS for HTML+PHP5 Files

Prior to sharing some exact recommendations and steps according to utilizing NFS-shared HTML+PHP5 Files on the Apache server, let’s get a basic understanding of the Apache web server. For quite a long time Apache server was a top solution that existed online. This option was the only option for thousands if not millions of sites worldwide. It is most likely that most companies/organization has tried this solution.

Apache Foundation has started this project and till today this solution is highly popular among users globally. Apache is a core system that guarantees a certain flexibility level and static hosting. Due to MPM, it is possible to reach the maximized performance on Linux systems. Also, its core functionality relies on a supported and large series of modules. These models provide all the basics starting from proxy services and ending with authentication.     

Apache server is needed for guaranteeing access to the dynamic content and that is possible to accomplish with HTTPS or HTTP protocol. According to our practical experience in the field, we can guide you through the process of setting up an Apache web server. So, if that sounds important to you, just continue and you will get all the needed instructions according to the process.    

Setting Up the NFS Client Configuration

For the installation of NFS client, you should use yum command:

# yum install nfs-utils nfs4-acl-tools

To activate the client services of NFSv4, the following commands should be used:

# chkconfig nfslock on
# chkconfig rpcbind on
# chkconfig rpcidmapd on

Configuring /etc/idmapd.conf for the NFS Client

For the entering of the configuration file, you will need the next line:

 # vi /etc/idmapd.conf

Once you have entered the file, set it up as per the server domain name:

Domain = hostzealot.com
[Mapping]
Nobody-User = nobody

Once the file is closed with the needed changes, start the client services by using the following:

# /sbin/service rpcidmapd start
# /sbin/service rpcbind start
# /sbin/service nfslock start

Mounting NFS File Systems via /etc/fstab

Start with the next command:

# showmout -e vm05

Mounting NFS File Systems begins with editing /etc/fstab with:

# vi /etc/fstab

Add the following to the file:

vm05:/exports/html/var/www/html  nfs4   orsize=32768,wsize=32768,intr,hard,proto=tcp,sync

Close the file with the made changes, and try to determine whether netfs service is on with:

# chkconfig netfs on

The last thing to accomplish is to check whether Apache user can find the file:

# su - apache
$ ls /var/www/html/
$ exit
#

Because of the security policy restrictions, root or other users can not get access to check /var/www/html. This is considered to be a default standard so only Apache users can get access to DocumentRoot.

Apache Software Installation

Here the process starts with the yum command:

# yum install httpd

Installing Required PHP5 and Its Modules

The next important step includes the installation of the php5 and other crucial models that give access to graphics, my sql, and more. For the installation use the following:

# yum install -y php-pear php-common php-bcmath php-mbstring php-cli php-pdo php-php-gettext php-mcrypt php-gd php-xml php-pecl-apc
php php-mysql php-xmlrpc

Enabling Memcached Support for PHP5

For getting memcached server access on vm3, there is a necessity for memcache server installation for php:

# yum install -y php-pecl-memcache

Extracting Real Source IP for Forwarded HTTP Requests

To get a real source IP for Forwarded HTTP requests, use the following command:

# yum -y install mod_extract_forwarded package

For editing this file, you should use:

# vi /etc/httpd/conf.d/mod_extract_forwarded.conf

Once you have entered this configuration file, correct or add the next lines:

## Accept real ip from our nginx reverse proxy  at 192.168.1.1 ##
MEFaccept 192.168.1.1

Once the changes are saved, then reload the Apache server.

Setting Up iptables to Allow Access to the Web Server

Here, you will need to edit /etc/sysconfig/iptables with the next data. The line should be put between DROP and final LOG:

-A INPUT -m state --state NEW -p tcp -s 192.168.1.0/24 --dport 80 -j ACCEPT

Close the file with the changes and restart the server with:

# /sbin/service iptables restart
# /sbin/iptables -L -v -n

Activating Apache Server

To activate the server use the following:

 # chkconfig httpd on
# service httpd start

Then insert the url address:

http://your_url/

Integration of Apache Web Server with NFS for HTML+PHP5 Files

To edit /etc/httpd/conf/httpd.conf, fill in the next:

   # vi /etc/httpd/conf/httpd.conf

In the file, there should be made certain correction or adds for the Document Root. There you should specify the nfs location in such a way:  

DocumentRoot "/var /www/ html"
<directory "/var /www/ html">

After that save the changes that were made.

PHP is a really popular language for scripting. It is possible to change the configuration by editing /etc/httpd/conf.d/php.conf, here you will need to insert:

# cat /etc/httpd/conf.d/php.conf
views 4m, 3s
views 2
Share

Was this article helpful to you?

VPS popular offers

Other articles on this topic

Backup VPS
Backup VPS
cookie

Accept cookies & privacy policy?

We use cookies to ensure that we give you the best experience on our website. If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the HostZealot website.