Javaな日々

NO JAVA, NO LIFE.

さくら VPS (CentOS 6.3) に LAMP を構築する - PHP インストール

  1. PHP をインストール

    [admin@www****** ~]$ sudo yum -y install php php-mbstring php-mysql

  2. php.ini の設定
    PHP の設定ファイル (php.ini) を以下のように書き換える.

    [admin@www****** ~]$ sudo vi /etc/php.ini

    • short_open_tag = Off
      ↓
      short_open_tag = On 

    • expose_php = On
      ↓
      expose_php = Off

    • max_execution_time = 30
      ↓
      max_execution_time = 300

    • error_reporting  =  E_ALL
      ↓
      error_reporting  =  E_ALL & ~E_NOTICE

    • magic_quotes_gpc = On
      ↓
      magic_quotes_gpc = Off

    • ;default_charset = "iso-8859-1"
      ↓
      default_charset = "UTF-8"

    • upload_max_filesize = 2M
      ↓
      upload_max_filesize = 15M

    • ;date.timezone =
      ↓
      date.timezone = Asia/Tokyo

    • ;mbstring.language = Japanese
      ↓
      mbstring.language = Japanese

    • ;mbstring.internal_encoding = EUC-JP
      ↓
      mbstring.internal_encoding = UTF-8

    • ;mbstring.http_input = auto
      ↓
      mbstring.http_input = auto

    • ;mbstring.http_output = SJIS
      ↓
      mbstring.http_output = pass

    • ;mbstring.encoding_translation = Off
      ↓
      mbstring.encoding_translation = On

    • ;mbstring.detect_order = auto
      ↓
      mbstring.detect_order = auto

    • ;mbstring.substitute_character = none;
      ↓
      mbstring.substitute_character = none; 

  3. PHPApache で利用できるように設定.

    [admin@www****** ~]$ sudo vi /etc/httpd/conf/httpd.conf

    • PHP を使えるようにする.

      # If the AddEncoding directives above are commented-out, then you
      # probably should define those extensions to indicate media types:
      #
      AddType application/x-compress .Z
      AddType application/x-gzip .gz .tgz
      AddType application/x-httpd-php .php # 追記

    • index の設定 (PHP を許可する)

      DirectoryIndex index.html index.html.var
      ↓
      DirectoryIndex index.html index.php index.cgi index.html.var

  4. Apache を再起動して設定を適用.

    [admin@www****** ~]$ sudo /etc/rc.d/init.d/httpd restart