Using nice URLs for APEX

So, I have installed the OS to my server, and subsequently installed the latest Oracle Express Database, and now I can start making applications using Oracle Application Express (APEX).

I can access the APEX login page by typing in the following address:

http://host.domain.com:8080/apex/

Notice the ugly :8080 after the hostname? That is because the APEX installation on Oracle XE defaults to using the Embedded PL/SQL Gateway (EPG) and EPG listens to port 8080 by default.

I want to change the URL to a ‘nicer-looking’ one. One way of doing this is to configure EPG to listen to port 80.  This is especially fine if APEX is the sole purpose of the server. However, since the server will be used for other purposes, this is undesirable because EPG cannot serve as a regular webserver, and therefore cannot replace Apache.

Another way to give APEX a nice URL is to use Apache’s reverse proxy feature.  The users will not directly access APEX via EPG but will connect to Apache, which in turn will connect to APEX.

First, set up the proxy directives in apache conf:

<IfModule mod_proxy.c>
#ProxyRequests should be turned off to disable forward proxy
ProxyRequests Off
<Proxy *>
    Order allow,deny
    Allow from all
</Proxy>
</IfModule>

Then put in the actual proxy configuration for APEX:

NameVirtualHost *:80

<VirtualHost *:80>
    DocumentRoot "/var/www/html"
    ServerName host.domain.com
</VirtualHost>

<VirtualHost *:80>
    DocumentRoot "/var/www/html"
    ServerName apex.domain.com

    Redirect    /       http://apex.domain.com/apex/

    <Location /apex/>
        ProxyPass               http://localhost:8080/apex/
        ProxyPassReverse        http://localhost:8080/apex/
    </Location>

    <Location /i/>
        ProxyPass               http://localhost:8080/i/
        ProxyPassReverse        http://localhost:8080/i/
    </Location>
</VirtualHost>

Now the browser will show the APEX login page when you go to apex.domain.com.

Unable to use WordPress header crop

Tried to add a header image to the blog.  The image upload function worked fine but after the image was uploaded, WordPress asked to crop the image. Clicking on ‘Crop and Publish’ gives the error:

Image could not be processed. Please go back and try again.

Turns out you need an image manipulation tool called ‘gd’ to make WordPress header crop work. It is a module of php. Installation of gd:

# yum install php-gd

Had to restart apache and now header crop works!

Use subdomains with WordPress

My WordPress blog has been successfully installed.

Now, I want to run the blog under a sub-domain i.e. http://blog.domain.com instead of http://host.domain.com/blog.

Let’s see how this can be done.

Initial googling points to apache and mod_rewrite. Let’s read more.

Oops, further googling shows that this can be done without using URL rewrites. Just use the built-in apache virtual hosts feature by adding the following to the config file (/etc/httpd/conf/httpd.conf in CentOS):

NameVirtualHost *:80

<VirtualHost *:80>
    ServerAdmin webmaster@blog.domain.com
    DocumentRoot /path/to/wordpress/directory
    ServerName blog.domain.com
    ErrorLog logs/blog.domain.com-error_log
    CustomLog logs/blog.domain.com-access_log common
</VirtualHost>

And.. voila! Not really. After doing this and restarting the apache service, http://blog.domain.com throws out a 404 error.

It turns out you need to change the WordPress working directory to the new URL via Settings>General before moving the files and implementing the virtual host. After that everything is OK.