Oracle linux apache mysql php

Install the Apache Web Server

Apache has been in active development since 1993 and over time has become one of the most popular web servers in the world. The Apache web server is a key component of the LAMP (Linux, Apache, Oracle MySQL and Perl/PHP) software stack and continues to be widely used today.

The Apache web server is directly available from the Application Streams repository in Oracle Linux 8 or later and is simple to deploy and configure.

Prerequisites

Objectives

At the end of this tutorial, you should be able to do the following:

  • Install and configure the Apache package
  • Configure the firewall
  • Apply Apache configurations
  • Secure web services

Installing and configuring the web server package

sudo systemctl enable --now httpd.service 
sudo systemctl status httpd 
sudo firewall-cmd --add-service=http --permanent sudo firewall-cmd --reload 

Configuring Apache

To change the root path for your web server, do not edit the /etc/httpd/conf/httpd.conf file directly. Instead, as a preferred method, create a site-specific configuration file in the /etc/httpd/conf.d directory.

In the following example, the file /etc/httpd/conf.d/example.com.conf is created to contain configurations for virtual hosts.

    Create virtual hosts by adding the following information in /etc/httpd/conf.d/example.com.conf :

ErrorLog /var/log/httpd/example.com_error.log
CustomLog /var/log/httpd/example.com_access.log combined

sudo mkdir -p /var/www/example.com/html sudo echo "example.com" > /var/www/example.com/html/index.html sudo chown -R apache:apache /var/www/example.com/html 

On systems where SELinux is enabled in enforcing mode and pages are not served from within the /var/www directory , you must apply the correct security context to the DocumentRoot directory. For example, to serve web pages from the /mnt/example.com directory, type:

sudo semanage fcontext -a -t httpd_sys_content_t "/mnt/example.com(/.*)?" sudo restorecon -Rv /mnt/example.com/ 
sudo systemctl restart httpd 

Securing the web service

As a best practice, secure all communications between a web browser and your Apache server by using HTTPS. For a secure setup, a TLS certificate is required.

Note:
Oracle strongly recommends that you use a TLS certificate that has been signed by an external Certificate Authority (CA). See Oracle Linux: Managing Certificates and Public Key Infrastructure for more information.

sudo dnf install mod_ssl sudo systemctl restart httpd 

SSLEngine on SSLCertificateFile /etc/pki/tls/private/certificate.crt
SSLCertificateKeyFile /etc/pki/tls/private/private.key

ErrorLog /var/log/httpd/example.com_error.log
CustomLog /var/log/httpd/example.com_access.log combined

sudo systemctl restart httpd 
sudo firewall-cmd --add-service=https --permanent sudo firewall-cmd --reload 

More Learning Resources

Explore other labs on docs.oracle.com/learn or access more free learning content on the Oracle Learning YouTube channel. Additionally, visit education.oracle.com/learning-explorer to become an Oracle Learning Explorer.

Читайте также:  Comodo antivirus для linux установка

For product documentation, visit Oracle Help Center.

Install the Apache Web Server

Copyright © 2020, Oracle and/or its affiliates.

Источник

Free Tier: Install Apache and PHP on an Oracle Linux Instance

In this tutorial, you use an Oracle Cloud Infrastructure Free Tier account to set up an Oracle Linux instance. Then, you install an Apache web server and PHP and access your new server from the internet.

This tutorial covers all the steps necessary to set up a virtual network for your host and connect the host to the internet. Key tasks include how to:

  • Set up a compartment for your development work.
  • Install your Oracle Linux instance and connect it to your Virtual Cloud Network (VCN).
    • Set up an Oracle Cloud Infrastructure virtual cloud network and related network services required for your host to connect to the internet.
    • Set up ssh encryption keys to access your Oracle Linux Server.

    Here is a simplified diagram of the setup for your Linux instance.

    A diagram of the components needed to run an Apache webserver on Oracle Cloud Infrastructure

    For additional information, see:

    Before You Begin

    To successfully complete this tutorial, you must have the following:

    • An Oracle Cloud Infrastructure Free Tier account. Start for free.
    • A MacOS, Linux, or Windows computer with ssh support installed.

    1. Set up a Compartment for Development

    Configure a compartment for your development.

    Create a compartment for the resources that you create in this tutorial.

    1. Sign in to the Oracle Cloud Infrastructure Console.
    2. Open the navigation menu and click Identity & Security. Under Identity, click Compartments.
    3. Click Create Compartment.
    4. Fill in the following information:
      • Name:
      • Description: Compartment for .
      • Parent Compartment:(root)
    5. Click Create Compartment.

    2. Install an Oracle Linux Instance

    Use the Create a VM Instance workflow to create a new compute instance.

    The workflow does several things when installing the instance:

    • Creates and installs a compute instance running Oracle Linux.
    • Creates a VCN with the required subnet and components needed to connect the Oracle Linux instance to the internet.
    • Creates an ssh key pair you use to connect to the instance.

    To get started installing an instance with the Create a VM instance workflow, follow these steps:

    The steps provided are for a Free Tier account. If you are using a paid account, the steps might differ from those shown here.

    • Scroll down to Launch Resources.
    • Select Create a VM instance workflow.

    Enter a value for the name or use the system supplied default. For compartment, select the default root compartment.

    The data might look similar to the following:

    Availability domain

    • Availability domain: AD-1
    • Capacity type: On-demand capacity
    • Fault domain: Let Oracle choose the best fault domain

    For Free Tier, use the Always Free Eligible option for availability domain.

    The data looks similar to the following:

    • Shielded instance: Disabled
    • Confidential computing: Disabled

    The following is sample data for an AMD virtual machine. The actual values might differ.

    For Free Tier, use Always Free Eligible shape options.

    • Click Edit.
    • Primary Network: Select Create new virtual cloud network.
    • New virtual cloud network name: Take the generated VCN name or provide your own name.
    • Create in compartment: .
    • Subnet: Select Create new public subnet.
    • New subnet name: Take the generated subnet name or provide your own name.
    • Create in compartment: .
    • CIDR block: Take the default value (for example, 10.0.0.0/24).
    • Public IPv4 address, take the default value of Assign a public IPv4 address.
    • Continue to the next section.
    • Select the Generate a key pair for me option.
    • Click Save Private Key and Save Public Key to save the private and public SSH keys for this compute instance.

    If you want to use your own SSH keys, select one of the options to provide your public key.

    Put your private and public key files in a safe location. You can’t retrieve keys again after the compute instance has been created.

    3. Enable Internet Access

    The Create a VM Instance wizard automatically creates a VCN for your VM. You add an ingress rule to your subnet to allow internet connections on port 80.

    Follow these steps to select your VCN’s public subnet and add the ingress rule.

    1. Open the navigation menu and click Networking, and then click Virtual Cloud Networks.
    2. Select the VCN you created with your compute instance.
    3. With your new VCN displayed, click subnet link.

    The public subnet information is displayed with the Security Lists at the bottom of the page. A link to the Default Security List for your VCN is displayed.

    • Stateless: Checked
    • Source Type: CIDR
    • Source CIDR: 0.0.0.0/0
    • IP Protocol: TCP
    • Source port range: (leave-blank)
    • Destination Port Range: 80
    • Description: Allow HTTP connections

    4. Install and Configure Apache and PHP

    With your compute instance and VCN setup, install, and configure Apache web server and PHP to run on your Oracle Linux instance.

    With your compute instance and VCN setup, install, and configure Apache web server on your Oracle Linux instance.

    1. Open the navigation menu and click Compute. Under Compute, click Instances.
    2. Click the link to the instance you created in the previous step.

    From the Instance Details page look under the Instance Access section. Write down the Public IP Address the system created for you. You use this IP address to connect to your instance.

    Since you identified your public key when you created the instance, this command logs you into your instance. You can now issue sudo commands to install and start your server.

    sudo systemctl enable httpd
    Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service. 
    sudo systemctl restart httpd
    sudo firewall-cmd --add-service=http --permanent

    If you intend to set up HTTPS later (recommended), also enable HTTPS connections on port 443:

    sudo firewall-cmd --add-service=https --permanent

    Apache Server Test Page

    You can test your server from the command line with curl localhost . Or, you can connect your browser to the public IP address assigned to your instance: http:// .

    Get the IP address from your compute instance details page. From the main menu, select Compute then Instances. Select the compute instance your created. The IP address is listed under the Public IP Address field.

    Install and configure PHP to run on your Oracle Linux instance.

      Configure the Oracle Linux package repos to use PHP 7.

    sudo yum install -y oracle-php-release-el7
    sudo systemctl restart httpd
    PHP 7.4.13 (cli) (built: Nov 25 2020 21:10:33) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies
    sudo vi /var/www/html/info.php

    PHP configuration Page

    The browser produces a listing of PHP configuration on your instance.

    After you are done testing, remove info.php from your system.

    What’s Next

    You have successfully installed and deployed an Apache web server on Oracle Cloud Infrastructure using a Linux instance.

    To explore more information about development with Oracle products:

    Источник

Оцените статью
Adblock
detector