• Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • Categories
    Category
    {{ postCtrl.tags }}
    • {{ category.tag_type }}

      • {{tag.tag_name}}
      • View more
  • News
  • Tutorials
  • Forums
  • Tags
  • Users
Tutorial News Comments FAQ Related Articles

How to modify webpage content in Apache

{{postValue.id}}


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.

Browser

Linuxhelp tutorial

Tags:
michael
Author: 

Comments ( 0 )

No comments available

Add a comment
{{postCtrl.cmtErrMsg}}

Frequently asked questions ( 5 )

Q

how to Install the apache package in centos 7?

A

you can install the apache package by following command
# yum install httpd

Q

What are the content to be edited in apache config file to host web page?

A

Use the following content to edit the apache config file
# vim /etc/httpd/conf.d/http.conf

servername www.linuxhelp.com
documentroot /var/www/html/owndir


require all granted

Q

in which location the web root directory located for apache?

A

The command to view web root dir for apache is
# cd /var/www/html/

Q

How to change the ownership of the web root directory file in apache?

A

you can use the following command to change the ownership of web root directory
# chown -R apache: apache

Q

how to add the http port to host webpage in apache?

A

Use the following command to add the port for http in apache
# firewall-cmd --permanent --add-service=http

# firewall-cmd --permanent --add-port=80/tcp

Back To Top!
Rank
User
Points

Top Contributers

userNamenaveelansari
135850

Top Contributers

userNameayanbhatti
92510

Top Contributers

userNamehamzaahmed
32150

Top Contributers

1
userNamelinuxhelp
31040

Top Contributers

userNamemuhammadali
24500
Can you help Sebastian ?
How to change non required to required field in SuiteCRM Custom/Default Modules

How to change not required to the required field in SuiteCRM Custom/Default Modules?

Networking
  • Routing
  • trunk
  • Netmask
  • Packet Capture
  • domain
  • HTTP Proxy
Server Setup
  • NFS
  • KVM
  • Memory
  • Sendmail
  • WebDAV
  • LXC
Shell Commands
  • Cloud commander
  • Command line archive tools
  • last command
  • Shell
  • terminal
  • Throttle
Desktop Application
  • Linux app
  • Pithos
  • Retrospect
  • Scribe
  • TortoiseHg
  • 4Images
Monitoring Tool
  • Monit
  • Apache Server Monitoring
  • EtherApe 
  • Arpwatch Tool
  • Auditd
  • Barman
Web Application
  • Nutch
  • Amazon VPC
  • FarmWarDeployer
  • Rukovoditel
  • Mirror site
  • Chef
Contact Us | Terms of Use| Privacy Policy| Disclaimer
© 2025 LinuxHelp.com All rights reserved. Linux™ is the registered trademark of Linus Torvalds. This site is not affiliated with linus torvalds in any way.