Install the Apache Web Server on Oracle Linux 7.8 (Oracle Cloud Infrastructure – OCI)

Configurare noua (How To)

Situatie

You have a Linux server and you want to install an Web Application Server on it.

Solutie

Pasi de urmat

Install the httpd package
The following command installs the httpd package and all of its dependencies.

sudo yum install httpd -y

Enable and start the httpd service
To enable and start the httpd service for immediate access and make the service start automatically after a reboot, run the following command:

sudo apachectl start
sudo systemctl enable httpd

The service starts a web server that listens on TCP port 80 by default.
To check the status of the service, run this command:

sudo service httpd status

Configure firewall rules (Optional):
If you are using a custom firewall profile or an Oracle Cloud Infrastructure instance, open the firewall port for the Apache web service (80).
These commands enable the firewall port for the Apache web service and reload the default firewall service:

sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
sudo firewall-cmd --reload

Test your deployment
With your web browser, go to the domain name or IP address of your system.

http://myserver.example.com/ 
or IP address
http://130.61.....

The Apache web server opens the default test page.

 

Output sample :
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
[cosadm@my-laptop~]$ ssh opc@coslnxhost001
[opc@coslnxhost001 ~]$ uname -a
Linux coslnxhost001 4.14.35-1902.306.2.el7uek.x86_64 #2 SMP Fri Aug 28 14:42:11 PDT 2020 x86_64 x86_64 x86_64 GNU/Linux
[opc@coslnxhost001 ~]$ sudo yum install httpd -y
Loaded plugins: langpacks, ulninfo
ol7_UEKR5 | 2.8 kB 00:00:00
ol7_addons | 2.8 kB 00:00:00
ol7_developer | 2.8 kB 00:00:00
ol7_developer_EPEL | 3.4 kB 00:00:00
ol7_ksplice | 2.8 kB 00:00:00
ol7_latest | 3.4 kB 00:00:00
ol7_oci_included | 2.9 kB 00:00:00
ol7_optional_latest | 2.8 kB 00:00:00
ol7_software_collections | 2.8 kB 00:00:00
(1/19): ol7_UEKR5/x86_64/updateinfo | 97 kB 00:00:00
(2/19): ol7_developer/x86_64/primary_db | 598 kB 00:00:00
(3/19): ol7_developer_EPEL/x86_64/group_gz | 87 kB 00:00:00
(4/19): ol7_developer_EPEL/x86_64/updateinfo | 6.3 kB 00:00:00
(5/19): ol7_developer/x86_64/updateinfo | 7.2 kB 00:00:00
(6/19): ol7_ksplice/updateinfo | 5.8 kB 00:00:00
(7/19): ol7_ksplice/primary_db | 1.1 MB 00:00:00
(8/19): ol7_addons/x86_64/updateinfo | 93 kB 00:00:00
(9/19): ol7_latest/x86_64/group_gz | 134 kB 00:00:00
(10/19): ol7_latest/x86_64/updateinfo | 3.0 MB 00:00:00
(11/19): ol7_addons/x86_64/primary_db | 162 kB 00:00:00
(12/19): ol7_oci_included/x86_64/primary_db | 336 kB 00:00:00
(13/19): ol7_optional_latest/x86_64/updateinfo | 1.2 MB 00:00:00
(14/19): ol7_software_collections/x86_64/updateinfo | 8.7 kB 00:00:00
(15/19): ol7_optional_latest/x86_64/primary_db | 5.1 MB 00:00:00
(16/19): ol7_software_collections/x86_64/primary_db | 5.1 MB 00:00:00
(17/19): ol7_developer_EPEL/x86_64/primary_db | 12 MB 00:00:00
(18/19): ol7_UEKR5/x86_64/primary_db | 14 MB 00:00:01
(19/19): ol7_latest/x86_64/primary_db | 27 MB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-95.0.1.el7 will be installed
--> Processing Dependency: httpd-tools = 2.4.6-95.0.1.el7 for package: httpd-2.4.6-95.0.1.el7.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-95.0.1.el7.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-95.0.1.el7.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-95.0.1.el7.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.4.8-7.el7 will be installed
---> Package apr-util.x86_64 0:1.5.2-6.0.1.el7 will be installed
---> Package httpd-tools.x86_64 0:2.4.6-95.0.1.el7 will be installed
---> Package mailcap.noarch 0:2.1.41-2.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
Package Arch Version Repository Size
========================================================================================================================
Installing:
httpd x86_64 2.4.6-95.0.1.el7 ol7_latest 1.2 M
Installing for dependencies:
apr x86_64 1.4.8-7.el7 ol7_latest 103 k
apr-util x86_64 1.5.2-6.0.1.el7 ol7_latest 91 k
httpd-tools x86_64 2.4.6-95.0.1.el7 ol7_latest 92 k
mailcap noarch 2.1.41-2.el7 ol7_latest 30 k

Transaction Summary
========================================================================================================================
Install 1 Package (+4 Dependent packages)

Total download size: 1.5 M
Installed size: 4.3 M
Downloading packages:
(1/5): apr-1.4.8-7.el7.x86_64.rpm | 103 kB 00:00:00
(2/5): httpd-2.4.6-95.0.1.el7.x86_64.rpm | 1.2 MB 00:00:00
(3/5): httpd-tools-2.4.6-95.0.1.el7.x86_64.rpm | 92 kB 00:00:00
(4/5): mailcap-2.1.41-2.el7.noarch.rpm | 30 kB 00:00:00
(5/5): apr-util-1.5.2-6.0.1.el7.x86_64.rpm | 91 kB 00:00:00
------------------------------------------------------------------------------------------------------------------------
Total 4.5 MB/s | 1.5 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : apr-1.4.8-7.el7.x86_64 1/5
Installing : apr-util-1.5.2-6.0.1.el7.x86_64 2/5
Installing : httpd-tools-2.4.6-95.0.1.el7.x86_64 3/5
Installing : mailcap-2.1.41-2.el7.noarch 4/5
Installing : httpd-2.4.6-95.0.1.el7.x86_64 5/5
Verifying : httpd-tools-2.4.6-95.0.1.el7.x86_64 1/5
Verifying : apr-util-1.5.2-6.0.1.el7.x86_64 2/5
Verifying : mailcap-2.1.41-2.el7.noarch 3/5
Verifying : apr-1.4.8-7.el7.x86_64 4/5
Verifying : httpd-2.4.6-95.0.1.el7.x86_64 5/5

Installed:
httpd.x86_64 0:2.4.6-95.0.1.el7

Dependency Installed:
apr.x86_64 0:1.4.8-7.el7 apr-util.x86_64 0:1.5.2-6.0.1.el7 httpd-tools.x86_64 0:2.4.6-95.0.1.el7
mailcap.noarch 0:2.1.41-2.el7

Complete!
[opc@coslnxhost001 ~]$
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- 
[opc@coslnxhost001 ~]$ sudo apachectl start
[opc@coslnxhost001 ~]$ sudo service httpd status
Redirecting to /bin/systemctl status httpd.service
● httpd.service - The Apache HTTP Server
Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
Active: active (running) since Wed 2020-10-14 07:53:07 GMT; 6s ago
Docs: man:httpd(8)
man:apachectl(8)
Main PID: 17934 (httpd)
Status: "Processing requests..."
Memory: 6.8M
CGroup: /system.slice/httpd.service
├─17934 /usr/sbin/httpd -DFOREGROUND
├─17935 /usr/sbin/httpd -DFOREGROUND
├─17936 /usr/sbin/httpd -DFOREGROUND
├─17937 /usr/sbin/httpd -DFOREGROUND
├─17938 /usr/sbin/httpd -DFOREGROUND
└─17939 /usr/sbin/httpd -DFOREGROUND

Oct 14 07:53:07 coslnxhost001 systemd[1]: Starting The Apache HTTP Server...
Oct 14 07:53:07 coslnxhost001 systemd[1]: Started The Apache HTTP Server.
[opc@coslnxhost001 ~]$ sudo systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[opc@coslnxhost001 ~]$ sudo service httpd status
--- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- 
[opc@coslnxhost001 ~]$ sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
success
[opc@coslnxhost001 ~]$ sudo firewall-cmd --reload
success
[opc@coslnxhost001 ~]$

Tip solutie

Permanent

Voteaza

(24 din 50 persoane apreciaza acest articol)

Despre Autor

Leave A Comment?