さくらのVPS サーバーセットアップメモ 3 『PHPとMySQL、PHPMyadminのインストール』
今回は、PHP+MySQLのインストールついでにPHPMyadminのインストールです。対応事項
- PHPのインストール
- MySQLのインストール
- PHPMyAdminのインストール
パッケージで管理したいので、yumで全部インストール
# yumでphpをインストール sudo yum -y install php php-devel php-gd php-mbstring php-mysql php-pdo php-pear php-xml php-imap php-pecl-apc # yumでmysqlをインストール sudo yum install mysql mysql-devel mysql-server
yumでMySQLもインストールし、自動起動をオン
# MySQLの自動起動をON chkconfig mysqld on # MySQLを起動 /etc/init.d/mysqld start
MySQLの初期設定
# MySQLの初期設定起動 sudo 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):# パスワードなしなので、空エンター OK, successfully used password, moving on... Setting the root password ensures that nobody can log into the MySQL root user without the proper authorisation. You already have a root password set, so you can safely answer 'n'. Change the root password? [Y/n] # 空エンター 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] #空エンターで、anonymousユーザー削除 ... 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] #リモートログインする予定ないので空エンターを押し、削除 ... 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] # 空エンターでテスト用のDBを削除 - Dropping test database... ERROR 1008 (HY000) at line 1: Can't drop database 'test'; database doesn't exist ... Failed! Not critical, keep moving... - 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] # 設定を反映 ... 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!
MySQLのユーザーを作成
mysql -u root -p #パスワードを入力 grant all privileges on *.* to nadeko@localhost identified by 'ur-passwd'; quit
PHPMyAdminのインストール
cd /var/www/html sudo mkdir phpmyadmin sudo chown apache. phpmyadmin/ cd phpmyadmin/ #gitでソース落としたかったので、gitインストール sudo yum -y install git # githubからphpmyadminのソースをダウンロード sudo -u apache git clone git://github.com/phpmyadmin/phpmyadmin.git /var/www/html/phpmyadmin/ # apache起動してなかったので、起動 sudo /etc/init.d/httpd start
見れたので、phpmyadminの設定するよ 以下例のURLにブラウザから、アクセス!
アクセスできたら、設定画面から、config.ini.phpを生成
http://ur-hostname/phpmyadmin/setup/
画面の説明めんどいので成果物を貼っとく
以下を、『sudo vim /var/www/html/phpmyadmin/config.ini.php』とかで適宜保存
<?php /* * Generated configuration file * Generated by: phpMyAdmin 4.0.0-dev setup script * Date: Mon, 30 Apr 2012 20:47:11 +0900 */ /* Servers configuration */ $i = 0; /* Server: ur-hostname [1] */ $i++; $cfg['Servers'][$i]['verbose'] = 'ur-hostname'; # ホスト名を適宜設定 $cfg['Servers'][$i]['host'] = 'localhost'; # ホスト名を適宜設定 $cfg['Servers'][$i]['port'] = ''; $cfg['Servers'][$i]['socket'] = ''; $cfg['Servers'][$i]['connect_type'] = 'tcp'; $cfg['Servers'][$i]['extension'] = 'mysqli'; $cfg['Servers'][$i]['auth_type'] = 'cookie'; $cfg['Servers'][$i]['user'] = 'root'; # さっき作ったMySQLのユーザー名を設定 $cfg['Servers'][$i]['password'] = 'ur-passwd'; # さっき作ったMySQLのユーザー名のパスワードを設定 /* End of servers configuration */ $cfg['blowfish_secret'] = '4f9e7b39038153.77380295'; $cfg['DefaultLang'] = 'en'; $cfg['ServerDefault'] = 1; $cfg['UploadDir'] = ''; $cfg['SaveDir'] = ''; ?>
以下URLにアクセスして、MySQLのユーザー名とパスワードをぶっこみ、 ログイン出来れば、OK
http://ur-hostname/phpmyadmin/
登録:
コメントの投稿
(
Atom
)
0 件のコメント :
コメントを投稿