開発メモ,主に補足by子連れ親父プログラマー

ラベル port の投稿を表示しています。 すべての投稿を表示
ラベル port の投稿を表示しています。 すべての投稿を表示

2012-08-19

OS X Mountaion Lion で MacPorts を使って開発環境を整える(postgres編)


OS X Mountaion Lion で MacPorts を使って開発環境を整える(postgres編)


まずは、

$ sudo port install postgresql90

とすると終わり際に、

To use the postgresql server, install the postgresql90-server port

と出るので、引き続き、

$ sudo port install postgresql90-server

を実行。終わり際に、

###########################################################
# A startup item has been generated that will aid in
# starting postgresql90-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 postgresql90-server
###########################################################

と、

To create a database instance, after install do
 sudo mkdir -p /opt/local/var/db/postgresql90/defaultdb
 sudo chown postgres:postgres /opt/local/var/db/postgresql90/defaultdb
 sudo su postgres -c '/opt/local/lib/postgresql90/bin/initdb -D /opt/local/var/db/postgresql90/defaultdb'

To tweak your DBMS, consider increasing kern.sysv.shmmax by adding an increased kern.sysv.shmmax .. to /etc/sysctl.conf

が出る。
順番にやっていく。

$ sudo port load postgresql90-server
$ sudo mkdir -p /opt/local/var/db/postgresql90/defaultdb
$ sudo chown postgres:postgres /opt/local/var/db/postgresql90/defaultdb
$ sudo su postgres -c '/opt/local/lib/postgresql90/bin/initdb -D /opt/local/var/db/postgresql90/defaultdb'

ここで、だーっと出る。

The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale ja_JP.UTF-8.
The default database encoding has accordingly been set to UTF8.
initdb: could not find suitable text search configuration for locale ja_JP.UTF-8
The default text search configuration will be set to "simple".

fixing permissions on existing directory /opt/local/var/db/postgresql90/defaultdb ... ok
creating subdirectories ... ok
selecting default max_connections ... 20
selecting default shared_buffers ... 2400kB
creating configuration files ... ok
creating template1 database in /opt/local/var/db/postgresql90/defaultdb/base/1 ... ok
initializing pg_authid ... ok
initializing dependencies ... ok
creating system views ... ok
loading system objects' descriptions ... ok
creating conversions ... ok
creating dictionaries ... ok
setting privileges on built-in objects ... ok
creating information schema ... ok
loading PL/pgSQL server-side language ... ok
vacuuming database template1 ... ok
copying template1 to template0 ... ok
copying template1 to postgres ... ok

WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the -A option the
next time you run initdb.

Success. You can now start the database server using:

    /opt/local/lib/postgresql90/bin/postgres -D /opt/local/var/db/postgresql90/defaultdb
or
    /opt/local/lib/postgresql90/bin/pg_ctl -D /opt/local/var/db/postgresql90/defaultdb -l logfile start

最後のやつをやってみる。

$ /opt/local/lib/postgresql90/bin/postgres -D /opt/local/var/db/postgresql90/defaultdb

エラーになる。

postgres cannot access the server configuration file "/opt/local/var/db/postgresql90/defaultdb/postgresql.conf": Permission denied

パーミッションの問題か。
sudo su postgres して再トライ。

$ sudo su postgres
$ /opt/local/lib/postgresql90/bin/postgres -D /opt/local/var/db/postgresql90/defaultdb
LOG:  database system was shut down at 2012-08-11 04:10:00 JST
LOG:  autovacuum launcher started
LOG:  database system is ready to accept connections

動いたっぽい。

$ /opt/local/lib/postgresql90/bin/psql -l -U postgres                              List of databases
   Name    |  Owner   | Encoding | Collation | Ctype |   Access privileges  
-----------+----------+----------+-----------+-------+-----------------------
 postgres  | postgres | UTF8     | C         | C     |
 template0 | postgres | UTF8     | C         | C     | =c/postgres          +
           |          |          |           |       | postgres=CTc/postgres
 template1 | postgres | UTF8     | C         | C     | =c/postgres          +
           |          |          |           |       | postgres=CTc/postgres
(3 rows)

よさそうだ。
パスを通しておく。

$ vim .profile

export PATH=/opt/local/lib/postgresql90/bin:$PATH

テスト用DBを作っておく。

$ createdb sample_db -U postgres -E UTF-8

psqlして、

$ psql sample_db -U postgres

テーブルを作る。

sample_db=# CREATE TABLE users (
sample_db(# id SERIAL PRIMARY KEY,
sample_db(# name varchar(255)
sample_db(# );
NOTICE:  CREATE TABLE will create implicit sequence "users_id_seq" for serial column "users.id"
NOTICE:  CREATE TABLE / PRIMARY KEY will create implicit index "users_pkey" for table "users"
CREATE TABLE

確認。

sample_db=# \d
              List of relations
 Schema |     Name     |   Type   |  Owner  
--------+--------------+----------+----------
 public | users        | table    | postgres
 public | users_id_seq | sequence | postgres
(2 rows)

sample_db=# \d users
                                 Table "public.users"
 Column |          Type          |                     Modifiers                     
--------+------------------------+----------------------------------------------------
 id     | integer                | not null default nextval('users_id_seq'::regclass)
 name   | character varying(255) |
Indexes:
    "users_pkey" PRIMARY KEY, btree (id)

データを入れておく。

sample_db=# INSERT INTO users (name) VALUES ('yamada');
INSERT 0 1

セレクトして確認。

sample_db=# select * from users;
 id |  name 
----+--------
  1 | yamada
(1 row)

再びportでインストール

$ sudo port install php5-postgresql

アパッチ再起動

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

infophp()で確認。

簡単なphpを書いて接続テスト。

<?php
$conn = pg_pconnect("dbname=sample_db user=postgres");
if (!$conn) {
  echo "An error occured.\n";
  exit;
}

$result = pg_query($conn, "SELECT * FROM users");
if (!$result) {
  echo "An error occured.\n";
  exit;
}

while ($row = pg_fetch_row($result)) {
  echo "Id: $row[0]  Name: $row[1]";
  echo "<br />\n";
}

表示される。

Id: 1 Name: yamada

よさそうだ。

2012-08-17

OS X Mountaion Lion で MacPorts を使って開発環境を整える(MySQL編)

OS X Mountaion Lion で MacPorts を使って開発環境を整える(MySQL編)


引き続きMySQLのインストールへ。
まずは、

$ 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
###########################################################

こんなメッセージが出る。

If this is a new install, in order to setup the database you might want to run:
sudo -u _mysql mysql_install_db5

悩ましいね。
とりあえず、

$ 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 bohr.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!

だーっと何か出た。
さっぱりわからんのでとりあえず、

$ /opt/local/lib/mysql5/bin/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):
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/opt/local/var/run/mysql5/mysqld.sock' (2)

現在のrootのパスワードをいれろってメッセージが出るが設定してないじゃん。
設定してないから何もいれなくてもいいのか?
が、空でenterしても反応なし。
これは何かオカシイ。
なんか間違ってる。
ということでmac本体を再起動だ!
・・・・・
で、もう一回ここから。

$ /opt/local/lib/mysql5/bin/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):
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
Enter current password for root (enter for none):
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:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!

引き続きrootのパスワード設定になったので、2回入れる。
成功!

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!

Cleaning up...



All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

あとは、なんじゃようわからんが全部yesで完了!
いやあ、こんな設定初めてやったかも。

$ /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 10
Server version: 5.1.63 Source distribution

Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

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

mysql>

オッケーだ。
パスが通っていないので、

$ vim ~/.profile

して、

export PATH=/opt/local/lib/mysql5/bin:$PATH

を追加。

次へ。

$ sudo port install php5-mysql

終わり際に、以下のメッセージが出るので、

To use mysqlnd with a local MySQL server, edit /opt/local/etc/php5/php.ini and set
mysql.default_socket, mysqli.default_socket and pdo_mysql.default_socket
to /opt/local/var/run/mysql5/mysqld.sock

php.ini を編集する。

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

で、default_socket の空になっている = に書きこむ。
PDO。

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
; http://php.net/pdo_mysql.default-socket
pdo_mysql.default_socket = /opt/local/var/run/mysql5/mysqld.sock

mysql。

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
; http://php.net/mysql.default-socket
mysql.default_socket = /opt/local/var/run/mysql5/mysqld.sock

mysqli。

; Default socket name for local MySQL connects.  If empty, uses the built-in
; MySQL defaults.
; http://php.net/mysqli.default-socket
mysqli.default_socket = /opt/local/var/run/mysql5/mysqld.sock

アパッチ再起動。

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

infophp()でmysqlが入ってることを確認。
テスト用データベースを作成する。

mysql> CREATE DATABASE sample_db DEFAULT CHARACTER SET utf8;
Query OK, 1 row affected (0.00 sec)

ユーザー権限を設定。

mysql> GRANT ALL ON sample_db.* TO sample_user@localhost IDENTIFIED BY 'password';
Query OK, 0 rows affected (0.00 sec)

データベースを指定して、

mysql> use sample_db
Database changed

テーブルを作成。

mysql> CREATE TABLE users (
    -> id INT AUTO_INCREMENT,
    -> name varchar(255),
    -> PRIMARY KEY  (id)
    -> );
Query OK, 0 rows affected (0.04 sec)

テーブルを確認。

mysql> show tables;
+---------------------+
| Tables_in_sample_db |
+---------------------+
| users               |
+---------------------+
1 row in set (0.00 sec)

一個データをインサート。

mysql> INSERT INTO users (name) VALUES ('yamada');
Query OK, 1 row affected (0.00 sec)

セレクトして確認。

mysql> select * from users;
+----+--------+
| id | name   |
+----+--------+
|  1 | yamada |
+----+--------+
1 row in set (0.00 sec)

DBに接続してセレクトする簡単なphpを書く。
php.netからそのまま。

<?php
$link = mysqli_connect('localhost', 'sample_user', 'password', 'sample_db');
if (!$link) {
    die('Connect Error (' . mysqli_connect_errno() . ') '
            . mysqli_connect_error());
}
echo 'Success... ' . mysqli_get_host_info($link) . "\n";

if ($result = mysqli_query($link, "SELECT name FROM users")) {
    printf("Select returned %d rows.\n", mysqli_num_rows($result));

    /* 結果セットを開放します */
    mysqli_free_result($result);
}

mysqli_close($link);

画面に表示される。

Success... Localhost via UNIX socket Select returned 1 rows.

よさそうだ。


2012-08-10

OS X Mountaion Lion で MacPorts を使って開発環境を整える(apache, PHP編)

OS X Mountaion Lion で MacPorts を使って開発環境を整える(apache, PHP編)


という訳で無事 Mountaion Lion のクリーンインストールも完了し、開発環境を再構築しようってことで四苦八苦。
まずはMacPortsのこのページ


http://www.macports.org/install.php


から Mountaion Lion のリンクをクリックしてダウンロード。
MacPorts をインストール。
それから Apple の開発者ページ


https://developer.apple.com/downloads/index.action


へ行って Command Line Tools (OS X Mountain Lion) for Xcode をダウンロードしてインストール。
(実際にはここでログインが必要で、なんだっけな、iCloudのアカウントで入ってメールアドレスのVerifyがあって、そんでやっとダウンロードできる)


そんで、まずはアパッチ。


$ sudo port install apache2

終わり際に


###########################################################
# 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
###########################################################

とかって出るので、以下を実行。


$ sudo port load apache2
$ port installed

として確認してみると、アパッチと一緒に


openssl @1.0.1c_0 (active)
 perl5 @5.12.4_0+perl5_12 (active)
 perl5.12 @5.12.4_1 (active)
 sqlite3 @3.7.13_0 (active)

この辺もインストールされているのが分かる。
で、次はphp。


$ 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.

と表示されるので、


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

とする。

ついでにphp.iniを編集して、


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

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = Asia/Tokyo 

とタイムゾーンの設定を入れておく。
引き続き、apacheのhttpd.conf を編集。


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

として、


# Virtual hosts
Include conf/extra/httpd-vhosts.conf

この部分のコメントアウトを外す。
さらに、


AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz

となっているあたりに以下を追加。


AddType application/x-httpd-php .php

引き続き


$ sudo vim /opt/local/apache2/conf/extra/httpd-vhosts.conf

を編集。下の方を全部消して、以下のように変更


<VirtualHost *:80>
   DocumentRoot "/opt/local/apache2/htdocs"
   ServerName localhost
 </VirtualHost>
          
 <VirtualHost *:80>
     DocumentRoot "/Users/xxxx/htdocs"
     ServerName vhost
     <Directory "/Users/xxxx/htdocs">
       order deny,allow
       allow from All
       Options All
       AllowOverride All
     </Directory>
</VirtualHost>

自分のユーザーフォルダーの直下にhtdocsを作っておく。


$ mkdir /Users/xxxx/htdocs

その中に、適当な index.html を入れておく。
ついでに


<?php
phpinfo();

とだけ書いてあるinfo.phpファイルを作って入れておく。

あと、


$ sudo vim /private/etc/hosts

として


127.0.0.1   vhost

を追加。


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

でアパッチ再起動。ブラウザで見てみる。


http://vhost/
http://vhost/info.php

OKなら mbstring とかも入れる。


$ sudo port install php5-mbstring
$ sudo /opt/local/apache2/bin/apachectl restart

とかやって。phpinfo() でちゃんと反映されているか確認する。
ここまでで一週間くらいかかった。(笑)
先は長いって。



2011-11-20

OSX Lion に Tomcat6 を入れて Java のサーブレットで HelloWorld するまでのすったもんだ

OSX Lion に Tomcat6 を入れて Java のサーブレットで HelloWorld するまでのすったもんだ

そういえばLionにしてから自宅の開発環境がほったらかしになってたな、と、嫌な予感はしていたんだが、いざ始めてみると大仕事に。 Java の SDK は入ってるはずだから Tomcat だけ入れればいいはず、と思って、

sudo port install tomcat6

と打った最初っからつまづいた。 まず MacPorts そのものがバージョン2.0.3にアップしていてこの selfupdate ができない。 Xcode を4.1にバージョンアップしろ、と言われる。 でApp Store で Xcode を検索してインストール。 App Store の画面でインストール済みになって、それからどうすればいいのか分からず、途中作業中断もはさんで大幅に時間ロス。 ふと見ると Application の中に Install Xcode というアイコンができているのでそれを起動で無事完了。 MacPorts のバージョンアップをして、引き続き Tomcat を入れる。

http://localhost:8080

を開いてみると得体の知れない EnterpriseDB とかいう画面が開くだけなので、(←なんすかね、これ)

sudo vim /opt/local/share/java/tomcat6/conf/server.xml

として、8080になってるところを8090に変更。 さらに、

sudo vim /opt/local/share/java/tomcat6/conf/tomcat-users.xml

として、Tomcat のアプリケーションマネージャ画面に入るためのIDとパスワードを設定する。

<tomcat-users>
    <role rolename="manager-gui"/>
    <user username="myname" password="mypassword" roles="manager-gui"/>
</tomcat-users>

HelloWorld 用のjava ファイルを用意して、

javac HelloWorld.java 

とするも文字化け。

vim ~/.profile

として、末尾に

alias javac="javac -J-Dfile.encoding=UTF8"
alias java="java -Dfile.encoding=UTF8"

を追加。文字化けは収まったが、コンパイルに失敗するので、 さらに .profile に

export CLASSPATH=/opt/local/share/java/tomcat6/lib/servlet-api.jar

を追加。

javac HelloWorld.java 

とやって、HelloWorld.class を作成する。

/opt/local/share/java/tomcat6/webapps

以下に、

/opt/local/share/java/tomcat6/webapps/sample

というフォルダーを作り、さらにその中に、

/opt/local/share/java/tomcat6/webapps/sample/WEB-INF
/opt/local/share/java/tomcat6/webapps/sample/WEB-INF/classes
/opt/local/share/java/tomcat6/webapps/sample/WEB-INF/src
/opt/local/share/java/tomcat6/webapps/sample/WEB-INF/lib

とフォルダーを作って、 classes の中に HelloWorld.class を、src の中に HelloWorld.java を、 WEB-INF 直下に web.xml を置いて、

http://localhost:8090/sample/Hello

で完成。

2011-09-03

OSX で MacPorts を使って、CoffeeScript を試してみる

WEB+DB PRESS Vol.64 の記事で面白そうだったので早速試してみた。
記事では CoffeeScript のコンパイラをインストールするのに、まず Node.js と npm が必要とあり、
その Node.js のインストールには nvm を使ってみる、とあるが、面倒なので port でやってみる。
$ port search node*
とすると、以下の4つが見つかるので、
nodejs @0.4.11 (devel, net)
    Evented I/O for V8 JavaScript

nodejs-devel @0.5.4 (devel, net)
    Evented I/O for V8 JavaScript

nodejuice @1.5.0 (www)
    A web development tool to autorefesh the browser on changes.

npm @1.0.26 (devel)
    node package manager

Found 4 ports.
$ sudo port install nodejs
$ sudo port install npm
でよさそうだ。
が、
$ port search coffee*
とすると、
coffee-script @1.1.2 (lang)
    a language that compiles into JavaScript
こう出るので、もしかすると
$ sudo port install coffee-script
だけでもよかったのかもしれない。いずれにしろ、これで
$ coffee -v
CoffeeScript version 1.1.2
というように入ったので、記事の通りに
hello = ->
  console.log "Hello, World!"

hello()
を hello.coffee として保存し、

コンパイル。
$ coffee -c hello.coffee 
Node.js から実行。
$ node hello.js
Hello, World!
CoffeeScript から直接実行。
$ coffee hello.coffee 
Hello, World!
生成された js ファイルは、
(function() {
  var hello;
  hello = function() {
    return console.log("Hello, World!");
  };
  hello();
}).call(this);
となっている。
うまくいったようだ。
WEB+DB PRESS Vol.64

2011-01-25

OSXのMacPortsでphpのバージョンが5.3.5になり、なにもかもおかしくなった件

前の記事を見たら2010/3/18ってなってたからおよそ一年近くほったらかしになっていたことになるが。
1年前に自宅のOSXの環境にMacPortsでphpを入れて、その時は5.3.2だったんだが、
それで昨日そいつを更新しようと思い立ち、
sudo port upgrade installed
とやったが最後、とんでもなく延々と待たされた挙げ句に
 php5 @5.3.2_0+apache2+macosx+mysql5+pear+sockets+sqlite
 php5 @5.3.5_0+apache2 (active)
と2つのphp5が存在している状態になり、もう訳が分からない(涙)。
なんなんすか、これ。
phpのバージョンを5.3.2から5.3.5にするんだったら、
 php5 @5.3.5_0+apache2+macosx+mysql5+pear+sockets+sqlite
こうなるのが普通じゃないか?!
おかしい、これは絶対おかしい。
ということで
sudo port uninstall -f php5 @5.3.5_0+apache2
とやって消してみた。
消してからふと、そういえばmbstringが使えなかったような気がしたナーと思ったので
ついうっかり、
sudo port install php5-mbstring
とやってしまった。すると、
 php5 @5.3.2_0+apache2+macosx+mysql5+pear+sockets+sqlite
 php5 @5.3.5_0+apache2 (active)
げげーっつまたしても5.3.5が復活している!!
さすがにここまでやって気がついた。
恐らくこれは5.3.2と5.3.5とでは、もう、違うってことだ。
これからはもう絶対に
php5 @5.3.5_0+apache2+macosx+mysql5+pear+sockets+sqlite
こういう風にはならないってことだ。
結果、
php5 @5.3.5_0+apache2 (active)
php5-mbstring @5.3.5_0 (active)
php5-mysql @5.3.5_0+mysqlnd (active)
こういう風になる。
ついでに泣けるのがこのmbstring入れる時に出るメッセージ
Your php.ini contains a line that will prevent php5-mbstring
and other PHP extensions from working. To fix this,
edit /opt/local/etc/php5/php.ini and delete this line:

extension_dir = "./"
この行を消せってのは
extension_dir = "./"
のことを指している(笑)。

2010-03-18

MacPortsでOSXにphp5.3を入れる

OSXに、php5.3を入れようということで、
port installed
で見たところ、apache2とかはもうインストール済みになってるみたいだったので、もう一回以下のコマンドでphpのインストールに挑戦。
sudo port -d install php5 +apache2 +macox +mysql5 +pear +postgres +sockets +sqlite
最後に出た以下のメッセージを完全に見逃す
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
こうして入れたシステム一式は、OSXの
/opt/local
の下に入るようです。
PHPのバージョン5.3.2になっている。
$ php -v
PHP 5.3.2 (cli) (built: Mar 18 2010 03:49:53) 
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
pearも入っている。
$ pear -V
PEAR Version: 1.9.0
PHP Version: 5.3.2
Zend Engine Version: 2.3.0
でアパッチを起動したいということで、
sudo launchctl load -w /Library/LaunchDaemons/org.macports.apache2.plist 
とりあえずこうするだけでapache動いた。
が、phpが動いていない。 そこで、以下を実行。
sudo cp php.ini-development php.ini
sudo /opt/local/apache2/bin/apxs -a -e -n "php5" libphp5.so
アパッチのhttpd.confに
以下を追加。
Include conf/extra/mod_php.conf
以下を付け足し。

    DirectoryIndex index.html index.php

で、
sudo /opt/local/apache2/bin/apachectl restart
したら、phpもオッケーに。
なったがな、しかし。だな。

このブログを検索

Powered by Blogger.

ラベル

php (17) jQuery (13) OSX (10) MySQL (8) Javascript (7) Postgres (7) port (7) apache (6) Java (3) Smarty (2) html (2) pear (2) FCKEditor (1) XAMPP (1) css (1) git (1) perl (1) ruby (1)

Facebookバナー