Redis can't start due to tcp-backlog - macos

I am using the osx and trying to install redis through brew
brew install redis
==> Downloading http://download.redis.io/releases/redis-2.8.17.tar.gz
Already downloaded: /Library/Caches/Homebrew/redis-2.8.17.tar.gz
==> make -C /private/tmp/redis-WEL8AT/redis-2.8.17/src CC=clang
==> Caveats
To have launchd start redis at login:
ln -sfv /usr/local/opt/redis/*.plist ~/Library/LaunchAgents
Then to load redis now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.redis.plist
Or, if you don't want/need launchctl, you can just run:
redis-server /usr/local/etc/redis.conf
==> Summary
At last I have installed redis, but when I run it in the way of
redis-server /usr/local/etc/redis.conf
there is error message,
*** FATAL CONFIG FILE ERROR ***
Reading the configuration file, at line 54
>>> 'tcp-backlog 511'
Bad directive or wrong number of arguments
I learned from Redis tcp-backlog to uncomment the redis.conf in that line.
but still more errors on other lines come again.
How do I solve it ?

Check if you have installed redis twice. I my case I had another redis installation from anaconda with version 2.6.9:
$ which redis-server
/Users/<username>/anaconda/bin/redis-server
$ redis-server -v
Redis server v=2.6.9 sha=00000000:0 malloc=libc bits=64
Homebrew instead will install the redis-server to a different place:
$ /usr/local/bin/redis-server -v
Redis server v=3.0.1 sha=00000000:0 malloc=libc bits=64 build=bf58331b4c8133f5
So to start the homebrew version with the homebrew config file do
$ /usr/local/bin/redis-server /usr/local/etc/redis.conf

I had similar problem due to a config file left over from previous redis versions. Uninstalling all redis versions and reinstalling the latest worked (also, don't forget to update brew before installing redis):
brew uninstall redis --force
brew update
brew install redis
You should now be able to start it.

Related

How can I install brew httpd on MacOS 11 Big Sur?

I've upgraded macOS version to 11 Big Sur and unable to use brew's apache instead of build in version.
What I did:
sudo apachectl stop
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null
brew intall httpd
When I'm trying to start the installed httpd it says that apache is started
==> Successfully started httpd (label: homebrew.mxcl.httpd)
but when I run brew services command I see that httpd is not started (and http://localhost:8080 is not working).
sergeylyskov#MacBook-Pro-Sergey ~ % brew services
Name Status User Plist
httpd error sergeylyskov /Users/sergeylyskov/Library/LaunchAgents/homebrew.mxcl.httpd.plist
php#7.3 stopped
php#7.4 stopped
postgresql#12 stopped
P.S. I want to use brew's version because seems like build in apache is not properly work with php modules (it don't show xdebug and imagick extensions in phpinfo())
Any advice?
I tried uninstalling and then reinstalling httpd, but that didn't work initially. When you uninstall, brew does NOT remove the /usr/local/etc/httpd config directory (which is sensible because you might have a lot of things configured in there and not backed up). However, these configuration files might well be outdated (or customized) in a way that makes them incompatible with the latest version of httpd, causing it to fail. So I did the following:
brew services stop httpd
brew uninstall httpd
mv /usr/local/etc/httpd /usr/local/etc/httpd-old
brew install httpd
brew services start httpd
This got it running again with fresh config files; I can now copy over any specific configuration details from httpd-old into the new httpd dir.
Also note: by default, httpd serves from /usr/local/var/www. This dir is not affected by the uninstall-reinstall process, so only your config files need re-doing.

MacOS cannot run nginx

When I run nginx on my MacOS.
➜ nginx nginx
dyld: Library not loaded: /usr/local/opt/openssl#1.1/lib/libssl.1.1.dylib
Referenced from: /usr/local/bin/nginx
Reason: image not found
[1] 10170 abort nginx
Please start by installing HomeBrew http://brew.sh/. It is a package manager for MacOS that allows to easily install various Unix applications.
MacOS will prompt you to first install Xcode Command Line Tools (unless you have them already).
After installation, the following command, if necessary, will tell you how to complete the installation:
brew doctor
//Then updates all packages with:
brew update
brew upgrade
//Then Install Nginx
brew install nginx
// Then automatically launch Nginx at startup with:
sudo cp /usr/local/opt/nginx/*.plist /Library/LaunchDaemons
sudo launchctl load -w /Library/LaunchDaemons/homebrew.mxcl.nginx.plist
Good luck!
I had that problem for a bit, but when I ran
brew uninstall nginx
and then
brew install nginx
It reinstalled properly and I was able to run it without getting that error.

Correct way to install psql without full Postgres on macOS?

Official page do not mention such case. But many users need only psql without a local database (I have it on AWS). Brew do not have psql.
You could also use homebrew to install libpq.
brew install libpq
This would give you psql, pg_dump and a whole bunch of other client utilities without installing Postgres.
Unfortunately since it provides some of the same utilities as are included in the full postgresql package, brew installs it "keg-only" which means it isn't in the PATH by default. Homebrew will spit out some information on how to add it to your PATH after installation. In my case it was this:
echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.zshrc
Alternatively, you can create symlinks for the utilities you need. E.g.:
ln -s /usr/local/Cellar/libpq/10.3/bin/psql /usr/local/bin/psql
Note: used installed version instead of 10.3.
Alternatively, you could instruct homebrew to "link all of its binaries to the PATH anyway"
brew link --force libpq
but then you'd be unable to install the postgresql package later.
libpq 11.2
MacOS & zsh or bash
below works
install libpq
brew install libpq
update PATH
if use zsh:
echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
if use bash:
echo 'export PATH="/usr/local/opt/libpq/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
Homebrew only really has the postgres formula, and doesn't have any specific formula that only installs the psql tool.
So the "correct way" to get the psql application is indeed to install the postgres formula, and you'll see toward the bottom of the "caveats" section that it doesn't actually run the database, it just puts the files on your system:
$ brew install postgres
==> Downloading https://homebrew.bintray.com/bottles/postgresql-9.6.5.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring postgresql-9.6.5.sierra.bottle.tar.gz
==> /usr/local/Cellar/postgresql/9.6.5/bin/initdb /usr/local/var/postgres
==> Caveats
<snip>
To have launchd start postgresql now and restart at login:
brew services start postgresql
Or, if you don't want/need a background service you can just run:
pg_ctl -D /usr/local/var/postgres start
==> Summary
🍺 /usr/local/Cellar/postgresql/9.6.5: 3,269 files, 36.7MB
Now you can use psql to connect to remote Postgres servers, and won't be running a local one, although you could if you really wanted to.
To verify that the local postgres daemon isn't running, check your installed homebrew services:
$ brew services list
Name Status User Plist
mysql stopped
postgresql stopped
If you don't have Homebrew Services installed, just
$ brew tap homebrew/services
...and you'll get this functionality. For more information on Homebrew Services, read this excellent blog post that explains how it works.
If you truly don't need postgresql then you don't even have to alter your path to use libra, just link libpq. The docs say the only reason it isn't is to avoid conflicts with the PostgreSQL package.
brew uninstall postgresql
brew install libpq
brew link --force libpq
Install libpq:
brew install libpq
Then, create a symlink:
sudo ln -s $(brew --prefix)/opt/libpq/bin/psql /usr/local/bin/psql
Hope it helps.
I found all of these really unsatisfying, especially if you have to support multiple versions of postgres. A MUCH easier solution is to download the binaries here:
https://www.enterprisedb.com/download-postgresql-binaries
And simply run the executable version of psql that matches the database you're working against without any extra steps.
example:
./path/to/specific/version/bin/psql -c '\x' -c 'SELECT * FROM foo;'
Found so many useful answers here, but a bit outdated since homebrew moved the installation files to /opt/homebrew/Cellar/libpq/15.1. After libpq is installed with brew install libpq you can run below command to see new location
brew link --force libpq
Then you can add it to your zshrc with
echo 'export PATH="/opt/homebrew/Cellar/libpq/15.1/bin:$PATH"' >> ~/.zshrc
You could try brew install postgresql
But this provides a nice GUI to manage your databases https://postgresapp.com

Erros in installing PostgreSQL using homebrew

I'm using Mac OS X 10.8.5 and trying to install postgreSQL using homebrew. I've fixed several errors and warnings which have occurred when I ran brew info postgresql. However, I don't know how to fix the rest of the problems.
$brew info postgresql
postgresql: stable 9.3.2 (bottled)
http://www.postgresql.org/
Conflicts with: postgres-xc
/usr/local/Cellar/postgresql/9.3.2 (2924 files, 40M) *
Poured from bottle
From: https://github.com/Homebrew/homebrew/commits/master/Library/Formula/postgresql.rb
==> Dependencies
Required: readline ✔
Recommended: ossp-uuid ✔
==> Options
--32-bit
Build 32-bit only
--enable-dtrace
Build with DTrace support
--no-perl
Build without Perl support
--no-tcl
Build without Tcl support
--without-ossp-uuid
Build without ossp-uuid support
--without-python
Build without python support
==> Caveats
If builds of PostgreSQL 9 are failing and you have version 8.x installed,
you may need to remove the previous version first. See:
https://github.com/Homebrew/homebrew/issues/issue/2510
To migrate existing data from a previous major version (pre-9.3) of PostgreSQL, see:
http://www.postgresql.org/docs/9.3/static/upgrading.html
When installing the postgres gem, including ARCHFLAGS is recommended:
ARCHFLAGS="-arch x86_64" gem install pg
To install gems without sudo, see the Homebrew wiki.
To have launchd start postgresql at login:
ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
Then to load postgresql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist
Or, if you don't want/need launchctl, you can just run:
postgres -D /usr/local/var/postgres
When I run server, I get:
/usr/local/rvm/gems/ruby-2.0.0-p353/gems/activerecord-4.0.0/lib/active_record/connection_adapters/postgresql_adapter.rb:825:in `initialize': could not connect to server: No such file or directory (PG::ConnectionBad)
Is the server running locally and accepting
connections on Unix domain socket "/var/pgsql_socket/.s.PGSQL.5432"?
I've uninstalled postgresql and reinstalled but seems like I wasn't able to remove the postgresql 8.x version.
I've read several different posts to install and run postgreSQL properly and tried what they've suggested but nothing seems to be working for me.
Installing PostgreSQL in Mac OS X El Capitan using homebrew
First check the 'owner' of the folder '/usr/local' by using this command:
$ ls -la '/usr'
If the owner of the file is 'root', run this command to change the owner to your currently logged user:
$ sudo chown -R `whoami` /usr/local
Install PostgreSQL using homebrew:
$ brew update
$ brew doctor
$ brew install postgresql#15
and that's it!
Uninstall PostgreSQL using homebrew:
$ brew uninstall postgres
then remove this folder: '/usr/local/var/postgres' and then change back the owner of your local
local folder to:
$ sudo chown -R root /usr/local
How to:
List brew services: $ brew services list
Run brew services: $ brew services start <service_name>
ex: $ brew services start postgresql
Stop brew serices: $ brew services stop <service_name>
Logging in to PostgreSQL for the first time:
1.) Run the postgres: $ brew services star postgresql
2.) Create a db using your username: $ createdb `whoami`
3.) Login to postgres: $ psql
To quit psql, just type: \q
4.) Create database (using terminal):
$ createdb <db_name>
psql tutorial:
http://blog.trackets.com/2013/08/19/postgresql-basics-by-example.html
http://exponential.io/blog/2015/02/21/install-postgresql-on-mac-os-x-via-brew/
Optional, installing pgAdmin:
1.) Download pdadmin: https://www.pgadmin.org/download/macosx.php
2.) Press ctrl+click then open to run the dmg file then drag it to your
Application folder. ctrl+click the pdadmin to run it so that it won't
ask for that annoying question again.
Login in to pgAdmin:
Note: Use your username and password when you installed your postgres for first login
then create a new user with privileges later or just change your password from
'File -> Change Password...'
Your Ruby code is apparently linked against the system version of PostgreSQL, which looks for a socket in /var/pgsql_socket. The Homebrew version would look in /tmp. (At this point, make sure that a file like /tmp/.s.PGSQL.5432 exists.) To work around this, you can tell your code to connect to the Homebrew version by specifying /tmp with the "host" option, however your code spells that.
In the future, make sure your Ruby gems are linked against the Homebrew version. Perhaps just uninstalling and reinstalling with the right paths set would do it.

Getting Redis up an running with ruby

I have installed Redis via gems, but am having a problem getting it started.
Following James Edward Gary II steps http://blog.grayproductions.net/articles/setting_up_the_redis_server/
I have:
$ sudo gem install ezmobius-redis
Password:
Successfully installed ezmobius-redis-0.1
1 gem installed
Installing ri documentation for ezmobius-redis-0.1...
Installing RDoc documentation for ezmobius-redis-0.1...
$ redis-server path/to/redis.conf
-bash: redis-server: command not found
Any thoughts as to what I am missing?
If you have done just what you have described in your question, then you are missing redis. ezmobius-redis is just a Ruby library that allows connecting to redis. redis itself is a separate piece of software running independently.
If you followed the article you linked and if you especially did this:
curl -O http://redis.googlecode.com/files/redis-1.0.tar.gz
tar xzvf redis-1.0.tar.gz
cd redis-1.0
make
sudo cp redis-server redis-cli redis-benchmark /usr/local/bin
then you have actually installed a very old version of redis into the /usr/local directory.
If you did this starting the server did not work, then you probably have /usr/local not in your PATH. You can start the server using:
$ /usr/local/bin/redis-server path/to/redis.conf
However, I would suggest to install the newest version of redis. To do that on OSX you should use homebrew:
- Read this (https://github.com/mxcl/homebrew/wiki/Installation) as a guide on how to install homebrew and then do a
brew install redis
to install the newest version of redis.
You might need to open a new terminal to get the latest path settings. Try typing "bash" or "xterm &" and typing the redis-server command again.

Resources