apache2 / php5.6のインストール

  • yumリポジトリの追加
    EPEL
    # rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
    # rpm --import http://dl.fedoraproject.org/pub/epel/RPM-GPG-KEY-EPEL-7

    Remi
    # rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
    # rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi

    MySQL
    # rpm -ivh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
  • EPELリポジトリを有効化
    # vim /etc/yum.repos.d/epel.repo

    [epel]
    ..
    ..
    enabled=0
    ↓
    enabled=1
  • Remiリポジトリを有効化
    # vim /etc/yum.repos.d/remi.repo

    [remi]
    ..
    ..
    enabled=0
    ↓
    enabled=1
    
    [remi-php56]
    ..
    ..
    enabled=0
    ↓
    enabled=1
  • Install Apache
    # yum -y install httpd-devel mod_ssl
  • Install PHP
    # yum -y install php php-devel
    # yum -y install php-pdo php-mysql
    # yum -y install php-mbstring php-mcrypt php-gd php-pear
    # yum -y install php-pear-DB
    # yum -y install php-pear-Auth-*
    # yum -y install php-pecl-apc-devel
    # yum -y install zlib-devel
  • Install MySQL
    # yum -y install mysql-devel
    # yum -y install mysql-server
  • Install Memcached
    # yum -y install memcached-devel php-pecl-memcache
  • Install ssmtp
    # yum -y install ssmtp
  • yumリポジトリの無効化
    # vim /etc/yum.repos.d/epel.repo

    [epel]
    ..
    ..
    enabled=1
    ↓
    enabled=0

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

    [remi]
    ..
    ..
    enabled=1
    ↓
    enabled=0
    
    [remi-php56]
    ..
    ..
    enabled=1
    ↓
    enabled=0
  • Apacheの不要な設定を読み込まない設定
    # mv -i /etc/httpd/conf.d/autoindex.conf /etc/httpd/conrf.d/autoindex.conf.org
    # mv -i /etc/httpd/conf.d/userdir.conf /etc/httpd/conf.d/userdir.conf.org
    # mv -i /etc/httpd/conf.d/welcome.conf /etc/httpd/conf/httpd.conf.org
  • Firewall設定
    # firewall-cmd --add-port=80/tcp --permanent
    # firewall-cmd --add-port=443/tcp --permanent
    # firewall-cmd --reload
    # firewall-cmd --list-ports --zone=public
  • Virtual HostをそれぞれのUserの権限で実行するための設定
    # cd /usr/src/
    # wget http://dl.fedoraproject.org/pub/epel/7/x86_64/h/httpd-itk-2.4.7.01-5.el7.x86_64.rpm
    # rpm -Uvh httpd-itk-2.4.7.01-5.el7.x86_64.rpm
    https://dl.fedoraproject.org/pub/epel/7/x86_64/h/ で存在するバージョンを確認
    # vim /etc/httpd/conf.modules.d/00-mpm-itk.conf

    ..
    ..
    #LoadModule mpm_itk_module modules/mod_mpm_itk.so
    ↓
    LoadModule mpm_itk_module modules/mod_mpm_itk.so

    virtualhost実行ユーザー(例: webuser)にapacheグループを追加する
    # usermod -aG apache webuser

    webuserのdocument rootが/home/webuser/wwwで、/home/webuser/www/upload以下をphp等でファイル更新させるためには、以下のSeLinuxの設定が必要
    # chcon -t httpd_sys_content_t /home/webuser/www/ -R
    # chcon -t httpd_sys_rw_content_t /home/webuser/www/upload/ -R

    ※phpのセッションを使うためにも必要
    上記webuserのVirtualHost例
    # vim /etc/httpd/conf.d/webuser.conf

    <VirtualHost *:80>
       ServerName webuser
       ServerAlias webuser
       DocumentRoot /home/webuser/www
       ErrorLog /home/webuser/logs/error.log
       CustomLog /home/webuser/logs/requests.log combined
    
       AssignUserId webuser webuser
       <Directory "/home/webuser/www">
          DirectoryIndex index.php index.html
          Require all granted
          AllowOverride AuthConfig
          Order allow,deny
          allow from all
       </Directory>
    </VirtualHost>