Zum Hauptinhalt springen

Du bist hier
< Zurück

URL Adresse: https://books.clusterapps.com/books/deployments/page/oracle-xe-and-apex-on-centos-7

Oracle XE and APEX on CentOS 7

Downloading the software

The first thing to do is download the software from Oracle Technology Network:

After the files have been downloaded, transfer them to the server.

Installation of RDBMS

After you checked them, to install the RDBMS, you need to install the preinstall RPM package first and then install the database software as following: 1

wget https://yum.oracle.com/repo/OracleLinux/OL7/latest/x86_64/getPackage/oracle-database-preinstall-18c-1.0-1.el7.x86_64.rpm

2

yum install oracle-database-preinstall-18c* -y

3

yum install oracle-database-xe-18c* -y

4

yum install httpd tomcat  -y

The user oracle and the group oinstallare created during the package installation. A default user environment is created during the set up process. You can set a password for this user by invoking passwd oracle command. This user is the owner of the /opt/oracle directory where the Oracle Database is located and this must stay unchanged. 1

 chown oracle:oinstall /opt/oracle

When the packages are installed and the user is set up, you need to run the initial database configuration script and answer all of the questions. 1

/etc/init.d/oracle-xe-18c configure

After answering the questions it is going to take several minutes to initialize the database.

Setting up environment

Set up Oracle Database environment variables . 1

echo 'ORACLE_SID=XE' >> /etc/profile.d/oraenv.sh

2

echo 'ORAENV_ASK=NO' >> /etc/profile.d/oraenv.sh

3

echo '. /opt/oracle/product/18c/dbhomeXE/bin/oraenv -s' >> /etc/profile.d/oraenv.sh

4

. /etc/profile.d/oraenv.sh

Enable Oracle Database XE service for automatic startup: 1

systemctl enable oracle-xe-18c

Connecting to database

And we are ready to log into the database. 1

sqlplus /nolog

Check if everything is good. 1

-- connect to the database

2

sqlplus /nolog

3

4

-- change role

5

CONNECT SYS as SYSDBA

6

7

-- basic query to check everything came up right

8

select * from dual;

9

10

-- exit the database

11

exit

To make it easier to connect to the pluggable database, edit thetnsnames.ora file and add there a new connection descriptor 1

vim /opt/oracle/product/18c/dbhomeXE/network/admin/tnsnames.ora

Add the following after the standard XE record: 1

PDB1 =

  (DESCRIPTION =

    (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))

    (CONNECT_DATA =

      (SERVER = DEDICATED)

      (SERVICE_NAME = XEPDB1)

    )

  )

Installation of APEX

Change your directory back to /root, unzip the APEX archive and make the user oracle the owner of the directory. Considering we are installing the 19.2 version of APEX, it would look like this. 1

cd /root

2

mkdir -p /opt/oracle/apex

3

unzip apex_19.*.zip -d /opt/oracle

4

chown -R oracle:oinstall /opt/oracle/apex

Create an allow all ACL for APEX sql file in the APEX directory. This one is called apex_acl.sql. 1

BEGIN

2

  BEGIN

3

    dbms_network_acl_admin.drop_acl(acl => 'all-network-PUBLIC.xml');

4

  EXCEPTION

5

    WHEN OTHERS THEN

6

      NULL;

7

  END;

8

  dbms_network_acl_admin.create_acl(acl         => 'all-network-PUBLIC.xml',

9

                                    description => 'Allow all network traffic',

10

                                    principal   => 'PUBLIC',

11

                                    is_grant    => TRUE,

12

                                    privilege   => 'connect');

13

  dbms_network_acl_admin.add_privilege(acl       => 'all-network-PUBLIC.xml',

14

                                       principal => 'PUBLIC',

15

                                       is_grant  => TRUE,

16

                                       privilege => 'resolve');

17

  dbms_network_acl_admin.assign_acl(acl  => 'all-network-PUBLIC.xml',

18

                                    host => '*');

19

END;

20

/

21

sho err

22

COMMIT;

23

/

From the APEX directory connect to the pluggable database as sysdba and run the installation scripts. 1

cd /opt/oracle/apex

2

-- connect to the database

3

sqlplus /nolog

4

5

-- change role

6

CONN sys@pdb1 AS SYSDBA

1

-- run the script to install a full development environment

2

@apexins.sql SYSAUX SYSAUX TEMP /i/

3

   

4

 -- create an instance administrator user and set their password

5

@apxchpwd.sql

6

7

-- unlock APEX public user

8

ALTER USER APEX_PUBLIC_USER ACCOUNT UNLOCK;

9

ALTER USER APEX_PUBLIC_USER IDENTIFIED BY "S0m3aw3s0m3Pw!";

10

11

-- configure REST Data Services 

12

@apex_rest_config.sql

13

14

-- run the ACL setup

15

@apex_acl.sql

16

17

-- disconnect from the database

18

exit

Copy APEX static files to the web server directory. They will be used to serve static images from the proxy. 1

mkdir -p /var/www/apex/images

2

cp -a /opt/oracle/apex/images/. /var/www/apex/images

The Application Express installation is complete.

Installation of ORDS

The Oracle Rest Data Services (ORDS) installation consists of unzipping the downloaded archive, running the configuration command, and then deploying the ords.war file into the Tomcat webapps folder. 1

cd /root

2

mkdir -p /opt/oracle/ords

3

unzip ords-19.*.zip -d /opt/oracle/ords

Run the ORDS configuration command with the advanced mode to run the interactive installation process. 1

cd /opt/oracle/ords

2

java -jar ords.war install advanced

When prompted for ORDS configuration directory, enter config.
Then provide the connection info to your pluggable database  XEPDB1

Follow the on screen instructions.

After the configuration is completed, the values are saved in opt/oracle/ords/config/ords/defaults.xml file. It can be modified there. See more at Oracle Docs.

The tomcat user (created as part of Tomcat install) must have read-write access to the ORDS configuration folder: 1

chown -R tomcat:tomcat /opt/oracle/ords/config

Deploy ORDS to Tomcat application server. Copy the ords.war into the Tomcat webapps directory for this 1

cp -a /opt/oracle/ords/ords.war /usr/share/tomcat/webapps/

Done with ORDS and Tomcat, on to Apache.

Configuration of Apache httpd to map ORDS

The last step is to configure Apache to map HTTP-requests to ORDS and therefore APEX engine.

For this, add a custom httpd configuration file. By default, every .conf file placed in the etc/httpd/conf.d/ directory is read by httpd as an additional configuration file to the main /etc/httpd/conf/httpd.conf config file.

Create the apex.conf file in the etc/httpd/conf.d/ directory with the contents as below: 1

# forward ORDS tomcat

2

<VirtualHost *:80>

3

    # uncomment the lines below if you plan to serve different domains 

4

    # on this web server, don't forget to change the domain name

5

    # ServerName yourdomain.tld

6

    # ServerAlias www.yourdomain.tld

7

    

8

    # alias for APEX static files

9

    Alias "/i" "/var/www/apex/images/"

10

11

    # uncomment the line below if you want 

12

    # to redirect traffic to ORDS from root path

13

    # RedirectMatch permanent "^/$" "/ords"

14

15

    # proxy ORDS requests to tomcat

16

    ProxyRequests off

17

    <Location "/ords">

18

        ProxyPass "ajp://localhost:8009/ords"

19

        ProxyPassReverse "ajp://localhost:8009/ords"

20

    </Location>

21

</VirtualHost>

Tell SELinux (Yes, that should be running) to allow Apache to communicate to tomcat. 1

setsebool httpd_can_network_connect on

Now you are ready to save the configuration file and restart the services. 1

systemctl restart httpd

2

systemctl restart tomcat

Open a few firewall ports. Yes, the the firewall should also be on. 1

firewall-cmd --permanent --add-service={http,https}

2

firewall-cmd --reload

And finally, access APEX from your web browser using a link like http://yourdomain.tld/ords (or http://yourdomain.tld in case you switched on force redirection), where yourdomain.tld is the domain name or the IP-address of your server.