inicio mail me! sindicaci;ón

Archive for MacOSX

Zero-config Rails und PHP mit puma-dev

Mit puma-dev lassen sich beliebig viele Rack/Rails-Anwendungen durch Erstellen von Symlinks verfügbar machen.
Allerdings ist damit Port 80 blockiert und steht nicht mehr für Apache zur Verfügung.

Zum Glück erlaubt puma-dev nicht nur das Erstellen von Symlinks auf Rack-Apps sondern auch das Erstellen von Files innerhalb von ~/.puma-dev/, die als Inhalt einen alternativen Port enthalten.
Damit kann man alle Applikationen, die statt von puma-dev von Apache behandelt werden sollen, z.B. PHP-Apps und statische Seiten, als Files anlegen, die nur 81 enthalten.
Außerdem muss man Apache auf Port 81 lauschen lassen.

Die erforderlichen Schritte sind:

Apache-Konfiguration /etc/apache2/httpd.conf

Apache soll zukünftig auf Port 80 lauschen:

Listen 81

Die Module für virtuelle Hosts, Rewrite und PHP sollen verwendet werden:

LoadModule vhost_alias_module libexec/apache2/mod_vhost_alias.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php7_module libexec/apache2/libphp7.so
Include /private/etc/apache2/extra/httpd-vhosts.conf

Virtual Hosts Konfiguration /etc/apache2/extra/httpd-vhosts.conf

<VirtualHost 127.0.0.1:81>
  ServerName any.dev
  ServerAlias *.dev
  UseCanonicalName Off
  VirtualDocumentRoot "/Users/{username}/Sites/%1"
  <Directory "/Users/{username}/Sites/*">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
    Require all granted
  </Directory>
</VirtualHost>

Angenommen die gewünschte PHP-Applikation liegt im Verzeichnis /Users/{username}/Sites/meine-app/.
Erstellt man eine Datei ~/.puma-dev/meine-app mit dem Inhalt 81, dann wird diese unter http://meine-app.test durch Apache verfügbar gemacht.

Happy hacking!

Updating postgres from 9.3 to 9.4 on MacOSX

Working with Heroku I recently wanted to pull the Heroku production DB to my local DB. Using pg:pull I got the following error message:
pg_dump: aborting because of server version mismatch
because Heroku uses PostgreSQL 9.4 and my local version was 9.3.
So I had to update my local DB; this is what I did:

1) shut down db and remove launch agent plists:
launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
rm ~/Library/LaunchAgents/homebrew.mxcl.postgresql*

2) remove links to old binaries, install new version (links automatically):
brew unlink postgresql93
brew install postgres

Note that I do not yet uninstall the old binaries, we need them to run pg_update later!

3) Link the new launch agent plist
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents

4) create a new empty cluster with the same locale as the old one:
initdb /usr/local/var/postgres9.4 --locale=en_US.UTF-8

5) run the upgrade script (using the binary of the new version)
pg_upgrade -v \
-d /usr/local/var/postgres \
-D /usr/local/var/postgres9.4 \
-b /usr/local/Cellar/postgresql93/9.3.5/bin \
-B /usr/local/Cellar/postgresql/9.4.5_2/bin

6) start new server and uninstall the old version:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
brew uninstall postgresql93

7) optional: re-install the pg rem for my ruby app
gem uninstall pg
bundle

Hope this helps somebody!

Vor kurzem dazugelernt:

Suche nach Wort unter dem Cursor in vim: #.

jssh ist eine JavaScript Shell, die den Firefox per Port 9997 fernsteuerbar macht.
Download z.B. hier.

y erzeugt einen YAML dump auf der Rails console, mehr dazu hier.

=3D ist ein escaptes “=” in quoted_printable.

sudo /usr/libexec/locate.updatedb aktualisiert unter MacOSX sofort die locate Datenbank.

rake db:migrate:redo führt unter rails die letzte Migration rückwärts und sofort wieder vorwärts aus, so dass sich die Vorwärts-Action korrigieren läßt

ack -Q bringt ack dazu, literal, also ohne RegExp zu suchen.

MacOSX Boot-Tastenkombinationen: single user, verbose, safe

In den single user mode (root shell) starten, beim Neustart:
[CMS] s

In den verbose mode (boot log) starten:
[CMD] v

In den safe mode (nur core kexts) starten:
[SHIFT]

PHP and MySQL on MacOSX 10.5. Leopard

After installing Leopard, the previous Apache configuration file in /etc/httpd/httpd.conf is no longer used. The Apache configuration sits in /etc/apache2/httpd.conf now.
In order to enable PHP again, I uncommented the following line first:
LoadModule php5_module libexec/apache2/libphp5.so
Second, to get my virtual hosts running again, I used the adapted Leopard version of Patrick Gibsons excellent utility
virtualhost.sh which even automatically moves all prior (Tiger) virtual hosts.
Finally to get rid of the error
Can't connect to local MySQL server through socket '/var/mysql/'
I successfully followed the steps found here:
sudo mkdir /var/mysql/
sudo ln -s /tmp/mysql.sock /var/mysql/mysql.sock

Everything is up and running fine now.

Using Finks svk on MacOSX with zsh

Some days ago I tried installing svk on MacOSX using fink.
Everything worked fine except when I finally tried to use it:

aljoscha% svk
Can't locate Class/Autouse.pm in @INC 
(@INC contains: /System/Library/Perl/5... [snip] ...5.8.1 .) at /Library/Perl/5.8.6/SVK.pm line 6.
BEGIN failed--compilation aborted at /Library/Perl/5.8.6/SVK.pm line 6.
Compilation failed in require at /usr/bin/svk line 6.
BEGIN failed--compilation aborted at /usr/bin/svk line 6.

The solution was not so obvious to me: Fink sets its paths in
/sw/bin/init.sh (/sw/bin/init.csh for csh users respectively)

Putting a

source /sw/bin/init.sh

into your ~/.zshrc makes svk happy.