I have dealt with this error quite a few times, but so infrequently that I forget the solution. When upgrading or wiping and reinstalling PostgreSQL via Homebrew, sometimes a few things get dropped by the scripts for some reason.
Situation: Postgres is running, database has been created, I can log in via psql and interact with the database just fine. Even Django, running via the development runserver, can interact with the database fine. However, when you try to test the production server on Apache, you get the dreaded error:
could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
Here is the solution:
Quick check to see if /var/pgsql_socket exists:
ls /var/ # nope, nothing here
So then just make one, per the instructions found here
sudo mkdir /var/pgsql_socket/
ln -s /private/tmp/.s.PGSQL.5432 /var/pgsql_socket/
Reload your apache page and voila, it works.
System config: OSX 10.12.5 (Sierra), httpd24, postgresql@9.5 (9.5.7), django 1.9.2
Showing posts with label MacOS. Show all posts
Showing posts with label MacOS. Show all posts
Thursday, June 15, 2017
Thursday, February 20, 2014
How to Install Shiny Server on OSX
I want to set up the
Instructions for building from source are here. We follow them pretty closely but there are a few gotchas.
The full HowTo is on our GitHub Wiki, here
shiny-server
to run on an iMac at work so that we can run multiple R-apps over the intranet. According to the docs for Shiny server, OSX is not supported yet (version 1.1.0) so we are going to build it from source and hope for the best! Instructions for building from source are here. We follow them pretty closely but there are a few gotchas.
The full HowTo is on our GitHub Wiki, here
Monday, September 16, 2013
Creating a Mountain Lion development environment
So I had to set up a new dev environment at work on Mountain Lion. It uses the following components
- Hombrew
- Python 2.7.5
- Django 1.5.2
- Apache 2.2.25
- Postgres 9.2.4
- R 3.0.1
- Virtualenv
Labels:
Apache,
Django,
Homebrew,
MacOS,
mod_wsgi,
Mountain Lion,
postgres,
python,
R,
RPy2,
Virtualenv
Tuesday, August 20, 2013
How to install mod_wsgi on Mountain Lion
There are apparently changes Apple made in XCode between Lion and Mountain Lion that cause the standard install method to fail. The conventional fix that comes up most often in a Google search at the time of this writing is to create a symlink between the new name of a Toolchain folder and the old name that the installer is supposedly looking for, like this
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain
I did this and tried to make mod_wsgi using Homebrew but it throws a cryptic apxs error. Long story short, I eventually compiled mod_wsgi from source myself, but it continued to through various errors, even though things seemed to be configured properly. I went back to a different Mountain Lion machine I had configured earlier using MacPorts. When I did that machine, I had no problems with mod_wsgi or the need for this toolchain symlink. Examining the Portfile for mod_wsgi gives the key. The missing element is adding the --disable-framework flag to the config file. After that, everything works fine.
This flag should be added to the Homebrew Formula for mod_wsgi. I have never made a Formula before, but maybe one day I will do it. Below is the Gist showing what I did and how it worked.
sudo ln -s /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/ /Applications/Xcode.app/Contents/Developer/Toolchains/OSX10.8.xctoolchain
I did this and tried to make mod_wsgi using Homebrew but it throws a cryptic apxs error. Long story short, I eventually compiled mod_wsgi from source myself, but it continued to through various errors, even though things seemed to be configured properly. I went back to a different Mountain Lion machine I had configured earlier using MacPorts. When I did that machine, I had no problems with mod_wsgi or the need for this toolchain symlink. Examining the Portfile for mod_wsgi gives the key. The missing element is adding the --disable-framework flag to the config file. After that, everything works fine.
This flag should be added to the Homebrew Formula for mod_wsgi. I have never made a Formula before, but maybe one day I will do it. Below is the Gist showing what I did and how it worked.
Monday, August 12, 2013
Fix locate command on Mountain Lion
So apparently upgrading to the Macintosh system Mountain Lion (10.8) breaks the unix "locate" command because it deletes the "nobody" user that was used to own the database.
I found this gist that gives instructions how to get it working again. However, in my case I also had to enable the root user and then log in as root in Terminal and run the command
/usr/libexec/locate.updatedb
as root. Then it finally worked. Sheesh.
Thursday, April 4, 2013
How to remap Home/End key bindings in Mac OSX Mountain Lion
This is taken straight from here. Content is copied in case the link dies. I needed to redo the key bindings for Sublime after I upgraded the OS to 10.8. So here it is:
To get your Home and End keys working properly on Mac OS X (in my case, Mountain Lion, although this should work in prior versions back to at least Tiger), simply open the Terminal and do this:
$ cd ~/Library
$ mkdir KeyBindings
$ cd KeyBindings
$ nano DefaultKeyBinding.dict
Put these lines in that file, including the curly braces:
{
/* Remap Home / End keys to be correct */
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
"^\UF729" = "moveToBeginningOfDocument:"; /* Ctrl + Home */
"^\UF72B" = "moveToEndOfDocument:"; /* Ctrl + End */
"$^\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Ctrl + Home */
"$^\UF72B" = "moveToEndOfDocumentAndModifySelection:"; /* Shift + Ctrl + End */
}
Press Ctrl+O and then Enter to save the file, and Ctrl+X to exit. Restart your computer to have it take full effect.
To get your Home and End keys working properly on Mac OS X (in my case, Mountain Lion, although this should work in prior versions back to at least Tiger), simply open the Terminal and do this:
$ cd ~/Library
$ mkdir KeyBindings
$ cd KeyBindings
$ nano DefaultKeyBinding.dict
Put these lines in that file, including the curly braces:
{
/* Remap Home / End keys to be correct */
"\UF729" = "moveToBeginningOfLine:"; /* Home */
"\UF72B" = "moveToEndOfLine:"; /* End */
"$\UF729" = "moveToBeginningOfLineAndModifySelection:"; /* Shift + Home */
"$\UF72B" = "moveToEndOfLineAndModifySelection:"; /* Shift + End */
"^\UF729" = "moveToBeginningOfDocument:"; /* Ctrl + Home */
"^\UF72B" = "moveToEndOfDocument:"; /* Ctrl + End */
"$^\UF729" = "moveToBeginningOfDocumentAndModifySelection:"; /* Shift + Ctrl + Home */
"$^\UF72B" = "moveToEndOfDocumentAndModifySelection:"; /* Shift + Ctrl + End */
}
Press Ctrl+O and then Enter to save the file, and Ctrl+X to exit. Restart your computer to have it take full effect.
Tuesday, March 29, 2011
Adding PHP module to default OS 10.6.1 PHP stack
The current system is Snow Leopard 10.6.1 and I want to add PostgreSQL support to the default PHP installation. Snow Leopard comes with PHP 5.3.4 already installed in Apple's weird, distributed way. However, the current distro for PHP is 5.3.6 at the time of this writing, so what to do? I found the solution scattered across many different blogs, so I am synthesizing it here. None of this was my own creation.
First, grab a copy of the source code that matches what is already installed. Probably won't find it on PHP.net, so try this link: php-5.3.4
I created a /src directory to store source code in. Copy the tar file into here or a similar directory and unpack it.
Change to that directory:
First, grab a copy of the source code that matches what is already installed. Probably won't find it on PHP.net, so try this link: php-5.3.4
I created a /src directory to store source code in. Copy the tar file into here or a similar directory and unpack it.
Change to that directory:
>cd /src/php-5.3.4
Set some environment variables before doing the configuration
>export MACOSX_DEPLOYMENT_TARGET=10.6.7
>export CFLAGS="-arch x86_64"
>export CXXFLAGS="-arch x86_64"
>export LDFLAGS="-arch x86_64"
Go to the pgsql source directory in php ext folder
>cd ext/pgsql
Compile the extension module
>phpize
>./configure
>make
The extension will be found here
>cd /src/php-5.3.4/ext/pgsql/.libs/
>ls
-rwxr-xr-x 1 Bali admin 154K Mar 29 12:41 pgsql.so
Copy the extension to the extensions library and make sure it is executable
>sudo cp pgsql.so
/usr/lib/php/extensions/no-debug-non-zts-20090626/
>cd
/usr/lib/php/extensions/no-debug-non-zts-20090626/
>sudo chmod +x pgsql.so
Create a copy of the php.ini file if one does not already exist
>sudo cp /etc/php.ini.default /etc/php.ini
Edit the php.ini file and add the following two lines:
extension_dir="/usr/lib/php/extensions/no-debug-non-zts-20090626/"
extension=pgsql.so
Save and then test that the extension is loaded properly by running the following at the command line:
>php -m
You should see a list of installed modules, including pgsql. Then go back and restart Apache
>/usr/sbin/apachectl graceful
Run phpinfo to verify the module has been loaded. You may have to scroll down to see it.
That is it.
Thursday, January 13, 2011
Update the locate database on the Mac
This is the command for updating the locate database on the OSX system.
sudo /usr/libexec/locate.updatedb
I should figure out how to make this run everyday.
sudo /usr/libexec/locate.updatedb
I should figure out how to make this run everyday.
Subscribe to:
Posts (Atom)