LoginSignup
10
12

PHP のインストール

Last updated at Posted at 2018-07-15

前提

Wordpress の環境を構築するために php のインストールを行う。
Nginxはインストール済みの状態を想定。

ソースからビルドする場合

CentOS 7 の場合、リポジトリにあるものが古かったため、ソースからビルドしてみた。

今回は試しレベルのため、SELinux もあらかじめ無効にして試している。
実環境でインストールする場合には、セキュリティの設定を自環境における適切なものに適宜設定してください。

手順

  1. あらかじめ依存ライブラリをインストール

    # yum -y install libxml2-devel systemd-devel libpng-devel
    
    $ sudo apt install build-essential
    $ sudo apt install \
        autoconf \
        re2c \
        bison \
        libsqlite3-dev \
        libpq-dev \
        libonig-dev \
        libfcgi-dev \
        libfcgi0ldbl \
        libjpeg-dev \
        libpng-dev \
        libssl-dev \
        libxml2-dev \
        libcurl4-openssl-dev \
        libxpm-dev \
        libgd-dev \
        libmysqlclient-dev \
        libfreetype6-dev \
        libxslt1-dev \
        libpspell-dev \
        libzip-dev \
        libgccjit-10-dev \
        libsystemd-dev
    
  2. phpのtar.gzファイルをダウンロードする

    # curl -LkvOf https://www.php.net/distributions/php-7.4.27.tar.gz
    
  3. ファイルに破損がないか確認する

    # sha256sum php-7.4.27.tar.gz
    564fd5bc9850370db0cb4058d9087f2f40177fa4921ce698a375416db9ab43ca  php-7.4.27.tar.gz
    
  4. Configureとビルドを実行する

    # tar -zxf php-7.4.27.tar.gz
    # cd php-7.4.27/
    # ./configure --enable-fpm --with-openssl --with-curl --with-mysqli --with-zlib --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-fpm-systemd --enable-mbstring --with-mysql-sock=/var/lib/mysql/mysql.sock
    # make
    # make test
    # make install
    
  5. 必要な設定ファイルを雛形からコピーする

    # cp php.ini-production /usr/local/lib/php.ini
    

参考

10
12
0

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
10
12