0.要件
- OS:CentOS6.x
- ユーザ名:hogeuser
- ミドルウェア:Apache2.2.x,PHP5.3.x,MySQL5.1.x
- アプリ:Wordpress,CakePHP
- 他
- ドメイン名:hogehoge.com
- ドキュメントルート:/var/www/vhosts/hogehoge.com
- MySQLのrootパスワード:hogehoge0
- Wordpressインストール先
- ドキュメントルート以下:/var/www/vhosts/hogehoge.com/wordpress
- DB名:wordpress_db
- DBユーザ名:wordpress
- DBパスワード:hogehoge1
- CakePHPインストール先
- ドキュメントルート以下:/var/www/vhosts/hogehoge.com/cakephp
- DB名:cake_db
- DBユーザ名:cakephp
- DBパスワード:hogehoge2
1.インストールの下準備
Kernelなどインストール済みのミドルウェアを最新に。
全てのミドルウェアをアップデート
コマンド
yum update -y
一旦、再起動
コマンド
reboot
Ctl-Alt-Delの停止
※不慮の事故を避けるために
/etc/init/control-alt-delete.conf
#下記の行をコメントアウト
exec /sbin/shutdown -r now "Control-Alt-Delete pressed"
あると便利なツールのインストール
コマンド
yum install telnet sysstat nmap gcc make git subversion subversion-tools subversion-libs subversion-devel openssl-devel -y
SELinuxの無効
/etc/selinux/config
#SELINUX=enforcing
SELINUX=disabled
2.SSHの設定
ユーザーの追加
コマンド
useradd hogeuser
パスワードの設定
コマンド
passwd hogeuser
ユーザー hogeuser のパスワードを変更。
新しいパスワード:
新しいパスワードを再入力してください:
passwd: 全ての認証トークンが正しく更新できました。
rootでのSSHログインを停止
/etc/ssh/sshd_config
#PermitRootLogin yes
PermitRootLogin no
設定の反映
コマンド
/etc/init.d/sshd restart
3.Apache
Apacheのインストール
コマンド
yum install httpd.x86_64 httpd-devel.x86_64
Apacheの起動
コマンド
/etc/init.d/httpd start
Apacheの自動起動
コマンド
chkconfig httpd on
コンテンツディレクトリの作成
コマンド
mkdir -p /var/www/vhosts/hogehoge.com/public_html/
chown hogeuser.hogeuser -R /var/www/vhosts/
Virtalhostの追記
/etc/httpd/conf.d/vhosts.conf
NameVirtualHost *:80
<VirtualHost *:80>
ServerAdmin info@hogehoge.com
ServerName www.hogehoge.com
ServerAlias hogehoge.com
DocumentRoot "/var/www/vhosts/hogehoge.com/public_html/"
DirectoryIndex index.php index.html index.xml
<Directory /var/www/vhosts/hogehoge.com/public_html/>
Options FollowSymLinks
AllowOverride all
</Directory>
CustomLog /var/log/httpd/hogehoge.com-access_log combined
ErrorLog /var/log/httpd/hogehoge.com-error_log
</VirtualHost>
configのチェック
コマンド
/etc/init.d/httpd configtest
設定反映
コマンド
/etc/init.d/httpd restart
4.PHP
PHPのインストール
コマンド
yum install php.x86_64 php-mysql.x86_64
動作確認
/var/www/vhosts/hogehoge.com/public_html/index.php
<?php
phpinfo();
?>
5.MySQL
MySQLのインストール
コマンド
yum install mysql.x86_64 mysql-server.x86_64
MySQLの起動
コマンド
/etc/init.d/mysqld start
MySQLの自動起動
コマンド
chkconfig mysqld on
MySQLのrootのパスワードを設定
コマンド
mysql
コマンド
> GRANT ALL ON *.* TO root@localhost IDENTIFIED BY "hogehoge0" WITH GRANT OPTION;
> GRANT ALL ON *.* TO root@127.0.0.1 IDENTIFIED BY "hogehoge0" WITH GRANT OPTION;
> flush privileges;
> select user,host,password from mysql.user;
+------+-----------+------------------+
| user | host | password |
+------+-----------+------------------+
| root | localhost | xxxxxxxxxxxxxxxxxxx |
| root | 127.0.0.1 | xxxxxxxxxxxxxxxxxxx |
+------+-----------+------------------+
> quit
パスワードが更新されたかの確認
コマンド
mysql -u root -p
: hogehoge0 と入力
6.Vsftpd
Vsftpdのインストール
コマンド
yum install vsftpd
vsftpdの起動
コマンド
/etc/init.d/vsftpd start
Vsftpdの自動起動
コマンド
chkconfig vsftpd on
設定変更(AnonymousをNo、chrootをNo)
/etc/vsftpd/vsftpd.conf
#anonymous_enable=YES
anonymous_enable=NO
#chroot_local_user=YES
chroot_local_user=NO
設定反映
コマンド
/etc/init.d/vsftpd restart
7.Wordpress
Wordpress用DBの作成
コマンド
> create database wordpress_db;
> GRANT ALL ON wordpress_db.* TO wordpress@localhost IDENTIFIED BY "hogehoge1";
> GRANT ALL ON wordpress_db.* TO wordpress@127.0.0.1 IDENTIFIED BY "hogehoge1";
> flush privileges;
> quit
8.CakePHP
cakePHP用DBの作成
コマンド
> create database cakephp_db;
> GRANT ALL ON cakephp_db.* TO cakephp@localhost IDENTIFIED BY "hogehoge2";
> GRANT ALL ON cakephp_db.* TO cakephp@127.0.0.1 IDENTIFIED BY "hogehoge2";
> flush privileges;
> quit