LoginSignup
7
7

More than 5 years have passed since last update.

Apache 2.2 + PHP 5.6 インストール(RPM)(CentOS 6.7)

Posted at

開発ツールのインストール

[vagrant@localhost ~]$ sudo yum -y groupinstall development

EPELリポジトリの追加

[vagrant@localhost ~]$ sudo rpm --import http://ftp.riken.jp/Linux/fedora/epel/RPM-GPG-KEY-EPEL-6
[vagrant@localhost ~]$ sudo rpm -ivh http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
[vagrant@localhost ~]$ sudo sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo

Remiポジトリの追加

[vagrant@localhost ~]$ sudo rpm --import http://rpms.famillecollet.com/RPM-GPG-KEY-remi
[vagrant@localhost ~]$ sudo rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
[vagrant@localhost ~]$ sudo sed -i -e "s/enabled *= *1/enabled=0/g" /etc/yum.repos.d/remi.repo

Apache のインストール

[vagrant@localhost ~]$ sudo yum -y install httpd mod_ssl

Apache の設定

[vagrant@localhost ~]$ sudo cp -p /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.org
[vagrant@localhost ~]$ sudo sed -i -e "s/#ServerName www.example.com:80/ServerName localhost.localdomain:80/"  /etc/httpd/conf/httpd.conf

Apache の設定(バーチャルホストの作成)

※ここでは「virtualhost.tatsunet.net」という名前のバーチャルホストを作成する。
※SSLサーバ証明書はデフォルトファイル(オレオレ証明書)を使用する。

[vagrant@localhost ~]$ sudo mkdir /var/www/virtualhost.tatsunet.net
[vagrant@localhost ~]$ cat << EOF | sudo tee /etc/httpd/conf.d/virtualhost.tatsunet.net.conf
NameVirtualHost *:80

<VirtualHost *:80>
  DocumentRoot /var/www/virtualhost.tatsunet.net
  ServerName virtualhost.tatsunet.net
  CustomLog logs/virtualhost.tatsunet.net_access_log combined
  ErrorLog logs/virtualhost.tatsunet.net_error_log
</VirtualHost>

NameVirtualHost *:443

<VirtualHost *:443>
  DocumentRoot /var/www/virtualhost.tatsunet.net
  ServerName virtualhost.tatsunet.net
  CustomLog logs/virtualhost.tatsunet.net_ssl_access_log combined
  ErrorLog logs/virtualhost.tatsunet.net_ssl_error_log

  SSLEngine on
  SSLProtocol all -SSLv2
  SSLCipherSuite DEFAULT:!EXP:!SSLv2:!DES:!IDEA:!SEED:+3DES
  SSLCertificateFile /etc/pki/tls/certs/localhost.crt
  SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
</VirtualHost>
EOF

PHP のインストール

[vagrant@localhost ~]$ sudo yum -y --enablerepo=remi-php56,remi,epel install php php-devel php-gd php-gmp php-intl php-mbstring php-mcrypt php-mysqlnd php-nrk-Predis php-opcache php-pdo php-pear php-pecl-apcu php-pecl-jsonc php-pecl-jsonc-devel php-pecl-lua php-pecl-memcached php-pecl-msgpack php-pecl-xdebug php-pecl-xhprof php-pecl-xslcache php-pecl-zip php-phpunit-PHPUnit php-process php-xml

PHP の設定

[vagrant@localhost ~]$ sudo cp -p /etc/php.ini /etc/php.ini.org
[vagrant@localhost ~]$ sudo sed -i -e 's/;date.timezone =/date.timezone = "Asia\/Tokyo"/' /etc/php.ini
[vagrant@localhost ~]$ php -i | grep date.timezone
date.timezone => Asia/Tokyo => Asia/Tokyo

Apache の起動

[vagrant@localhost ~]$ /etc/rc.d/init.d/httpd configtest
Syntax OK
[vagrant@localhost ~]$ sudo /etc/rc.d/init.d/httpd start
[vagrant@localhost ~]$ sudo chkconfig httpd on

動作確認

[vagrant@localhost ~]$ php -m
[PHP Modules]
apc
apcu
bz2
calendar
Core
ctype
curl
date
dom
ereg
exif
fileinfo
filter
ftp
gd
gettext
gmp
hash
iconv
igbinary
intl
json
libxml
lua
mbstring
mcrypt
memcached
mhash
msgpack
mysql
mysqli
mysqlnd
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
Phar
posix
readline
Reflection
session
shmop
SimpleXML
soap
sockets
SPL
sqlite3
standard
sysvmsg
sysvsem
sysvshm
tidy
tokenizer
wddx
xdebug
xhprof
xml
xmlreader
xmlwriter
xsl
xslcache
Zend OPcache
zip
zlib

[Zend Modules]
Xdebug
Zend OPcache

[vagrant@localhost ~]$ apachectl -M
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 auth_basic_module (shared)
 auth_digest_module (shared)
 authn_file_module (shared)
 authn_alias_module (shared)
 authn_anon_module (shared)
 authn_dbm_module (shared)
 authn_default_module (shared)
 authz_host_module (shared)
 authz_user_module (shared)
 authz_owner_module (shared)
 authz_groupfile_module (shared)
 authz_dbm_module (shared)
 authz_default_module (shared)
 ldap_module (shared)
 authnz_ldap_module (shared)
 include_module (shared)
 log_config_module (shared)
 logio_module (shared)
 env_module (shared)
 ext_filter_module (shared)
 mime_magic_module (shared)
 expires_module (shared)
 deflate_module (shared)
 headers_module (shared)
 usertrack_module (shared)
 setenvif_module (shared)
 mime_module (shared)
 dav_module (shared)
 status_module (shared)
 autoindex_module (shared)
 info_module (shared)
 dav_fs_module (shared)
 vhost_alias_module (shared)
 negotiation_module (shared)
 dir_module (shared)
 actions_module (shared)
 speling_module (shared)
 userdir_module (shared)
 alias_module (shared)
 substitute_module (shared)
 rewrite_module (shared)
 proxy_module (shared)
 proxy_balancer_module (shared)
 proxy_ftp_module (shared)
 proxy_http_module (shared)
 proxy_ajp_module (shared)
 proxy_connect_module (shared)
 cache_module (shared)
 suexec_module (shared)
 disk_cache_module (shared)
 cgi_module (shared)
 version_module (shared)
 php5_module (shared)
 ssl_module (shared)
Syntax OK
[vagrant@localhost ~]$ echo '<?php phpinfo();' | sudo tee /var/www/virtualhost.tatsunet.net/index.php
[vagrant@localhost ~]$ sudo cp -p /etc/hosts /etc/hosts.org
[vagrant@localhost ~]$ sudo sed -i -e "s/`grep 127.0.0.1 /etc/hosts`/& virtualhost.tatsunet.net/" /etc/hosts
[vagrant@localhost ~]$ curl -s http://virtualhost.tatsunet.net/ | egrep "<tr>.*PHP Version"
<tr><td class="e">PHP Version </td><td class="v">5.6.16 </td></tr>
[vagrant@localhost ~]$ curl -s -k https://virtualhost.tatsunet.net/ | egrep "<tr>.*PHP Version"
<tr><td class="e">PHP Version </td><td class="v">5.6.16 </td></tr>
7
7
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
7
7