Oracle 11g XE with Apex 5.1 on the AWS EC2

1. Make a SSH connection

2. Go to the /tmp

cd /tmp

3. Download oracle xe

http://www.oracle.com/technetwork/database/database-technologies/express-edition/downloads/index.html

4. Download Apex

http://www.oracle.com/technetwork/developer-tools/apex/downloads/index.html

5. Unpack files

unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
unzip apex_5.1.2_en.zip

6. Oracle XE installation

cd Disk1
sudo rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
sudo /etc/init.d/oracle-xe configure

7. Add an environment to the .bashrc

vim ~/.bashrc

. /u01/app/oracle/product/11.2.0/xe/bin/oracle_env.sh

8. Add user to dba

sudo usermod -a -G dba ec2-user

9. Exit ssh

exit

10. Make a ssh connection

11. Go to the /tmp/apex

cd /tmp/apex

12. Change MEMORY_TARGET

sqlplus /nolog
CONNECT SYS as SYSDBA
ALTER SYSTEM SET MEMORY_TARGET='1G' SCOPE=spfile;
SHUTDOWN
STARTUP

13. Upgrade the apex

@apexins.sql SYSAUX SYSAUX TEMP /i/

14. Configuring the EPG

sqlplus /nolog
CONNECT SYS as SYSDBA
@apex_epg_config.sql /tmp

15. Init an apex admin account

@apxchpwd.sql

16. Drop the old apex scheme

drop user apex_040000 cascade;

17. Create the tmp directory

CREATE DIRECTORY TMP AS '/tmp';

18. Normalize the default group

ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME UNLIMITED;
ALTER PROFILE DEFAULT LIMIT FAILED_LOGIN_ATTEMPTS UNLIMITED;
ALTER PROFILE DEFAULT LIMIT PASSWORD_LOCK_TIME UNLIMITED;
ALTER PROFILE DEFAULT LIMIT PASSWORD_GRACE_TIME UNLIMITED;

19. Normalize ACL http://docs.oracle.com/database/apex-5.1/HTMIG/enabling-network-services-in-Oracle-db11g-or-later.htm#HTMIG29162

DECLARE
  ACL_PATH  VARCHAR2(4000);
BEGIN
  -- Look for the ACL currently assigned to '*' and give APEX_050100
  -- the "connect" privilege if APEX_050100 does not have the privilege yet.
  SELECT ACL INTO ACL_PATH FROM DBA_NETWORK_ACLS
   WHERE HOST = '*' AND LOWER_PORT IS NULL AND UPPER_PORT IS NULL;
  IF DBMS_NETWORK_ACL_ADMIN.CHECK_PRIVILEGE(ACL_PATH, 'APEX_050100',
     'connect') IS NULL THEN
      DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(ACL_PATH,
     'APEX_050100', TRUE, 'connect');
  END IF;
EXCEPTION
  -- When no ACL has been assigned to '*'.
  WHEN NO_DATA_FOUND THEN
  DBMS_NETWORK_ACL_ADMIN.CREATE_ACL('power_users.xml',
    'ACL that lets power users to connect to everywhere',
    'APEX_050100', TRUE, 'connect');
  DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL('power_users.xml','*');
END;
/
COMMIT;

20. Exit from Oracle db

EXIT

21. Clean up the installation files

cd /tmp
rm -rf apex
rm -rf Disk1
rm oracle-xe-11.2.0-1.0.x86_64.rpm.zip
rm apex_5.1.2_en.zip

22. Make the ide.w--w--w.com vhost

sudo vim /etc/httpd/conf.d/vhosts.conf

<VirtualHost *:80>
ServerName ide.w--w--w.com
Redirect permanent / https://ide.w--w--w.com
</VirtualHost>
<VirtualHost *:443>
Redirect permanent / /apex
ServerName ide.w--w--w.com
<IfModule security2_module>
SecRuleEngine Off
</IfModule>
ProxyRequests Off
ProxyPreserveHost On
ProxyPass /apex http://127.0.0.1:8080/apex
ProxyPassReverse /apex http://127.0.0.1:8080/apex
ProxyPass /i http://127.0.0.1:8080/i
ProxyPassReverse /i http://127.0.0.1:8080/i
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
</VirtualHost>

23. Restart httpd

sudo service httpd restart

24. Exit from the ssh

exit

P.S. List of the old apex schemes

select username from dba_users
where regexp_like(username,'(FLOWS|APEX)_\d{6}')
and username <> (select table_owner from all_synonyms
where synonym_name = 'WWV_FLOW'
and owner = 'PUBLIC');

P.P.S. Edit /u01/app/oracle/product/11.2.0/xe/network/admin/listener.ora to change the ip address.