2012-11-20

CentOS 6.3 最小構成からのスタート
(6)MySQLの起動

インストール直後は、自動起動しない。


# chkconfig 
auditd          0:off 1:off 2:on 3:on 4:on 5:on 6:off
crond           0:off 1:off 2:on 3:on 4:on 5:on 6:off
httpd           0:off 1:off 2:off 3:off 4:off 5:off 6:off
ip6tables       0:off 1:off 2:on 3:on 4:on 5:on 6:off
iptables        0:off 1:off 2:on 3:on 4:on 5:on 6:off
lvm2-monitor    0:off 1:on 2:on 3:on 4:on 5:on 6:off
mysqld          0:off 1:off 2:off 3:off 4:off 5:off 6:off
netconsole      0:off 1:off 2:off 3:off 4:off 5:off 6:off
netfs           0:off 1:off 2:off 3:on 4:on 5:on 6:off
network         0:off 1:off 2:on 3:on 4:on 5:on 6:off
postfix         0:off 1:off 2:on 3:on 4:on 5:on 6:off
rdisc           0:off 1:off 2:off 3:off 4:off 5:off 6:off
restorecond     0:off 1:off 2:off 3:off 4:off 5:off 6:off
rsyslog         0:off 1:off 2:on 3:on 4:on 5:on 6:off
saslauthd       0:off 1:off 2:off 3:off 4:off 5:off 6:off
sshd            0:off 1:off 2:on 3:on 4:on 5:on 6:off
udev-post       0:off 1:on 2:on 3:on 4:on 5:on 6:off
# 


なので、自動起動するようにする。

# chkconfig mysqld on


起動する。

# service mysqld start
MySQL データベースを初期化中:  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:

/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
/usr/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 /usr ; /usr/bin/mysqld_safe &

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

Please report any problems with the /usr/bin/mysqlbug script!

                                                          [  OK  ]
mysqld を起動中:                                           [  OK  ]
# 

と、ここでもMySQL起動の際にメッセージが表示される。
インストール直後は、rootのパスワードが設定されていないので、
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

のどちらかを実行してパスワードを設定する。
もしくは、
/usr/bin/mysql_secure_installation

を実行すれば、
  • rootのパスワード設定
  • anonymousユーザーの削除
  • リモートホストからのrootのログイン拒否
  • testデータベースの削除
をステップ実行で実施できる。

2012-11-19

CentOS 6.3 最小構成からのスタート
(5)apacheの起動

インストール直後は、自動起動しない。


# chkconfig 
auditd          0:off 1:off 2:on 3:on 4:on 5:on 6:off
crond           0:off 1:off 2:on 3:on 4:on 5:on 6:off
httpd           0:off 1:off 2:off 3:off 4:off 5:off 6:off
ip6tables       0:off 1:off 2:on 3:on 4:on 5:on 6:off
iptables        0:off 1:off 2:on 3:on 4:on 5:on 6:off
lvm2-monitor    0:off 1:on 2:on 3:on 4:on 5:on 6:off
mysqld          0:off 1:off 2:off 3:off 4:off 5:off 6:off
netconsole      0:off 1:off 2:off 3:off 4:off 5:off 6:off
netfs           0:off 1:off 2:off 3:on 4:on 5:on 6:off
network         0:off 1:off 2:on 3:on 4:on 5:on 6:off
postfix         0:off 1:off 2:on 3:on 4:on 5:on 6:off
rdisc           0:off 1:off 2:off 3:off 4:off 5:off 6:off
restorecond     0:off 1:off 2:off 3:off 4:off 5:off 6:off
rsyslog         0:off 1:off 2:on 3:on 4:on 5:on 6:off
saslauthd       0:off 1:off 2:off 3:off 4:off 5:off 6:off
sshd            0:off 1:off 2:on 3:on 4:on 5:on 6:off
udev-post       0:off 1:on 2:on 3:on 4:on 5:on 6:off
# 


なので、自動起動するようにする。

# chkconfig httpd on


起動する。

# service httpd start
httpd を起動中: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
                                                           [  OK  ]
# 

と、ここでapache起動の際にエラーが表示されている。
これは、「サーバーのFQDNを決定できなかったので、localhost.localdomain を使うよ」っていう意味。

そう言えば、インストールした後に何もしていない。

ということで、/etc/httpd/conf/httpd.conf の ServerName を環境に合わせて変更。
ServerName hoge.example.dom:80

色々調べると、/etc/hostsへの追記や、/etc/sysconfig/networkのHOSTNAMEとあわせるとかの記述が見つかったが、httpd.confを変更しただけでエラーは出なくなった。

いいんだろうか。

2012-11-18

CentOS 6.3 最小構成からのスタート
(4)LAMPインストール

# yum install httpd php php-mbstring php-mysql mysql-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: ftp.nara.wide.ad.jp
 * extras: ftp.nara.wide.ad.jp
 * updates: ftp.nara.wide.ad.jp
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-15.el6.centos.1 will be installed
--> Processing Dependency: httpd-tools = 2.2.15-15.el6.centos.1 for package: httpd-2.2.15-15.el6.centos.1.x86_64
--> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-15.el6.centos.1.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.2.15-15.el6.centos.1.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-15.el6.centos.1.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-15.el6.centos.1.x86_64
---> Package mysql-server.x86_64 0:5.1.66-1.el6_3 will be installed
--> Processing Dependency: mysql = 5.1.66-1.el6_3 for package: mysql-server-5.1.66-1.el6_3.x86_64
--> Processing Dependency: perl-DBI for package: mysql-server-5.1.66-1.el6_3.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: mysql-server-5.1.66-1.el6_3.x86_64
--> Processing Dependency: perl(vars) for package: mysql-server-5.1.66-1.el6_3.x86_64
--> Processing Dependency: perl(strict) for package: mysql-server-5.1.66-1.el6_3.x86_64
--> Processing Dependency: perl(Sys::Hostname) for package: mysql-server-5.1.66-1.el6_3.x86_64
--> Processing Dependency: perl(POSIX) for package: mysql-server-5.1.66-1.el6_3.x86_64
--> Processing Dependency: perl(Getopt::Long) for package: mysql-server-5.1.66-1.el6_3.x86_64
--> Processing Dependency: perl(File::Temp) for package: mysql-server-5.1.66-1.el6_3.x86_64
--> Processing Dependency: perl(File::Path) for package: mysql-server-5.1.66-1.el6_3.x86_64
--> Processing Dependency: perl(File::Copy) for package: mysql-server-5.1.66-1.el6_3.x86_64
--> Processing Dependency: perl(File::Basename) for package: mysql-server-5.1.66-1.el6_3.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: mysql-server-5.1.66-1.el6_3.x86_64
--> Processing Dependency: perl(DBI) for package: mysql-server-5.1.66-1.el6_3.x86_64
--> Processing Dependency: /usr/bin/perl for package: mysql-server-5.1.66-1.el6_3.x86_64
---> Package php.x86_64 0:5.3.3-14.el6_3 will be installed
--> Processing Dependency: php-common = 5.3.3-14.el6_3 for package: php-5.3.3-14.el6_3.x86_64
--> Processing Dependency: php-cli = 5.3.3-14.el6_3 for package: php-5.3.3-14.el6_3.x86_64
---> Package php-mbstring.x86_64 0:5.3.3-14.el6_3 will be installed
---> Package php-mysql.x86_64 0:5.3.3-14.el6_3 will be installed
--> Processing Dependency: php-pdo for package: php-mysql-5.3.3-14.el6_3.x86_64
--> Running transaction check
---> Package apr.x86_64 0:1.3.9-5.el6_2 will be installed
---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be installed
---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed
---> Package httpd-tools.x86_64 0:2.2.15-15.el6.centos.1 will be installed
---> Package mailcap.noarch 0:2.1.31-2.el6 will be installed
---> Package mysql.x86_64 0:5.1.66-1.el6_3 will be installed
--> Processing Dependency: mysql-libs = 5.1.66-1.el6_3 for package: mysql-5.1.66-1.el6_3.x86_64
---> Package perl.x86_64 4:5.10.1-127.el6 will be installed
--> Processing Dependency: perl-libs = 4:5.10.1-127.el6 for package: 4:perl-5.10.1-127.el6.x86_64
--> Processing Dependency: perl-libs for package: 4:perl-5.10.1-127.el6.x86_64
--> Processing Dependency: perl(version) for package: 4:perl-5.10.1-127.el6.x86_64
--> Processing Dependency: perl(Pod::Simple) for package: 4:perl-5.10.1-127.el6.x86_64
--> Processing Dependency: perl(Module::Pluggable) for package: 4:perl-5.10.1-127.el6.x86_64
--> Processing Dependency: libperl.so()(64bit) for package: 4:perl-5.10.1-127.el6.x86_64
---> Package perl-DBD-MySQL.x86_64 0:4.013-3.el6 will be installed
---> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed
---> Package php-cli.x86_64 0:5.3.3-14.el6_3 will be installed
--> Processing Dependency: libedit.so.0()(64bit) for package: php-cli-5.3.3-14.el6_3.x86_64
---> Package php-common.x86_64 0:5.3.3-14.el6_3 will be installed
---> Package php-pdo.x86_64 0:5.3.3-14.el6_3 will be installed
--> Running transaction check
---> Package libedit.x86_64 0:2.11-4.20080712cvs.1.el6 will be installed
---> Package mysql-libs.x86_64 0:5.1.61-4.el6 will be updated
---> Package mysql-libs.x86_64 0:5.1.66-1.el6_3 will be an update
---> Package perl-Module-Pluggable.x86_64 1:3.90-127.el6 will be installed
---> Package perl-Pod-Simple.x86_64 1:3.13-127.el6 will be installed
--> Processing Dependency: perl(Pod::Escapes) >= 1.04 for package: 1:perl-Pod-Simple-3.13-127.el6.x86_64
---> Package perl-libs.x86_64 4:5.10.1-127.el6 will be installed
---> Package perl-version.x86_64 3:0.77-127.el6 will be installed
--> Running transaction check
---> Package perl-Pod-Escapes.x86_64 1:1.04-127.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package                 Arch     Version                       Repository
                                                                           Size
================================================================================
Installing:
 httpd                   x86_64   2.2.15-15.el6.centos.1        base      813 k
 mysql-server            x86_64   5.1.66-1.el6_3                updates   8.6 M
 php                     x86_64   5.3.3-14.el6_3                updates   1.1 M
 php-mbstring            x86_64   5.3.3-14.el6_3                updates   453 k
 php-mysql               x86_64   5.3.3-14.el6_3                updates    79 k
Installing for dependencies:
 apr                     x86_64   1.3.9-5.el6_2                 updates   123 k
 apr-util                x86_64   1.3.9-3.el6_0.1               base       87 k
 apr-util-ldap           x86_64   1.3.9-3.el6_0.1               base       15 k
 httpd-tools             x86_64   2.2.15-15.el6.centos.1        base       70 k
 libedit                 x86_64   2.11-4.20080712cvs.1.el6      base       74 k
 mailcap                 noarch   2.1.31-2.el6                  base       27 k
 mysql                   x86_64   5.1.66-1.el6_3                updates   885 k
 perl                    x86_64   4:5.10.1-127.el6              base       10 M
 perl-DBD-MySQL          x86_64   4.013-3.el6                   base      134 k
 perl-DBI                x86_64   1.609-4.el6                   base      705 k
 perl-Module-Pluggable   x86_64   1:3.90-127.el6                base       38 k
 perl-Pod-Escapes        x86_64   1:1.04-127.el6                base       30 k
 perl-Pod-Simple         x86_64   1:3.13-127.el6                base      210 k
 perl-libs               x86_64   4:5.10.1-127.el6              base      576 k
 perl-version            x86_64   3:0.77-127.el6                base       49 k
 php-cli                 x86_64   5.3.3-14.el6_3                updates   2.2 M
 php-common              x86_64   5.3.3-14.el6_3                updates   523 k
 php-pdo                 x86_64   5.3.3-14.el6_3                updates    73 k
Updating for dependencies:
 mysql-libs              x86_64   5.1.66-1.el6_3                updates   1.2 M

Transaction Summary
================================================================================
Install      23 Package(s)
Upgrade       1 Package(s)

Total download size: 28 M
Downloading Packages:
--------------------------------------------------------------------------------
Total                                           1.4 MB/s |  28 MB     00:20     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction

  Installing : php-common-5.3.3-14.el6_3.x86_64                            1/25 

  Updating   : mysql-libs-5.1.66-1.el6_3.x86_64                            2/25 

  Installing : apr-1.3.9-5.el6_2.x86_64                                    3/25 

  Installing : apr-util-1.3.9-3.el6_0.1.x86_64                             4/25 

  Installing : httpd-tools-2.2.15-15.el6.centos.1.x86_64                   5/25 

  Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                        6/25 

  Installing : php-pdo-5.3.3-14.el6_3.x86_64                               7/25 

  Installing : 1:perl-Pod-Escapes-1.04-127.el6.x86_64                      8/25 

  Installing : 3:perl-version-0.77-127.el6.x86_64                          9/25 

  Installing : 1:perl-Pod-Simple-3.13-127.el6.x86_64                      10/25 

  Installing : 1:perl-Module-Pluggable-3.90-127.el6.x86_64                11/25 

  Installing : 4:perl-libs-5.10.1-127.el6.x86_64                          12/25 

  Installing : 4:perl-5.10.1-127.el6.x86_64                               13/25 

  Installing : perl-DBI-1.609-4.el6.x86_64                                14/25 

  Installing : perl-DBD-MySQL-4.013-3.el6.x86_64                          15/25 

  Installing : mysql-5.1.66-1.el6_3.x86_64                                16/25 

  Installing : libedit-2.11-4.20080712cvs.1.el6.x86_64                    17/25 

  Installing : php-cli-5.3.3-14.el6_3.x86_64                              18/25 

  Installing : mailcap-2.1.31-2.el6.noarch                                19/25 

  Installing : httpd-2.2.15-15.el6.centos.1.x86_64                        20/25 

  Installing : php-5.3.3-14.el6_3.x86_64                                  21/25 

  Installing : mysql-server-5.1.66-1.el6_3.x86_64                         22/25 

  Installing : php-mysql-5.3.3-14.el6_3.x86_64                            23/25 

  Installing : php-mbstring-5.3.3-14.el6_3.x86_64                         24/25 

  Cleanup    : mysql-libs-5.1.61-4.el6.x86_64                             25/25 

  Verifying  : php-common-5.3.3-14.el6_3.x86_64                            1/25 

  Verifying  : perl-DBD-MySQL-4.013-3.el6.x86_64                           2/25 

  Verifying  : httpd-2.2.15-15.el6.centos.1.x86_64                         3/25 

  Verifying  : 4:perl-libs-5.10.1-127.el6.x86_64                           4/25 

  Verifying  : perl-DBI-1.609-4.el6.x86_64                                 5/25 

  Verifying  : 1:perl-Pod-Simple-3.13-127.el6.x86_64                       6/25 

  Verifying  : httpd-tools-2.2.15-15.el6.centos.1.x86_64                   7/25 

  Verifying  : 3:perl-version-0.77-127.el6.x86_64                          8/25 

  Verifying  : php-cli-5.3.3-14.el6_3.x86_64                               9/25 

  Verifying  : php-mbstring-5.3.3-14.el6_3.x86_64                         10/25 

  Verifying  : mysql-libs-5.1.66-1.el6_3.x86_64                           11/25 

  Verifying  : 1:perl-Pod-Escapes-1.04-127.el6.x86_64                     12/25 

  Verifying  : php-5.3.3-14.el6_3.x86_64                                  13/25 

  Verifying  : php-pdo-5.3.3-14.el6_3.x86_64                              14/25 

  Verifying  : 1:perl-Module-Pluggable-3.90-127.el6.x86_64                15/25 

  Verifying  : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                       16/25 

  Verifying  : mysql-server-5.1.66-1.el6_3.x86_64                         17/25 

  Verifying  : mailcap-2.1.31-2.el6.noarch                                18/25 

  Verifying  : apr-1.3.9-5.el6_2.x86_64                                   19/25 

  Verifying  : libedit-2.11-4.20080712cvs.1.el6.x86_64                    20/25 

  Verifying  : php-mysql-5.3.3-14.el6_3.x86_64                            21/25 

  Verifying  : mysql-5.1.66-1.el6_3.x86_64                                22/25 

  Verifying  : 4:perl-5.10.1-127.el6.x86_64                               23/25 

  Verifying  : apr-util-1.3.9-3.el6_0.1.x86_64                            24/25 

  Verifying  : mysql-libs-5.1.61-4.el6.x86_64                             25/25 

Installed:
  httpd.x86_64 0:2.2.15-15.el6.centos.1   mysql-server.x86_64 0:5.1.66-1.el6_3  
  php.x86_64 0:5.3.3-14.el6_3             php-mbstring.x86_64 0:5.3.3-14.el6_3  
  php-mysql.x86_64 0:5.3.3-14.el6_3      

Dependency Installed:
  apr.x86_64 0:1.3.9-5.el6_2                                                    
  apr-util.x86_64 0:1.3.9-3.el6_0.1                                             
  apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1                                        
  httpd-tools.x86_64 0:2.2.15-15.el6.centos.1                                   
  libedit.x86_64 0:2.11-4.20080712cvs.1.el6                                     
  mailcap.noarch 0:2.1.31-2.el6                                                 
  mysql.x86_64 0:5.1.66-1.el6_3                                                 
  perl.x86_64 4:5.10.1-127.el6                                                  
  perl-DBD-MySQL.x86_64 0:4.013-3.el6                                           
  perl-DBI.x86_64 0:1.609-4.el6                                                 
  perl-Module-Pluggable.x86_64 1:3.90-127.el6                                   
  perl-Pod-Escapes.x86_64 1:1.04-127.el6                                        
  perl-Pod-Simple.x86_64 1:3.13-127.el6                                         
  perl-libs.x86_64 4:5.10.1-127.el6                                             
  perl-version.x86_64 3:0.77-127.el6                                            
  php-cli.x86_64 0:5.3.3-14.el6_3                                               
  php-common.x86_64 0:5.3.3-14.el6_3                                            
  php-pdo.x86_64 0:5.3.3-14.el6_3                                               

Dependency Updated:
  mysql-libs.x86_64 0:5.1.66-1.el6_3                                            

Complete!
#


CentOS 6.x では、PHPは5.3になっている。

2012-11-12

htmlspecialchars()とhtmlentities()の第4引数はfalseで

文字エンコーディングに UTF-8 を使っているときは気にしなかったが、
EUC-JP や Shift_JIS を使わなければならなかったとき、ハマッた。

EUC-JP や Shift_JIS (両方とも、Windows標準キャラクタセットが扱える CP51932、SJIS-win を含む)の場合、これらの文字セットに存在しない



などをPOSTすると、数値文字参照形式でPOSTされる。
なので、POSTされた値を htmlspecialchars() や htmlentities() を通して

echo htmlspecialchars(POST値, ENT_QUOTES, 文字エンコーディング);

echo htmlentities(POST値, ENT_QUOTES, 文字エンコーディング);

とすると、数値文字参照の「&」が「&」に変換され、数値文字参照の値がそのまま表示される。

これは、両関数の第4引数「double_encode」のデフォルトが「true」のため。

■PHPマニュアル htmlspecialchars()
http://www.php.net/manual/ja/function.htmlspecialchars.php

■PHPマニュアル htmlentities()
http://www.php.net/manual/ja/function.htmlentities.php



回避策は、この第4引数「double_encode」を「false」にしてやればいい。


こんな感じ。


echo htmlspecialchars(POST値, ENT_QUOTES, 文字エンコーディング, false);

echo htmlentities(POST値, ENT_QUOTES, 文字エンコーディング, false);

2012-11-07

ただのメモ兼ブックマーク

PHP型の比較表
http://www.php.net/manual/ja/types.comparisons.php


MySQLのNULLは、
・is_null() で true。
・ == '' で true。


phpMyAdminでtext型フィールドの値を表示する
http://www.zelazny.mydns.jp/archives/002723.php


InsertしたレコードのAUTO_INCREMENT値を取得する
http://blog.tofu-kun.org/071206185929.php


CentOS6.2 へ OpenVZ を入れる
http://www.mogumagu.com/wp/wordpress/?p=729


iPhone4 のデフォルト文字数など
横幅:ひらがな19文字
縦幅:14行


htmlspecialchars(),htmlentities()の第3引数は、IANAに登録されているMIME名を使う
UTF-8
Shift_JIS
EUC-JP


PHPでシングルトン
http://d.hatena.ne.jp/Yudoufu/20090811/1250021010


topコマンドで表示される値の意味
http://www.uetyi.mydns.jp/wordpress/command/entry-124.html


topコマンドで表示されるVIRTの意味
http://okwave.jp/qa/q5812588.html


findで検索していろいろ
http://uguisu.skr.jp/Windows/find_xargs.html


OpenSSLの脆弱性
・libcrypto
・libssl 2014/4と2014/6の脆弱性はこっちのライブラリ


Chatの「メッセージは投稿者によって削除されました」を非表示にする方法

Chrome拡張機能を自作してやってみよう! ♪できるかな できるかな ・・・ 無理ぽ (´・ω・`) iframeの中に、実際のメッセージのやり取りが表示されるので、 $(function(){ $('iframe[name^="spa...