All posts by marcelo

Apache2 a2enmod rewrite on Ubuntu 12.04 and .htaccess for WordPress Permalinks

When I was setting WordPress up in order to make this blog work, I was changing the Settings>Permalinks section to make the post url look pretty. So I changed the “Common Settings” to “Day and Name” and saved.

When you do that WordPress writes the .htaccess file on the /var/www directory.

Ok, enough introductory small talk! What happens is that the above feature requires that the mod_rewrite (or simply rewrite) module is installed and enabled. Fortunately, it comes pre-installed on Ubuntu 12.04.1, and you just need to issue the

$ sudo a2enmod rewrite

command and that should work, right?

Well, not really… Even though the issued command creates the symlink for the rewrite.load file at /etc/apache2/mods-enabled, you still have to manually edit your /etc/apache2/sites-enabled/000-default file and change the AllowOverride directive from None to All at the /var/www Directory section.

So the section that looks like:

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None # change this line
    Order allow,deny
    allow from all
</Directory>

Should look like:

<Directory /var/www/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All # now it will read .htaccess
    Order allow,deny
    allow from all
</Directory>

Restart apache and everything should work. By changing the AllowOverride directive to All you’re telling Apache to read and load the configuration found at the .htaccess file on that Directory. If it is set to None, the .htaccess file is ignored.

More info at:

http://httpd.apache.org/docs/2.2/mod/core.html#allowoverride

Share Button

Tomcat 6 on Ubuntu 12.04

Supposing you don’t want to install the Tomcat version that is packaged on Ubuntu (if you need a differente version), this is what you should do:

Download Tomcat here to your home dir.

Add the Tomcat user and group

$ sudo groupadd tomcat
$ sudo useradd -g tomcat -s /usr/sbin/nologin -M tomcat

Go to /usr/local dir and unzip (beware of the file name, you may have downloaded a different/newer version), give appropriate permissions and create a simlink to ‘tomcat’

$ cd /usr/local
$ sudo tar -zxvf ~/apache-tomcat-6.0.36.tar.gz
$ sudo chown -R tomcat. /usr/local/apache-tomcat-6.0.36
$ sudo ln -s apache-tomcat-6.0.36 tomcat

Check if you can start it:

$ sudo /usr/local/tomcat/bin/startup.sh

There should be something like this on the screen:

Using CATALINA_BASE: /usr/local/tomcat
Using CATALINA_HOME: /usr/local/tomcat
Using CATALINA_TMPDIR: /usr/local/tomcat/temp
Using JRE_HOME: /usr
Using CLASSPATH: /usr/local/tomcat/bin/bootstrap.jar

Open the following addres on your web browser: http://localhost:8080 (or replace localhost with your server name/ip address) and verify that Tomcat started properly (a pretty page should be displayed telling you that you’ve installed Tomcat succesfully, or something like that).

Now shut it down:

$ sudo /usr/local/tomcat/bin/shutdown.sh

The same messages that appeared when you started it up should appear again (I know, I know, pretty weird).

Now you can use the following script to start and stop Tomcat. Download it to your home directory and place it at /etc/init.d

$ sudo mv tomcat /etc/init.d

To start/stop as the tomcat user, run the following command (it’s already on the script):

$ sudo su -s /bin/bash tomcat -c /usr/local/tomcat/bin/startup.sh
Share Button