Установка apache oracle linux

2 Getting Started

This chapter explains how to install and test Oracle Database and PHP environment. It has the following topics:

What You Need

To install your Oracle Database and PHP environment, you need:

  • Oracle Database Server which includes the sample data for this tutorial
  • Oracle Database Client libraries are included with the Oracle Database software or can be installed using Oracle Instant Client
  • Apache HTTP Server which is typically already installed on Linux computers
  • PHP — PHP Hypertext Preprocessor
  • A text editor for editing PHP code. A code editor such as Oracle JDeveloper with the optional PHP Extension can also be used.

Installing Oracle Database

You should install Oracle Database Server on your computer. The sample data used in this tutorial is installed by default. It is the HR component of the Sample Schemas.

Throughout this tutorial Oracle SQL Developer is the graphical user interface used to perform Database tasks. Oracle SQL Developer is a free graphical tool for database development.

Unlocking the HR User

The PHP application connects to the database as the HR user. You may need to unlock the HR account as a user with DBA privileges. To unlock the HR user:

  1. Open SQL Developer and open a connection to your Oracle database.
  2. Login to your Oracle database as system .
  3. Open SQL Worksheet or SQL*Plus and run the following SQL statement:
alter user hr account unlock;

For further information about unlocking an Oracle Database account, see Chapter 6, «Managing Users and Security,» in the Oracle Database 2 Day DBA guide.

Installing Apache HTTP Server

You should install Apache before you install PHP. Apache is typically installed by default on Linux computers. See Testing the Apache Installation on Linux before downloading the Apache software.

Perform the following steps to obtain Apache HTTP Server for Windows or Linux:

    Enter the following URL in your Web browser:

Installing Apache on Windows

This section describes how to install Apache HTTP Server on Windows.

The file name and extraction directory are based on the current version. Throughout this procedure, ensure you use the directory name for the version you are installing.

You must be the administrator user to install Apache.

To install Apache, double-click the file and follow the wizards.

The default installation directory is likely to be C:\Program Files\Apache Group . This is the directory that is assumed for the tutorial exercises. If you install to a different directory, you need to note the directory so you can change the path used in the tutorials.

Starting and Stopping Apache on Windows

You can use the Start menu option to start Apache. This opens a console window showing any error messages. Error messages may also be written to C:\Program Files\Apache Group\Apache2\logs\error.log .

You can also use the ApacheMonitor utility to start Apache. It will appear as an icon in your System Tray, or navigate to the Apache bin directory and double click ApacheMonitor.exe . In a default installation, Apache bin is located at c:\Program Files\Apache Group\Apache2\bin .

You can also use the Windows Services to start Apache. You access Windows Services from the Windows Start menu at Start > Control Panel > Administrative Tools > Services. Select the Standard tab. Right click the Apache2 HTTP Server and then select Restart

If you have errors, double check your httpd.conf and php.ini files.

Testing the Apache Installation on Windows

To test the Apache HTTP Server installation:

  1. Start your Web browser on the computer on which you installed Apache.
  2. Enter the following URL:

Your Web browser will display a page similar to the following:
Description of the illustration chap2_test_install_013.gif

Installing Apache on Linux

This section describes how to install Apache HTTP Server on Linux.

The file name and extraction directory are based on the current version. Throughout this procedure, ensure you use the directory name for the version you are installing.

Apache is typically already installed on Linux. If you find it is not installed after Testing the Apache Installation on Linux, perform the following steps to install the Apache HTTP Server:

  1. Go to the directory where you downloaded the httpd-2.2.12.tar.bz2 file.
  2. Log in as the root user and execute these commands:
# tar -jxvf httpd-2.2.12.tar.bz2 # cd httpd-2.2.12 # export ORACLE_HOME=/usr/lib/oracle/app/oracle/product/10.2.0/server # ./configure \ --prefix=/usr/local/apache \ --enable-module=so \ # make # make install

Starting and Stopping Apache on Linux

You use the apachectl script to start and stop Apache.

Start Apache with the apachectl script:

# /usr/local/apache/bin/apachectl start

Stop Apache with the apachectl script:

# /usr/local/apache/bin/apachectl stop

When you start Apache, you must have ORACLE_HOME defined. Any other required Oracle environment variables must be set before Apache starts too. These are the same variables set by the $ORACLE_HOME/bin/oracle_env.sh or the /usr/local/bin/oraenv scripts.

For convenience, you could create a script to start Apache as follows:

#!/bin/sh ORACLE_HOME=/usr/lib/oracle/app/oracle/product/10.2.0/server export ORACLE_HOME echo "Oracle Home: $ORACLE_HOME" echo Starting Apache /usr/local/apache/bin/apachectl start

Testing the Apache Installation on Linux

To test the Apache HTTP Server installation:

    Start your Web browser on the host on which you installed Apache, and enter the following URL:

Your Web browser will display a page similar to the following:
Description of the illustration chap2_install_001.gif

 # # UserDir is disabled by default since it can confirm the presence # of a username on the system (depending on home directory # permissions). # #UserDir disable # # To enable requests to /~user/ to serve the user's public_html # directory, remove the "UserDir disable" line above, and uncomment # the following line instead: # UserDir public_html 

This enables the Web browser to make an HTTP request using a registered user on the system and to serve files from the $HOME/public_html directory of the user. For example:

su - Password: apachectl restart

Installing PHP

Perform the following steps to obtain PHP for Windows or Linux:

    Enter the following URL in your Web browser:

Installing PHP on Windows

This section describes how to install PHP on Windows.

The file name and extraction directory are based on the current version. Throughout this procedure, ensure you use the directory name for the version you are installing.

You must be the administrator user to install PHP. To install PHP, perform the following steps:

  1. In Windows Explorer, go to the directory where you downloaded the PHP 5.2.10 zip file.
  2. Unzip the PHP package to a directory called C:\php-5.2.10
  3. Copy php.ini-recommended to C:\Program Files\Apache Group\Apache2\conf\php.ini
  4. Edit php.ini to make the following changes:
    • Change extension_dir to C:\php-5.2.10\ext , which is the directory containing php_oci8.dll and the other PHP extensions.
    • Remove the semicolon from the beginning of the line extension=php oci8.dll
    • Set the PHP directive, display_errors , to On . For testing it is helpful to see any problems in your code.
  5. Edit the file httpd.conf and add the following lines. Make sure you use forward slashes ‘/’ and not back slashes ‘\’:
# # This will load the PHP module into Apache # LoadModule php5_module c:/php-5.2.10/php5apache2.dll # # This next section will call PHP for .php, .phtml, and .phps files # AddType application/x-httpd-php .php AddType application/x-httpd-php .phtml AddType application/x-httpd-php-source .phps # # This is the directory containing php.ini # PHPIniDir "C:/Program Files/Apache Group/Apache2/conf"

Installing PHP on Linux

This section describes how to install PHP on Linux.

The file name and extraction directory are based on the current version. Throughout this procedure, ensure you use the directory name for the version you are installing.

Perform the following steps to install PHP:

  1. Go to the directory where you downloaded the php-5.2.10.tar.bz2 file.
  2. Log in as the root user and execute these commands:
# tar -jxvf php-5.2.10.tar.bz2 # cd php-5.2.10 # export ORACLE_HOME=/usr/lib/oracle/app/oracle/product/10.2.0/server # ./configure \ --with-oci8=$ORACLE_HOME \ --with-apxs2=/usr/local/apache/bin/apxs \ --with-config-file-path=/usr/local/apache/conf \ --enable-sigchild # make # make install
# cp php.ini-recommended /usr/local/apache/conf/php.ini
# # This next section will call PHP for .php, .phtml, and .phps files # AddType application/x-httpd-php .php AddType application/x-httpd-php .phtml AddType application/x-httpd-php-source .phps # # This is the directory containing php.ini # PHPIniDir "/usr/local/apache/conf"
LoadModule php5_module modules/libphp5.so
# /usr/local/apache/bin/apachectl start

Testing the PHP Installation

To test the PHP installation:

    Create a subdirectory called chap2 . To create a directory for your application files, and to change to the newly created directory, enter the following commands in a command window: On Windows:

mkdir "c:\program files\Apache Group\Apache2\htdocs\chap2" cd c:\program files\Apache Group\Apache2\htdocs\chap2
mkdir $HOME/public_html/chap2 cd $HOME/public_html/chap2
http://localhost/chap2/hello.php
http://localhost/~/chap2/hello.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.

For product documentation, visit Oracle Help Center.

Install the Apache Web Server

Copyright © 2020, Oracle and/or its affiliates.

Источник

Читайте также:  Linux info about package
Оцените статью
Adblock
detector