mod_rewrite, path setup through conf-enabled, .htaccess, alias, and wordpress

In other words, I’ve seriously overcomplicated this setup but after about a half-day of hammering away at it it seems it can be done after all, and my faults were minor.
Important takeaways…

I have a standard apache server setup that serves files from /var/www/html. This is simply defined in my /etc/apache2/sites-enabled directory as a virtual host, like this:

<VirtualHost *:80>
DocumentRoot /var/www/html ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined

I have a fully isolated wordpress environment someplace else on my filesystem that I use an alias to patch into the web server with it’s own configuration file. WordPress will write it’s own .htaccess file for you in it’s root, so remove one if you’ve made it, or rename it so you don’t get in the way! It should look something like this:
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /alias
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . alias/index.php [L]
# END WordPress

Most apache installs don’t have mod-rewrite enabled by default, so you ought to take care of that early on. Make sure you’ve got a link in your mods-enabled directory that looks something like this:
lrwxrwxrwx 1 root root 30 Aug 6 14:02 rewrite.load -> ../mods-available/rewrite.load

My over-engineering is the fact that I’ve got it now linked into my apache conf-enabled directory, with a conf file that looks like this:

# this should set up my dev box

Alias /solovic/actual/path/to/my/aliased/

<Directory "/actual/path/to/my/aliased/">
AllowOverride All
RewriteEngine On
RewriteBase "/actual/path/to/my/aliased/"
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ./alias/index.php [L]
#DirectoryIndex index.php
<IfModule mod_php.c>
<IfModule mod_mime.c>
AddType application/x-httpd-php .php
<FilesMatch ".+\.php$">
SetHandler application/x-httpd-php

php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_admin_flag allow_url_fopen On
php_value include_path .
Require all granted

My major fuckup, and what wasted most of my day in this case, was the RewriteRule above in my directory path. I left out that alias bit and so, apache, very confused at why I would want to send everything back to /var/www/html/index.php, kept spitting me 404s. So, if you’ve got a setup like mine and are pulling out your hair, it’s probably related to mod_rewrite, so check your apache error logs. You may come across something like this:

script '/var/www/html/index.php' not found or unable to stat, referer: http://host/aliasdir/wp-admin/post.php?post=10575&action=edit

And that, as they say, is that.

installing gems per-user for use with PhpStorm, no sudo required

Stumbled across this “gem” of an article (no pun intended) today while I was trying to sort out a fresh install of my dev environment. As much as I might bitch and complain about the various JetBrains IDEs, they are a pretty powerful set of cross-platform tools that I use in the absence of a suitable Visual Studio replacement in Linux. I use sass in most all of my projects, which luckily, integratese pretty straightforward with PhpStorm, my IDE of choice for wordpress development.

I’m wary of installing most ruby gems system-wide with sudo though, because mainly it just feels gross but I’m also concerned I’ll run into collisions if I need to use different versions of Ruby at different times for, ya know, stuff. Anyway, as it turns out, gem offers an elegant way of handling this on the command line:
gem install --user sass

Granted I still needed to config PhpStorm proper to find and use sass with my code, which is about as simple as:

Finding the right setting in the PhpStorm setting UI:

Creating a file-watcher for your scss:

As an aside, if you’re a student and can prove it with any @edu domain, you can get a full year’s license to try ALL of jetbrains products. That is:

Jetbrains Student License

IntelliJ IDEA Ultimate
ReSharper C++




Just a heads up. Pretty useful set of tools.