0
1

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.

CentOS7 Nginx php の設定

Last updated at Posted at 2018-09-18

yum のアップデート


$ yum update

PHP7.1

優先順位を決定するパッケージのインストール


$ yum install yum-priorities

標準レポジトリの優先順位を設定


$ vim /etc/yum.repos.d/CentOS-Base.repo

/etc/yum.repos.d/CentOS-Base.repo に以下を追記する

/etc/yum.repos.d/CentOS-Base.repo
[base]
priority=1
exclude=php*
 
[updates]
priority=1
exclude=php*
 
[extras]
priority=1
exclude=php*

epelレポジトリのインストール


$ yum install epel-release

epelレポジトリの優先順位の設定


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

/etc/yum.repos.d/epel.repo に以下を追記する

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

[epel]
priority=2
exclude=php*

remiレポジトリのインストール


$ yum install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

remiレポジトリの優先順位を設定


$ vim /etc/yum.repos.d/remi.repo

/etc/yum.repos.d/remi.repo に以下を追記する

/etc/yum.repos.d/remi.repo

[remi]
priority=2

remiレポジトリの優先順位を設定


$ vim /etc/yum.repos.d/remi-php71.repo

/etc/yum.repos.d/remi-php71.repo に以下を追記する

/etc/yum.repos.d/remi-php71.repo

[remi-php71]
enabled=1

念のため yum のキャッシュを削除する


$ yum clean all

PHP7.1 のインストール


$ yum install php php-cli php-common php-devel php-fpm php-gd php-mbstring php-pdo php-pear php-pecl-apcu php-soap php-xml php-xmlrpc php-mcrypt

PHPの起動


$ systemctl start php-fpm.service

サーバー再起動時PHPを自動起動するように設定


$ systemctl enable php-fpm

php のバージョンの確認


$ php -v
PHP 7.1.10 (cli) (built: Sep 27 2017 08:27:18) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.1.0, Copyright (c) 1998-2017 Zend Technologies

/etc/php-fpm.d/www.conf内のuserとgroupをnginxに変更


$ vim /etc/php-fpm.d/www.conf

/etc/php-fpm.d/www.conf

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = apache ← nginxに変更
; RPM: Keep a group allowed to write in log dir.
group = apache ← nginxに変更

PHPを再起動


$ systemctl restart php-fpm

0
1
1

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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?