64
67

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CentOS6にepel、remiで最新版のPHP、MySQLを導入

Last updated at Posted at 2014-07-02

ダウンロードできるバージョンの確認

yumでインストールできるphpのバージョンを確認

yum info php

yumでインストールできるmysqlのバージョンを確認

yum info mysql-server

古くなっていたらepel、remiで最新版を導入

###epelダウンロード

wget https://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

remiダウンロード

wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

elepインストール

sudo rpm -Uvh epel-release-6-8.noarch.rpm

remiインストール

sudo rpm -Uvh remi-release-6.rpm

epelの設定を編集

sudo vim /etc/yum.repos.d/epel.repo

1行編集

enable=0

remiでインストールできる最新版のphpを確認

yum info --enablerepo=remi php

remiで最新版のphpをインストール

sudo yum --enablerepo=remi install -y php php-pear php-devel php-mysql php-mbstring php-gd php-pdo php-xml

PHPの設定を編集

sudo vim /etc/php.ini

エラーログの場所

error_log = /var/log/php.log

mbstringの設定

mbstring.language = Japanese
mbstgring.internal_encoding = UTF-8
mbstring.http_input = auto
mbstring.detect_order = auto

expose_php

expose_php = Off

timezone

date.timezone = Asia/Tokyo

設定を反映

sudo service httpd restart

remiでインストールできる最新版のmysqlを確認

yum info --enablerepo=remi mysql-server

remiで最新版のMySQLをインストール

sudo yum --enablerepo=remi install -y mysql-server

動作確認

mysql --version

MySQLの設定を編集

sudo vim /etc/my.conf
character_set_server=utf8
default-storage-engine=InnoDB
innodb_file_per_table
[mysql]
default-character-set=utf8
[mysqldump]
default-character-set=utf8

MySQLの起動

sudo service mysqld start

MySQLのrootユーザにパスワードを設定

Initializing MySQL database:  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 at http://bugs.mysql.com/

                                                           [  OK  ]
Starting mysqld:                                           [  OK  ]

このようにごちゃごちゃ聞かれるので、以下の行に注目し、実行する

/usr/bin/mysql_secure_installation

rootユーザーのパスワードの設定を聞かれるので指示に従う

MySQLの自動起動

sudo chkconfig mysqld on

mysqlではまったときのメモ

http://www.kaasan.info/archives/1753
http://d.hatena.ne.jp/TamaC/20090330/1238418696

mysqlソケットエラー解決法

MySQLを起動しようとしてこのようなエラーが出たとき

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'

指定の場所にsocketファイルがあるか確認

ls -al /var/lib/mysql/

なかったら作成

sudo touch /var/lib/mysql/mysql.sock

ディレクトリ所有者の変更

sudo chown mysql:mysql -R /var/lib/mysql

mysql再起動

sudo /etc/init.d/mysqld restart
64
67
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
64
67

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?