LoginSignup
5

More than 5 years have passed since last update.

osxでwordpressを nginx, php-fpm,mysql の組み合わせて動かす。

Last updated at Posted at 2013-09-24

タイトルの通りです。どうせApacheでやっても標準の「共有」→「ウェブ」機能と被ってしまってめんどくさいことになるので。やった作業を思い出しながら書いてるので抜けがあるかもしれません。

事前準備

まずは $ brew doctor してhomebrew の準備を万全にしておきましょう。
俺はbrewを初めてインストールして以来全然してなかったのにアホみたいに警告出てきました。

結局何時間もかけてそれを警告をほとんどでなくできましたがこれだけは失くせませんでした。
``
Warning: "config" scripts exist outside your system or Homebrew directories.
./configure` scripts often look for *-config scripts to determine if
software packages are installed, and what additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew provided
script of the same name. We found the following "config" scripts:

/Users/ironsand/.rbenv/shims/passenger-config

多分偶然gemの名前と一致しただけっぽいので放置してても良さそうだけど、ちゃんとした解決方法を知ってる人がいたら教えて下さい。

## Nginx のインストール

`$ brew install nginx` でインストールできる。

起動は `$ brew -s reload` で。`start`はないらしい。なんでや。

設定ファイルは `/usr/local/nginx` 配下に。

## php のインストール

`$ brew install --without-apache --with-fpm --with-mysql php55` でインストール

そうするとインストールが終わったら英語で色々とメッセージが出てくる。
昔は英語が嫌いだったからこういうのを読み飛ばしてたけど、よく読んだらここに重要な事は全部書いてあるので絶対読んだほうがいいです。

✩✩✩✩ PEAR ✩✩✩✩

If PEAR complains about permissions, 'fix' the default PEAR permissions and config:
chmod -R ug+w /usr/local/Cellar/php55/5.5.4/lib/php
pear config-set php_ini /usr/local/etc/php/5.5/php.ini

✩✩✩✩ Extensions ✩✩✩✩

If you are having issues with custom extension compiling, ensure that this php is
in your PATH:
PATH="$(brew --prefix josegonzalez/php/php55)/bin:$PATH"

PHP55 Extensions will always be compiled against this PHP. Please install them
using --without-homebrew-php to enable compiling against system PHP.

✩✩✩✩ FPM ✩✩✩✩

To launch php-fpm on startup:
* If this is your first install:
mkdir -p ~/Library/LaunchAgents
cp /usr/local/Cellar/php55/5.5.4/homebrew-php.josegonzalez.php55.plist ~/Library/LaunchAgents/
launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist

* If this is an upgrade and you already have the homebrew-php.josegonzalez.php55.plist loaded:
    launchctl unload -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist
    cp /usr/local/Cellar/php55/5.5.4/homebrew-php.josegonzalez.php55.plist ~/Library/LaunchAgents/
    launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist

The control script is located at /usr/local/Cellar/php55/5.5.4/sbin/php55-fpm

You may also need to edit the plist to use the correct "UserName".

Please note that the plist was called 'org.php-fpm.plist' in old versions
of this formula.

To have launchd start php55 at login:
ln -sfv /usr/local/opt/php55/*.plist ~/Library/LaunchAgents
Then to load php55 now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.php55.plist
````

fpmを使いたいので指示通りに

$ mkdir -p ~/Library/LaunchAgents
$ cp /usr/local/Cellar/php55/5.5.4/homebrew-php.josegonzalez.php55.plist ~/Library/LaunchAgents/
$ launchctl load -w ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist

ログイン時に起動にして、とりあえず今立ち上げる。

$ ln -sfv /usr/local/opt/php55/*.plist ~/Library/LaunchAgents
$ launchctl load ~/Library/LaunchAgents/homebrew-php.josegonzalez.php55.plist

何故か説明だと mxcl さんのになってるけど josegonzalez さんのを使います。Issuesに上がってました。

Mysql のインストール

随分前にインストールしたのですっかり忘れてるけど多分 $ brew install mysql で入ります。

んで

$ mkdir -p ~/Library/LaunchAgents
$ ln -s `brew --prefix mysql`/homebrew.mxcl.mysql.plist ~/Library/launchAgents/
$ launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist

後はMysqlにwordpressって名前のデータベースを作って、適当に好きなユーザー名を作ればOKです。(めんどくさくなった。)

<取り消し線>そして、何か色々してて躓きまくってMysqlにちゃんとログイン出来ないので諦め。
もうVPSの方で作業します…。</取り消し線>

$ brew uninstall mysql
$ brew install mysql

したら直りました。

参考

Brew'ing PHP, MySQL & Nginx on Mac OS X
http://rtcamp.com/wordpress-nginx/tutorials/mac-osx-brew-php-mysql-nginx/

osx - autostart mysql on boot from terminal - Stack Overflow
http://stackoverflow.com/questions/8014500/autostart-mysql-on-boot-from-terminal

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5