mac 環境設定 mavericksからYosemiteにupdateしたらmailがフリーズする件
macをYosemiteにupdateして、前回記事を書いた頃までは問題なく使えていたmail。
しかし、ここ2週間ほどフリーズすることが増えてきました。
そのほとんどがmailを起動した時!
mailのデータ読み込みで固まっている感じです。
どうやらGmailとの相性がイマイチのようで・・
問題3 Gmailとメールバグ問題
多くのユーザーはGmailとメール同期のバグ問題に文句を言っています。Gmailとメールバグは最も一般的な問題です。まず、新しいOS XにおいてGmailとメールアプリケーションをシンクロ問題があります。Macと急にシンクロさせるとアプリが落ち、クラッシュしてしまうのです。開いている間、新たなメールやメッセージは表示されません。
解決方法としては・・
アカウントの詳細タブで「すべての添付ファイルを自動的にダウンロード」のチェックを外す。
これだけ。これで今の所フリーズすることは無くなりました。
mac 環境設定 cpanmでDBD::mysqlを入れる
以前利用していたMT4のブログをWPに移行したい!
なんせ、MT4はSQLite2で作成していたためデータを取り出すのが大変そうです。
『ひとまずMT4をMySQLで構築してみましょう。』と、いう流れになったのですが・・・
DBD::mysqlが入っていないため、今はperlからMySQLへ接続出来ない状態です。
cpanmのインストール
まずはcpanmのインストールから。
Mac(mavericks)にcpanmをインストールする | hypermkt blog を参考にインストールしてみます。
$ cd /usr/bin
$ sudo curl -LOk http://xrl.us/cpanm
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 216 0 216 0 0 468 0 --:--:-- --:--:-- --:--:-- 469
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0
0 0 0 131 0 0 31 0 --:--:-- 0:00:04 --:--:-- 700
100 295k 100 295k 0 0 67914 0 0:00:04 0:00:04 --:--:-- 67914$ ls -l | grep cpanm
-rw-r--r-- 1 root wheel 302366 6 2 15:08 cpanm$ sudo chmod +x cpanm
$ cpanm
Usage: cpanm [options] Module [...]
Try `cpanm --help` or `man cpanm` for more options.
これでcpanmのインストールはOKです。
DBD::mysqlのインストール
次に cpanmでDBD::mysqlを入れる - Qiita を参考にDBD::mysqlを入れてみたいと思います。
export DBD_MYSQL_CFLAGS=-I/usr/local/Cellar/mysql/5.6.15/bin/mysql export DBD_MYSQL_LIBS="-L/usr/local/Cellar/mysql/5.6.15/bin/mysql -lmysqlclient" export DBD_MYSQL_EMBEDDED= export DBD_MYSQL_CONFIG=/usr/local/Cellar/mysql/5.6.15/bin/mysql_config export DBD_MYSQL_NOCATCHSTDERR=0 export DBD_MYSQL_NOFOUNDROWS=0 export DBD_MYSQL_SSL= export DBD_MYSQL_TESTDB=test export DBD_MYSQL_TESTHOST=localhost export DBD_MYSQL_TESTPASSWORD= export DBD_MYSQL_TESTPORT=3306 export DBD_MYSQL_TESTUSER=root
参考サイトとMySQLのバージョンが違ってたので、そこだけ注意しながら1行ずつコピペ実行しました。
環境変数が設定されているか
env | grep DBD_
で確認。
先ほど打ち込んだ内容がズラズラ〜と表示されました。
$ cpanm DBD::mysql
!
! Can't write to /Library/Perl/5.16 and /usr/local/bin: Installing modules to /Users/username/perl5
! To turn off this warning, you have to do one of the following:
! - run me as a root or with --sudo option (to install to /Library/Perl/5.16 and /usr/local/bin)
! - Configure local::lib your existing local::lib in this shell to set PERL_MM_OPT etc.
! - Install local::lib by running the following commands
!
! cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
!
--> Working on DBD::mysql
Fetching http://www.cpan.org/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.031.tar.gz ... OK
Configuring DBD-mysql-4.031 ... OK
Building and testing DBD-mysql-4.031 ... FAIL
! Installing DBD::mysql failed. See /Users/username/.cpanm/work/1433225834.1048/build.log for details. Retry with --force to force install it.
なんかエラー・・・
sudoで叩いてみる。
$ sudo cpanm --force DBD::mysql
Password:
--> Working on DBD::mysql
Fetching http://www.cpan.org/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.031.tar.gz ... OK
Configuring DBD-mysql-4.031 ... OK
Building and testing DBD-mysql-4.031 ... FAIL
! Installing DBD::mysql failed. See /Users/username/.cpanm/work/1433227104.4380/build.log for details. Retry with --force to force install it.
またまたエラー。
ログで確認すると「Xcodeのライセンスがない」みたいなことが書かれているので、Xcodeを起動してライセンスを取得。
$ cpanm --force DBD::mysql
!
! Can't write to /Library/Perl/5.16 and /usr/local/bin: Installing modules to /Users/username/perl5
! To turn off this warning, you have to do one of the following:
! - run me as a root or with --sudo option (to install to /Library/Perl/5.16 and /usr/local/bin)
! - Configure local::lib your existing local::lib in this shell to set PERL_MM_OPT etc.
! - Install local::lib by running the following commands
!
! cpanm --local-lib=~/perl5 local::lib && eval $(perl -I ~/perl5/lib/perl5/ -Mlocal::lib)
!
--> Working on DBD::mysql
Fetching http://www.cpan.org/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.031.tar.gz ... OK
Configuring DBD-mysql-4.031 ... OK
Building and testing DBD-mysql-4.031 ... OK
Successfully installed DBD-mysql-4.031
1 distribution installed
やっぱりsudoでないとダメみたいです。
$ sudo cpanm --force DBD::mysql
Password:
--> Working on DBD::mysql
Fetching http://www.cpan.org/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.031.tar.gz ... OK
Configuring DBD-mysql-4.031 ... OK
Building and testing DBD-mysql-4.031 ... OK
Successfully installed DBD-mysql-4.031
1 distribution installed
無事インストール出来たみたいです。
確認します。
何も表示されなければOK!
mac 初期設定 part9 - Apache と MySQL の自動起動設定
~/Library/LaunchAgentsにシンボリックリンクをはる。
$ ln -sfv /usr/local/opt/httpd/*.plist ~/Library/LaunchAgents
/Users/username/Library/LaunchAgents/homebrew.mxcl.httpd.plist -> /usr/local/opt/httpd/homebrew.mxcl.httpd.plist
OS起動時にApacheを自動で起動する。
$ sudo launchctl load ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist
Password:
launchctl: Dubious ownership on file (skipping): /Users/username/Library/LaunchAgents/homebrew.mxcl.httpd.plist
nothing found to load
なんかエラーっぽい。。
plistファイルの権限をroot:wheelにする必要があるとか・・・。
$ sudo chown root:wheel ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist
で、リトライ!
$ sudo launchctl load ~/Library/LaunchAgents/homebrew.mxcl.httpd.plist
$ sudo apachectl restart
うまくいったっぽいです。
~/Library/LaunchAgentsにシンボリックリンクをはる。
$ ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
/Users/username/Library/LaunchAgents/homebrew.mxcl.mysql.plist -> /usr/local/opt/mysql/homebrew.mxcl.mysql.plist
一度再起動して確認しましょう!
OSを再起動してみて、ApacheとMySQLが動いていればOK!
のはずが・・・Apacheが起動されない><。
MySQLは起動してるのに。
いろいろ調べた結果、 /System/Library/LaunchDaemonsにシンボリックリンクを張れば良さそうです。
$ sudo ln -sfv /usr/local/opt/httpd/*.plist /System/Library/LaunchDaemons
Password:
/System/Library/LaunchDaemons/homebrew.mxcl.httpd.plist -> /usr/local/opt/httpd/homebrew.mxcl.httpd.plist
$ sudo apachectl restart
OS再起動して、
username 437 0.1 0.0 2432784 604 s000 S+ 12:44AM 0:00.00 grep httpd
daemon 151 0.0 0.0 2478244 780 ?? S 12:43AM 0:00.00 /usr/local/Cellar/httpd/2.2.26/sbin/httpd -k start
daemon 150 0.0 0.0 2478244 760 ?? S 12:43AM 0:00.00 /usr/local/Cellar/httpd/2.2.26/sbin/httpd -k start
daemon 149 0.0 0.0 2478244 816 ?? S 12:43AM 0:00.00 /usr/local/Cellar/httpd/2.2.26/sbin/httpd -k start
daemon 148 0.0 0.0 2478244 736 ?? S 12:43AM 0:00.00 /usr/local/Cellar/httpd/2.2.26/sbin/httpd -k start
daemon 147 0.0 0.0 2478244 784 ?? S 12:43AM 0:00.00 /usr/local/Cellar/httpd/2.2.26/sbin/httpd -k start
daemon 140 0.0 0.0 2467084 736 ?? S 12:43AM 0:00.00 /usr/local/Cellar/httpd/2.2.26/sbin/httpd -k start
root 139 0.0 0.2 2478244 7820 ?? Ss 12:43AM 0:00.21 /usr/local/Cellar/httpd/2.2.26/sbin/httpd -k start
mac 初期設定 part8 - Finderの不可視ファイルを表示する
不可視ファイルが見えない(アクセスできない)と何かと不便なので、表示させちゃいます。
ターミナルで以下の設定を「TRUE」に変更。
$ defaults write com.apple.finder AppleShowAllFiles TRUE
Finderを再起動
$ killall Finder
以上。
mac 初期設定 part7 - Webサーバの構築 phpMyAdminのインストール
外部 formula の josegonzalez/homebrew-php を使います。
先ほど入れたのでここは割愛。
念のため、searchで検索だけしておきます。
$ brew search phpmyadmin
phpMyAdminをインストールします。
$ brew install phpmyadmin
==> Installing dependencies for phpmyadmin: mcrypt, php54-mcrypt
==> Installing phpmyadmin dependency: mcrypt
==> Downloading http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/mcrypt/2.5.8 --mandir=/usr/local/Cell
==> make install
🍺 /usr/local/Cellar/mcrypt/2.5.8: 12 files, 332K, built in 30 seconds
==> Installing phpmyadmin dependency: php54-mcrypt
==> Downloading http://www.php.net/get/php-5.4.24.tar.bz2/from/this/mirror
######################################################################## 100.0%
==> PHP_AUTOCONF="/usr/local/opt/autoconf/bin/autoconf" PHP_AUTOHEADER="/usr/loc
==> ./configure --prefix=/usr/local/Cellar/php54-mcrypt/5.4.24 --with-php-config
==> make
==> Caveats
To finish installing mcrypt for PHP 5.4:
* /usr/local/etc/php/5.4/conf.d/ext-mcrypt.ini was created,
do not forget to remove it upon extension removal.
* Validate installation via one of the following methods:
*
* Using PHP from a webserver:
* - Restart your webserver.
* - Write a PHP page that calls "phpinfo();"
* - Load it in a browser and look for the info on the mcrypt module.
* - If you see it, you have been successful!
*
* Using PHP from the command line:
* - Run "php -i" (command-line "phpinfo()")
* - Look for the info on the mcrypt module.
* - If you see it, you have been successful!
==> Summary
🍺 /usr/local/Cellar/php54-mcrypt/5.4.24: 3 files, 56K, built in 21 seconds
==> Installing phpmyadmin
==> Downloading https://github.com/phpmyadmin/phpmyadmin/archive/RELEASE_4_1_4.t
######################################################################## 100.0%
==> Caveats
Note that this formula will NOT install mysql. It is not
required since you might want to get connected to a remote
database server.
Webserver configuration example (add this at the end of
your /etc/apache2/httpd.conf for instance) :
Alias /phpmyadmin /usr/local/share/phpmyadmin
<Directory /usr/local/share/phpmyadmin/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Then, open http://localhost/phpmyadmin
More documentation : file:///usr/local/Cellar/phpmyadmin/4.1.4/share/phpmyadmin/doc/
Don't forget to copy config.sample.inc.php to config.inc.php and :
- change your secret blowfish
- uncomment the configuration lines (pma, pmapass ...)
==> Summary
🍺 /usr/local/Cellar/phpmyadmin/4.1.4: 1532 files, 50M, built in 65 seconds
phpMyAdminのバーチャルホスト設定
/usr/local/etc/apache2/httpd.conf のバーチャルホストの設定ファイルをコメントを外して有効化します。
# Virtual hosts
Include /usr/local/etc/apache2/extra/httpd-vhosts.conf
バーチャルホストの設定ファイルを編集
/usr/local/etc/apache2/extra/httpd-vhosts.conf でバーチャルホストの設定ファイルを編集します。
元々あったダミーの設定をすべて削除して以下の内容を追加
Alias /phpmyadmin /usr/local/share/phpmyadmin
<Directory /usr/local/share/phpmyadmin/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
設定ファイル config.inc.php を作成
/usr/local/Cellar/phpmyadmin/4.1.4/share/phpmyadmin/config.sample.inc.php をコピーして設定ファイル config.inc.php を作成します。
$ cp /usr/local/Cellar/phpmyadmin/4.1.4/share/phpmyadmin/config.sample.inc.php /usr/local/Cellar/phpmyadmin/4.1.4/share/phpmyadmin/config.inc.php
$ sudo apachectl restart
Password:
$ mysql.server restart
Shutting down MySQL
. SUCCESS!
Starting MySQL
.. SUCCESS!
http://localhost/phpmyadminにアクセスして、ログインできたらOK!
mac 初期設定 part6 - Webサーバの構築 MySQLのインストール
HomebrewコマンドでMySQLをインストールします。
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/mysql-5.6.1
######################################################################## 100.0%
==> Pouring mysql-5.6.15.mavericks.bottle.tar.gz
==> Caveats
A "/etc/my.cnf" from another install may interfere with a Homebrew-built
server starting up correctly.
To connect:
mysql -uroot
To have launchd start mysql at login:
ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents
Then to load mysql now:
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
Or, if you don't want/need launchctl, you can just run:
mysql.server start
==> /usr/local/Cellar/mysql/5.6.15/bin/mysql_install_db --verbose --user=username
==> Summary
🍺 /usr/local/Cellar/mysql/5.6.15: 9410 files, 349M
MySQL の起動
$ mysql.server start
Starting MySQL
.. SUCCESS!
MySQL のセキュリティ設定
$ mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): ENTERキー
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] Y
New password: rootのパスワードを入力
Re-enter new password: rootのパスワードを再入力
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] Y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] Y
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] Y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] Y
... Success!
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
Cleaning up...
これでインストールOK!