前の10件 1  2  3  4  5  6  7  8  9

お次はperlをインストールします。

まずはデフォルトバージョンの確認

$ perl -v

This is perl, v5.8.9 built for darwin-2level

続いてmacportsの確認

$ port search perl
・・・
perl5 @5.8.9 (lang)
    Wrapper port for perl 5.x

perl5.10 @5.10.1 (lang)
    Perl 5.10.x - Practical Extraction and Report Language

perl5.12 @5.12.2 (lang)
    Perl 5.12.x - Practical Extraction and Report Language

perl5.8 @5.8.9 (lang)
    Perl 5.8.x - Practical Extraction and Report Language
・・・

とりあえず最新バージョンをインストールすることに。

関連モジュールの検索

$ port variants perl5.12
perl5.12 has the variants:
   dtrace: Build with DTrace probes
   mangle_names: mangle the installed names by appending -5.12 to avoid
                 conflicting with perl5.8 and perl5.10
   shared: Build shared perl library
   threads: Build with thread support
   universal: Build for multiple architectures

特にこれが必要!てのは無さそうなので、単体でインストールすることに。

$ sudo port install perl5.12
・・・
Error: Target org.macports.activate returned: Image error: /opt/local/bin/a2p is being used by the active perl5.8 port.  Please deactivate this port first, or use 'port -f activate perl5.12' to force the activation.
Log for perl5.12 is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_lang_perl5.12/main.log
Error: Status 1 encountered during processing.
To report a bug, see <http://guide.macports.org/#project.tickets>

なんかエラーでた。

perl5.8 が port を使用中なので、そいつを停止させるか perl5.12 が使うように指示を出してください(?)

!!! そういえば、phpをインストールしたときにperlも一緒にインストールされていたような・・・。

mac の開発環境構築 〜PHP〜

やっぱり。。

念のため、今までにインストールされたパッケージを確認。

$ port installed
The following ports are currently installed:
  apache-ant @1.8.1_0 (active)
  apache2 @2.2.16_0+preforkmpm
  apache2 @2.2.17_0+preforkmpm (active)
  apr @1.4.2_1 (active)
  apr-util @1.3.9_2 (active)
  autoconf @2.68_0 (active)
  autoconf213 @2.13_1 (active)
  automake @1.11.1_0 (active)
  bzip2 @1.0.6_0 (active)
  curl @7.21.2_1+ssl (active)
  curl-ca-bundle @7.21.2_0 (active)
  cyrus-sasl2 @2.1.23_3+kerberos (active)
  db46 @4.6.21_6 (active)
  expat @2.0.1_1 (active)
  freetype @2.4.3_0 (active)
  gawk @3.1.8_0 (active)
  gettext @0.18.1.1_2 (active)
  gperf @3.0.4_0 (active)
  gsed @4.2.1_0 (active)
  help2man @1.38.2_0 (active)
  jpeg @8b_0 (active)
  libiconv @1.13.1_0 (active)
  libidn @1.19_0 (active)
  libmcrypt @2.5.8_1 (active)
  libpng @1.2.44_0 (active)
  libtool @2.4_0 (active)
  libxml2 @2.7.7_0 (active)
  m4 @1.4.15_0 (active)
  mhash @0.9.9.9_0 (active)
  mysql5 @5.1.51_0 (active)
  mysql5-server @5.1.51_0 (active)
  ncurses @5.7_1 (active)
  ncursesw @5.7_1 (active)
  neon @0.29.5_0 (active)
  openssl @1.0.0a_0
  openssl @1.0.0a_1 (active)
  p5-locale-gettext @1.05_3 (active)
  pcre @8.10_0 (active)
  perl5 @5.8.9_0 (active)
  perl5.12 @5.12.2_0
  perl5.8 @5.8.9_3 (active)
  php5 @5.3.3_2+apache2+pear (active)
  php5-curl @5.3.3_0 (active)
  php5-gd @5.3.3_0 (active)
  php5-mbstring @5.3.3_0 (active)
  php5-mcrypt @5.3.3_0 (active)
  php5-mysql @5.3.3_0+mysqlnd (active)
  php5-sqlite @5.3.3_0 (active)
  php5-tidy @5.3.3_0 (active)
  php5-zip @5.3.3_0 (active)
  phpmyadmin @3.3.5.1_0 (active)
  pkgconfig @0.25_1 (active)
  readline @6.1.002_0 (active)
  serf @0.7.0_0 (active)
  sqlite3 @3.7.3_0 (active)
  subversion @1.6.13_0 (active)
  tidy @20090325_0 (active)
  zlib @1.2.5_0 (active)

perl5.12もちゃんとインストールされたけどactiveじゃないよ。ってことだね。

とりあえずOKにしておきましょう。5.12が必要になったらそのときにactiveにすればヨシ。

参考サイト:PerlをMacPortsからインストールする

いちいち長ったらしいパスから起動するのは面倒なので、エイリアスの設定をしておきましょう。

$  vi ~/.bash_profile

alias apache_start="sudo /opt/local/apache2/bin/apachectl start"
alias apache_stop="sudo /opt/local/apache2/bin/apachectl stop"
alias apache_restart="sudo /opt/local/apache2/bin/apachectl restart"

参考サイト:Snow LeopardなMacBookにMacPortsで開発環境入れ直し(Apache2/PHP5/MySQL5/PostgreSQL8.3)

続いてphpmyadminをインストール

$ port search phpmyadmin
phpmyadmin @3.3.5.1 (www, php, databases)
    A tool written in PHP intended to handle the administration of MySQL over
    the Web.

macportsの扱いにもそろそろ慣れてきましたね。

$ sudo port install phpmyadmin
・・・
A new configuration file has been created at /opt/local/www/phpmyadmin/config.inc.php.
Please refer to the phpMyAdmin documentation when editing this file,
an online version of which can be found at http://www.phpmyadmin.netdocumentation/Documentation.html#config
・・・

設定ファイルが作成されたので編集してください。と

デフォルトの設定ファイルをバックアップ

$ sudo cp /opt/local/www/phpmyadmin/config.inc.php /opt/local/www/phpmyadmin/config.inc.php.bak

設定ファイルを編集

$ sudo vi /opt/local/www/phpmyadmin/config.inc.php

// conneatタイプをsocketに変更
$cfg['Servers'][$i]['connect_type'] = 'socket';
// socket接続先を追加
$cfg['Servers'][$i]['socket'] = '/opt/local/var/run/mysql5/mysqld.sock';

Apacheに接続先を追加

<Directory /opt/local/www/phpmyadmin>
    Options FollowSymLinks
    AllowOverride All
    Order deny,allow
    Deny from all
    Allow from all
</Directory>
Alias /phpMyAdmin /opt/local/www/phpmyadmin

apacheを再起動

$ sudo /opt/local/apache2/bin/apachectl restart

http://localhost/phpMyAdmin/ に接続。MySQLのID、passでログイン。OK^^v

参考サイト:MacPortsでphpMyAdminをインストール

PHPから使えるようにphp5-mysqlをインストール

$ sudo port install php5-mysql
・・・
###########################################################
# A startup item has been generated that will aid in
# starting apache2 with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo port load apache2
###########################################################
Note: apache2 installs files outside the common directory structure.
・・・

apache2をloadしてくださいとのこと。

$ sudo port load apache2
Password:
Error: Target org.macports.load returned: org.macports.apache2: Already loaded
Log for apache2 is at: /opt/local/var/macports/logs/_opt_local_var_macports_sources_rsync.macports.org_release_ports_www_apache2/main.log
Error: Status 1 encountered during processing.
To report a bug, see 

またまたエラー。もう入ってます。ですって。

php.iniのdefault_socketを設定します。

$ sudo vi /opt/local/etc/php5/php.ini

pdo_mysql.default_socket=/opt/local/var/run/mysql5/mysqld.sock
mysql.default_socket =/opt/local/var/run/mysql5/mysqld.sock
mysqli.default_socket =/opt/local/var/run/mysql5/mysqld.sock

apacheを再起動してphpinfoで確認。OK!

参考サイト:macportsでMac Snow LeopardにApache2 + PHP5 + MySQL5 を入れる

続いてMySQLをインストール。

まずはデフォルトのMySQLの確認

$ mysql -v
-bash: mysql: command not found
$ ps ax | grep mysql

あれ?デフォルトでMySQLは入ってなかったかな??

ではMacPortsでインストールできるMySQLバージョンの確認

$ port search mysql
・・・
mysql4 @4.1.22 (databases)
    Multithreaded SQL database server

mysql5 @5.1.51 (databases)
    Multithreaded SQL database server

mysql5-devel @5.5.2-m2 (databases)
    Multithreaded SQL database server

mysql5-server @5.1.51 (databases)
    Multithreaded SQL database server

mysql5-server-devel @5.5.2-m2 (databases)
    Multithreaded SQL database server
・・・

インストール時に指定できる variants を確認

$ port variants mysql5-server
mysql5-server has no variants

mysql5-serverをインストール

$ sudo port install mysql5-server
・・・
###########################################################
# A startup item has been generated that will aid in
# starting mysql5-server with launchd. It is disabled
# by default. Execute the following command to start it,
# and to cause it to launch at startup:
#
# sudo port load mysql5-server
###########################################################
--->  Installing mysql5-server @5.1.51_0
******************************************************
* In order to setup the database, you might want to run
* sudo -u _mysql mysql_install_db5
* if this is a new install
******************************************************
・・・

mysql5-serverをloadしてください。といわれるので、いわれるまま叩いてみる。

$ sudo port load mysql5-server

お次もいわれるがまま

$ sudo -u _mysql mysql_install_db5
Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin -u root -h macmini.local password 'new-password'

Alternatively you can run:
/opt/local/lib/mysql5/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /opt/local ; /opt/local/lib/mysql5/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /opt/local/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /opt/local/lib/mysql5/bin/mysqlbug script!

パスワードを設定してください。とのことです。

$ sudo /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'
/opt/local/lib/mysql5/bin/mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)'
Check that mysqld is running and that the socket: '/opt/local/var/run/mysql5/mysqld.sock' exists!

おっと?connectがつながらないですって!

とりあえず起動してみることに

$ sudo /opt/local/share/mysql5/mysql/mysql.server start
Password:
Starting MySQL
. SUCCESS! 

もいちどトライ

$ sudo /opt/local/lib/mysql5/bin/mysqladmin -u root password 'new-password'

今度はうまく通ったみたい。

ログインしてみる

$ /opt/local/lib/mysql5/bin/mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.1.51 Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> 

「mysql5」コマンドで操作できるみたい。

数学ガール

| コメント(0)
結城 浩
ソフトバンククリエイティブ
発売日:2007-06-27

久しぶりに数式を見てワクワクドキドキした。

数式から生まれるあらたな数式。

偉人たちが発明した方程式を自分で証明してみる。
証明できたときの達成感!!
とてもなつかしい感覚。

もいちど学生に戻りたい。って思った。

PHPインストールのときにオプション指定できなかったものたちをインストールしていきます。

  • php5-sqlite
  • php5-mysql
  • php5-mbstring
  • php5-curl
  • php5-gd
  • php5-tidy
  • php5-mcrypt
  • php5-zip

こんなところでしょうか。ではインストールしていきます。

$ sudo port install php5-sqlite php5-mysql php5-mbstring php5-curl php5-gd php5-tidy php5-mcrypt php5-zip

apacheが入りましたので、お次は私にとって使用頻度が最も高いPHPをインストールします。

まずはデフォルトのPHPバージョンの確認

$ php -v
PHP 5.3.2 (cli) (built: Aug  7 2010 00:04:41) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

次にMacPortsでインストールできるPHPバージョンの確認

$ port search php
・・・
php4 @4.4.9 (lang, php, www)
    PHP: Hypertext Preprocessor

php5 @5.3.3 (lang, php, www)
    PHP: Hypertext Preprocessor
・・・

インストール時に指定できる variants を確認

$ port variants php5
php5 has the variants:
   apache: Add Apache 1 web server module
     * conflicts with apache2 no_web
[+]apache2: Add Apache 2.2 web server module
     * conflicts with apache no_web
   debug: Enable debug support (useful to analyze a PHP-related core dump)
   fastcgi: Add FastCGI web server binary
     * conflicts with no_web
   gmp: Obsolete; install php5-gmp port instead
   imap: Obsolete; install php5-imap port instead
   ipc: Add semaphore, shared memory and IPC functions
   macports_snmp: Obsolete; install php5-snmp port instead
   mssql: Obsolete; install php5-mssql port instead
   mysql4: Obsolete; install php5-mysql port instead
   mysql5: Obsolete; install php5-mysql port instead
   mysqlnd: Obsolete; install php5-mysql port instead
   no_web: Don't include any web server support
     * conflicts with apache apache2 fastcgi
   oracle: Obsolete; install php5-oracle port instead
   pcntl: Obsolete; install php5-pcntl port instead
   pear: Add PEAR
   postgresql82: Obsolete; install php5-postgresql port instead
   postgresql83: Obsolete; install php5-postgresql port instead
   pspell: Obsolete; install php5-pspell port instead
   snmp: Obsolete; install php5-snmp port instead
   sockets: Obsolete; install php5-sockets port instead
   sqlite: Obsolete; install php5-sqlite port instead
   suhosin: Add Suhosin patch
   tidy: Obsolete; install php5-tidy port instead
   universal: Build for multiple architectures

ほとんど「Obsolete」になっていてもう使えないもよう。、代わりに php5-**** でインストールする必要があるみたいです。

とりあえず、+apache2 と +pear だけ一緒にインストールしましょう。

$  sudo port install php5 +apache2 +pear

インストールの最後に、次のような指示がきました。

To customize php, copy
/opt/local/etc/php5/php.ini-development (if this is a development server) or
/opt/local/etc/php5/php.ini-production (if this is a production server) to
/opt/local/etc/php5/php.ini and then make changes.

If this is your first install, you need to activate PHP in your web server.

To enable PHP in Apache, run
  cd /opt/local/apache2/modules
  /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so

指示に従ってまずはphp.iniファイルを作成します。

$ sudo cp /opt/local/etc/php5/php.ini-development /opt/local/etc/php5/php.ini

apacheにPHPを追加

$ cd /opt/local/apache2/modules
$ /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
[activating module `php5' in /opt/local/apache2/conf/httpd.conf]
unable to open configuration file

!!sudoをつけ忘れたw 直接設定ファイルを編集することに。

phpモジュールの読み込みを追加

$ sudo vi /opt/local/apache2/conf/httpd.conf

# phpモジュールの読み込み
LoadModule php5_module modules/libphp5.so

# mod_php.confの読み込み
Include conf/extra/mod_php.conf

index.php を有効に

$ sudo vi /opt/local/apache2/conf/httpd.conf

#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    # DirectoryIndex index.html
    DirectoryIndex index.php index.html index.html.var
</IfModule>

インストールされたPHPのバージョン確認も忘れずに。(ターミナル再起動してね)

$ php -v
PHP 5.3.3 (cli) (built: Oct 26 2010 17:02:06) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

phpinfo で確認するとdate関数でエラーが表示されていたのでphp.ini の date.timezone を以下のように設定します。

$ sudo vi /opt/local/etc/php5/php.ini 

date.timezone = Asia/Tokyo

参考サイト:Mac OS X(Snow Leopard)のMacPortsでApache2, PHP5, MySQL5をインストールし直した

続いてwebサーバー「Apache」をインストールします。

まずはデフォルトのApacheバージョンの確認。

$ apachectl -v
Server version: Apache/2.2.14 (Unix)
Server built:   Dec  9 2009 19:21:30

次にMacPortsでインストールできるApacheバージョンの確認

$ port search apache
・・・
apache @1.3.41 (www)
    The extremely popular Apache http server
・・・
apache2 @2.2.16 (www)
    The extremely popular second version of the Apache http server

apache20 @2.0.63 (www)
    The extremely popular second version of the Apache http server
・・・

最新バージョンのApache2.2.16をインストールしたいので、インストールコマンドは「apache2」を指定します。

それではMacPortsでインストール

$ sudo port install apache2

インストールの最後に表示された自動起動コマンドを叩いておきます。

$ sudo port load apache2

設定ファイルを編集して、ユーザーディレクトリを有効にします。

$ sudo vi /opt/local/apache2/conf/httpd.conf
Password:

# 一番下の方にあります
# User home directories
Include conf/extra/httpd-userdir.conf

自動起動されているかも確認したいのでPCを再起動

バージョン確認

$ /opt/local/apache2/bin/apachectl -v
Server version: Apache/2.2.16 (Unix)
Server built:   Oct 26 2010 15:07:16

プロセス確認

$ ps aux | grep apache2
_www       183   0.0  0.0  2442056    592   ??  S     4:08PM   0:00.00 /opt/local/apache2/bin/httpd -k start
_www        83   0.0  0.0  2442056    592   ??  S     4:08PM   0:00.00 /opt/local/apache2/bin/httpd -k start
_www        82   0.0  0.0  2442056    592   ??  S     4:08PM   0:00.00 /opt/local/apache2/bin/httpd -k start
_www        81   0.0  0.0  2442056    592   ??  S     4:08PM   0:00.00 /opt/local/apache2/bin/httpd -k start
_www        80   0.0  0.0  2442056   1488   ??  S     4:08PM   0:00.00 /opt/local/apache2/bin/httpd -k start
_www        79   0.0  0.0  2442056   1464   ??  S     4:08PM   0:00.00 /opt/local/apache2/bin/httpd -k start
root        74   0.0  0.1  2442056   2436   ??  Ss    4:08PM   0:00.09 /opt/local/apache2/bin/httpd -k start
root        55   0.0  0.0  2446752   1020   ??  Ss    4:07PM   0:00.01 /opt/local/bin/daemondo --label=apache2 --start-cmd /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper start ; --stop-cmd /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper stop ; --restart-cmd /opt/local/etc/LaunchDaemons/org.macports.apache2/apache2.wrapper restart ; --pid=none

最後に表示確認。

「http://localhost/」に接続して『It works!』と表示されることを確認。

「http://localhost/~username/」に接続して『あなたの Web サイト。』と表示されることを確認。

起動・停止コマンド

$ sudo /opt/local/apache2/bin/apachectl start
$ sudo /opt/local/apache2/bin/apachectl stop

MacPortsがインストールできたので、MacPortsを利用して、バージョン管理システム「Subversion」をインストール

まずはデフォルトのsvnバージョンの確認

$ svn --version
svn, version 1.6.5 (r38866)
   compiled Jan 26 2010, 17:43:42

次にMacPortsでインストールできるsvnバージョンの確認

$ port search subversion
・・・
subversion @1.6.13 (devel)
    subversion (svn) -- a version control system designed to be a better cvs
・・・

それではMacPortsでインストール

$ sudo port install subversion

インストール時間:約30分。結構時間がかかりますね。何も入っていない状態だったので関連リソースがかなりインストールされたみたい。

では、改めてsvnバージョンの確認。(確認の前にターミナルを再起動してね!)

$ svn --version
svn, バージョン 1.6.13 (r1002816)
   コンパイル日時: Oct 26 2010, 00:32:52

無事、最新バージョンにかわっていることを確認できました。うれしいことに日本語表示になってますw

前の10件 1  2  3  4  5  6  7  8  9