2011-03-21(Mon)
CentOS5.3にPHP5.2.16をインストールする
ご存知PHP。
PHP: Hypertext Preprocessor - Wikipedia
公式リポジトリからyumでインストールした後、
非公式リポジトリでupdateするところまでです。
対象
- CentOS5.3
- PHP5.1.6 → 5.2.16
今回はこちらの記事を参考にさせて頂きました。
あざます><
すでにインストールされてないか確認
phpがすでに入ってないか確認します。
yum list installed | grep php
ないので、インストール開始。
yum -y install php php-mbstring php-mcrypt
おしまい。
そのままPHPのバージョンも上げたいのですが
CentOSの公式リポジトリは対応があまり早くない、、との事で
非公式リポジトリを利用して、バージョンを
5.1.6 → 5.2.16
へアップデートします。
利用させて頂くはここ。 Utter Ramblings
RPM-GPG-KEY取得
まずはキー(RPM-GPG-KEY)を取得。
rpm --import http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
/etc/yum.repos.d/utterramblings.repoを新規作成して、
vi /etc/yum.repos.d/utterramblings.repo
以下のリポジトリ参照設定を記述。
[utterramblings] name=Jason's Utter Ramblings Repo baseurl=http://www.jasonlitka.com/media/EL$releasever/$basearch/ enabled=1 gpgcheck=1 gpgkey=http://www.jasonlitka.com/media/RPM-GPG-KEY-jlitka
PHPのアップデート
そしてupdate!!
の前に、念の為(使い慣れる意味も込めて)利用可能なパッケージを確認。
yum info php
バッチリありましたので、
yum update php
これで完了。
mcryptのアップデート
php --version
でPHPのバージョンを確認すると、
バージョンはアップしたものの、
PHP Warning: PHP Startup: mcrypt: Unable to initialize module Module compiled with module API=20050922, debug=0, thread-safety=0 PHP compiled with module API=20060613, debug=0, thread-safety=0 These options need to match in Unknown on line 0 PHP 5.2.16 (cli) (built: Dec 17 2010 14:09:03) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2010 Zend Technologies
のメッセージが。
Unable to initialize module ( モジュールの初期化をすることが出来ない)
との事。
mcryptのエラーって事で、きっとバージョンの不整合だろう、と一応確認
yum list installed mcrypt
で、初期インストール時のPHPと同じバージョンだったので
こやつもupdateします。
yum install php-mcrypt
Complete!
ってところで、再度PHPのバージョン確認。
無事確認出来ました。ひーはー。
無事、非公式のリポジトリでのupdateが完了したので、
リポジトリを無効にします。
vi /etc/yum.repos.d/utterramblings.repo
で、enabledを1から0に変更。
つぎにphp.iniを編集します。
vi /etc/php.ini
php.iniでよくやる設定まとめ - bojovs blog
こちらを参考にさせていただきつつ、最低限する編集を列挙します。
(デフォルトからの変更点のみ記述。)
- expose_php = Off
- log_errors_max_len = 4096
- default_charset = "UTF-8"
- mbstring.internal_encoding = UTF-8
- short_open_tag = Off
こんな感じ。
CentOS5.3にmySQL5.1.52をインストールする
今回もざっくり作業手順だけლ(・ิω・ิლ)
対象
- CentOS5.3
- mySQL5.1.52
今回はこちらの記事を参考にさせて頂きました。
あざます><
すでにインストールされてないか確認
mysqlがすでにないか確認。
yum list installed | grep mysql
ないので、mysql serverをインストール。
yum -y install mysql-server php-mysql
my.cnf編集
vi /etc/my.cnf
こちらの記事を参考にさせて頂きつつ、
※追記したもののみ記述してます><
[mysqld] # add default-character-set = utf8 skip-character-set-client-handshake [mysql] # add default-character-set = utf8
ただ、skip-character-set-client-handshakeに関しては
- 2007/04/23-01、skip-character-set-client-handshake について - debian-etch に関するメモ(後、lennyへアップグレード)
- mysqlでskip-character-set-client-handshakeはもう使わないほうがいいと思われ | へぼい日記
といった記事も見かけたので、また改めて勉強しよ。
mySQL起動
編集後、起動させます。
/etc/rc.d/init.d/mysqld start
自動起動も行っておく。
chkconfig mysqld on
chkconfigコマンド叩いたあとはいつも通り
特に反応はなく、入力待ち状態になりました。
以上でインストール終了。
念の為、はいってみましょかね。
mysql -u root -p
※ここまでの流れではrootにパスワード設定をしていません。
入れました。
rootパスワードの設定
mysql_secure_installation
以下、対話形式でお送りします。
[root@localhost ~]# 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]キーを叩く(rootのパスワード設定する?)
New password:
# ※パスワードを入力
Re-enter new password:
# ※再度パスワードを入力
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]キーを叩く(リモートからのrootログインを禁止する?)
... 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]キーを叩く(testデータベースを削除する?)
- 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!
サンクス!
ひとまずこんな感じですლ(・ิω・ิლ)
...Success!ってなんかいいですね。かっけー
なお、mysqlの起動を確認するには
/usr/local/mysql/bin/mysqladmin ping -u root -p
起動していれば、
mysqld is alive
と表示されますえ。
はじめのhttpd.conf設定からapache起動まで
一番最初に設定した、httpd.confの設定を残しときます。
対象
今回はこちらの記事を参考にさせて頂きました。
あざます><
httpd.conf編集
vi /etc/httpd/conf/httpd.conf
デフォルト記述と、変更点のみ列挙します。
一旦、アクセス制限を掛けます。
<Directory />
Options FollowSymLinks
AllowOverride None
# add
Order deny,allow
# add
Deny from all
</Directory>
アクセス制限を拒否してから許可にするのは
モバイル開発の癖かも。
エラーページとかでapacheのバージョンを表示させないように。
# ServerSignature On # change ServerSignature Off
エラーページとかでOS情報を表示させないように。
# add ServerTokens Prod
ローカル環境的に、VirtualHostで何個か運用するつもりなので
基本的には変更点は以上。
エラーチェック
confファイルのエラーチェックをし
/etc/rc.d/init.d/httpd configtest
apache起動
Syntax OK のお言葉を貰ったところでapacheの起動
/etc/rc.d/init.d/httpd start
そして、初めての起動なのでそのまま自動起動も設定しておく。
chkconfig httpd on
おしまい。
