How to modify webpage content in Apache
To Modify Webpage content in Apache
Apache web server delivers web content and serve many queries at once. Normally webpage will be stored in /var/www/html. The procedures to modify the webpage content in Apache is explained.
Install the apache package
Execute the following command to install apache and its dependencies.
[root@linuxhelp Desktop]# yum install httpd*
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: centos.webwerks.com
* extras: mirror.nbrc.ac.in
* updates: mirror.nbrc.ac.in
Resolving Dependencies
--> Running transaction check
.
.
.
Installed:
httpd.x86_64 0:2.4.6-40.el7.centos.1 httpd-devel.x86_64 0:2.4.6-40.el7.centos.1
httpd-manual.noarch 0:2.4.6-40.el7.centos.1 httpd-tools.x86_64 0:2.4.6-40.el7.centos.1
Complete!
Go to the default web-root directory (/var/www/html/) and create a new directory.
[root@linuxhelp ~]# cd /var/www/html/
[root@linuxhelp html]# mkdir owndir
Open the newly created directory and create a file as index.html with the following HTML code.
[root@linuxhelp html]# cd owndir/
[root@linuxhelp owndir]# vim index.html
<!DOCTYPE html> <html> <body> <p><a href="https://www.linuxhelp.com">Visit our LINUX tutorial</a></p> </body> </html>
Create an another file for configuring apache with the following configuration.
[root@linuxhelp ~]# vim /etc/httpd/conf.d/http.conf
<virtualhost *:80> servername www.linuxhelp.com documentroot /var/www/html/owndir </virtualhost> <directory /var/www/html/owndir> require all granted </directory>
Set the selinux context to the newly created file at the web-root directory.
[root@linuxhelp ~]# chcon -Rt httpd_sys_content_t /var/www/html/owndir/
Verify whether the assigned selinux policy is configured or not.
[root@linuxhelp ~]# ls -lZ /var/www/html/owndir/
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0 index.html
Enable the apache service.
[root@linuxhelp ~]# systemctl enable httpd.service
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
Enable the firewall settings for apache service and ports and finally reload firewall.
[root@linuxhelp ~]# firewall-cmd --permanent --add-service=http success [root@linuxhelp ~]# firewall-cmd --permanent --add-port=80/tcp success [root@linuxhelp ~]# firewall-cmd --reload success
Now restart the apache service.
[root@linuxhelp ~]# systemctl restart httpd.service
Open the browser and navigate to http://<IP_address> to view the webpage content we created.


Comments ( 0 )
No comments available