CentOS 7 Apache 2.4.29 + PHP 7.2.2 + PHP 5.6.33 インストール手順

インストールコマンド (記事公開時点での最新版)

yum -y groupinstall base
yum -y groupinstall development

yum -y install zlib-devel
yum -y install perl-core

cd /usr/local/src/
wget https://www.openssl.org/source/openssl-1.1.0g.tar.gz
tar xf openssl-1.1.0g.tar.gz
cd openssl-1.1.0g
./config --prefix=/usr/local/openssl-1.1.0g shared zlib
make depend
make
make test
make install
echo /usr/local/openssl-1.1.0g/lib > /etc/ld.so.conf.d/openssl110g.conf
ldconfig

yum -y install libev-devel c-ares-devel
cd ../
wget https://github.com/nghttp2/nghttp2/releases/download/v1.30.0/nghttp2-1.30.0.tar.gz
tar xf nghttp2-1.30.0.tar.gz
cd nghttp2-1.30.0/
env OPENSSL_CFLAGS="-I/usr/local/openssl-1.1.0g/include" OPENSSL_LIBS="-L/usr/local/openssl-1.1.0g/lib -lssl -lcrypto" ./configure -enable-app
make
make install

yum -y install cmake
cd ../
wget https://github.com/google/brotli/archive/v1.0.2.tar.gz
tar xf v1.0.2.tar.gz
cd brotli-1.0.2/
mkdir out && cd out
../configure-cmake
make
make test
make install
echo /usr/local/lib > /etc/ld.so.conf.d/usr-local-lib.conf
ldconfig

yum -y install pcre-devel
yum -y install expat-devel
cd ../
wget http://ftp.jaist.ac.jp/pub/apache//apr/apr-1.6.3.tar.gz
tar xf apr-1.6.3.tar.gz
cd apr-1.6.3/
./configure
make
make install
cd ../
wget http://ftp.jaist.ac.jp/pub/apache//apr/apr-util-1.6.1.tar.gz
tar xf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1/
./configure --with-apr=/usr/local/apr
make
make install

cd ../
wget https://curl.haxx.se/download/curl-7.58.0.tar.gz
tar xf curl-7.58.0.tar.gz
cd curl-7.58.0/
yum -y install libidn2-devel libpsl-devel sspi-devel libsspi
./configure --enable-libcurl-option --with-nghttp2=/usr/local --with-libidn2 --with-darwinssl --with-libssh2  --with-ssl=/usr/local/openssl-1.1.0g --with-gssapi --enable-tls-srp
make
make install
ldconfig

cd ../
wget http://ftp.jaist.ac.jp/pub/apache//httpd/httpd-2.4.29.tar.gz
tar xf httpd-2.4.29.tar.gz
cd httpd-2.4.29/
./configure --enable-http2 --enable-brotli --with-brotli=/usr/local/lib --enable-ssl --with-ssl=/usr/local/openssl-1.1.0g --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr --enable-so --enable-mods-shared=all --enable-mpms-shared=all
make
make install

cd ../
wget http://jp2.php.net/get/php-7.2.2.tar.gz/from/this/mirror
tar xf mirror
rm -f mirror
wget http://jp2.php.net/get/php-5.6.33.tar.gz/from/this/mirror
tar xf mirror
rm -f mirror
cd php-7.2.2/
ln -s /usr/local/openssl-1.1.0g/lib /usr/local/openssl-1.1.0g/lib64
yum -y install bzip2-devel postgresql-devel
curl -sS https://downloads.mariadb.com/MariaDB/mariadb_repo_setup | sudo bash
yum -y install MariaDB-devel MariaDB-client
yum -y install gd-devel libwebp libwebp-devel libwebp-tools gmp-devel libc-client-devel libicu-devel readline-devel net-snmp-devel libtidy-devel libxml2-devel libxslt-devel
./configure --with-libdir=lib64 --with-pic --with-bz2 --with-imap --with-imap-ssl --with-freetype-dir --with-xpm-dir --with-gettext --with-gmp --with-iconv --with-jpeg-dir --with-curl=/usr/local --with-webp-dir --with-png-dir --with-openssl=/usr/local/openssl-1.1.0g --with-pcre-regex --with-zlib --with-layout=GNU --enable-exif --enable-ftp --enable-sockets --with-kerberos --enable-shmop --enable-calendar --with-libxml-dir --with-mhash --with-readline --with-tidy --with-xsl --with-gnu-ld --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pgsql --enable-mbstring --with-gd --with-apxs2=/usr/local/apache2/bin/apxs --enable-fpm --enable-opcache --enable-opcache-file --enable-zip --enable-bcmath --enable-intl
make
make install
libtool --finish /usr/local/src/php-7.2.2/libs

cd ../php-5.6.33/
yum -y install openssl-devel curl-devel
./configure --with-libdir=lib64 --with-pic --with-bz2 --with-imap --with-imap-ssl --with-freetype-dir --with-xpm-dir --with-gettext --with-gmp --with-iconv --with-jpeg-dir --with-curl=/usr --with-png-dir --with-openssl --with-openssl-dir=/usr/bin --with-pcre-regex --with-zlib --with-layout=GNU --enable-exif --enable-ftp --enable-sockets --with-kerberos --enable-shmop --enable-calendar --with-libxml-dir --with-mhash --with-readline --with-tidy --with-xsl --with-gnu-ld --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-pgsql --enable-mbstring --with-gd --with-apxs2=/usr/local/apache2/bin/apxs --enable-fpm --enable-opcache --enable-zip --with-mysql --enable-bcmath --prefix=/usr/local/lib/php56 --with-config-file-path=/usr/local/lib/php56 --enable-intl
make
make install
libtool --finish /usr/local/src/php-5.6.33/libs
ln -s /usr/local/lib/php56/bin/phar.phar /usr/local/bin/phar56
ln -s /usr/local/lib/php56/bin/pear /usr/local/bin/pear56
ln -s /usr/local/lib/php56/bin/peardev /usr/local/bin/peardev56
ln -s /usr/local/lib/php56/bin/pecl /usr/local/bin/pecl56
ln -s /usr/local/lib/php56/bin/php /usr/local/bin/php56
ln -s /usr/local/lib/php56/bin/php-cgi /usr/local/bin/php56-cgi
ln -s /usr/local/lib/php56/bin/php-config /usr/local/bin/php56-config
ln -s /usr/local/lib/php56/bin/phpize /usr/local/bin/php56ize
ln -s /usr/local/openssl-1.1.0g/bin/openssl /usr/local/bin/openssl
ldconfig

cd ../
wget https://pecl.php.net/get/apcu-5.1.9.tgz
wget https://pecl.php.net/get/apcu-4.0.11.tgz
tar xf apcu-5.1.9.tgz
tar xf apcu-4.0.11.tgz
cd apcu-5.1.9/
phpize
./configure
make
make install
cd ../apcu-4.0.11/
php56ize
./configure --with-php-config=/usr/local/bin/php56-config
make
make install

yum -y install libmemcached libmemcached-devel
cd ../
wget https://pecl.php.net/get/memcached-3.0.4.tgz
wget https://pecl.php.net/get/memcached-2.2.0.tgz
tar xf memcached-3.0.4.tgz
tar xf memcached-2.2.0.tgz
cd memcached-3.0.4/
phpize
./configure
make
make install
cd ../memcached-2.2.0/
php56ize
./configure --with-php-config=/usr/local/bin/php56-config
make
make install

cd ../
wget https://pecl.php.net/get/redis-3.1.6.tgz
tar xf redis-3.1.6.tgz
cd redis-3.1.6/
phpize
./configure
make
make install
make clean
php56ize
./configure --with-php-config=/usr/local/bin/php56-config
make
make install

cd ../
rm -f *.gz
rm -f *.tgz
rm -f package.xml
ln -s /usr/local/apache2/bin/ab /usr/local/bin/ab
ln -s /usr/local/apache2/bin/apachectl /usr/local/bin/apachectl
ln -s /usr/local/apache2/bin/apxs /usr/local/bin/apxs
ln -s /usr/local/apache2/bin/checkgid /usr/local/bin/checkgid
ln -s /usr/local/apache2/bin/fcgistarter /usr/local/bin/fcgistarter
ln -s /usr/local/apache2/bin/htcacheclean /usr/local/bin/htcacheclean
ln -s /usr/local/apache2/bin/htdbm /usr/local/bin/htdbm
ln -s /usr/local/apache2/bin/htdigest /usr/local/bin/htdigest
ln -s /usr/local/apache2/bin/htpasswd /usr/local/bin/htpasswd
ln -s /usr/local/apache2/bin/httpd /usr/local/bin/httpd
ln -s /usr/local/apache2/bin/httxt2dbm /usr/local/bin/httxt2dbm
ln -s /usr/local/apache2/bin/logresolve /usr/local/bin/logresolve
ln -s /usr/local/apache2/bin/rotatelogs /usr/local/bin/rotatelogs
ln -s /usr/local/apache2/conf /etc/httpd
cd

vi /etc/systemd/system/httpd.service


[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
 
[Service]
Type=forking
ExecStart=/usr/local/apache2/bin/apachectl start
ExecReload=/usr/local/apache2/bin/apachectl graceful
ExecStop=/usr/local/apache2/bin/apachectl stop
 
[Install]
WantedBy=multi-user.target


systemctl daemon-reload

☆ここからはyumインストール環境に近づけるための設定


groupadd apache -g 48
useradd -u 48 -g 48 -d /usr/local/apache2 -M -s /sbin/nologin apache
ln -s /usr/local/apache2/conf /etc/httpd
ln -s /usr/local/apache2/modules /etc/httpd/modules
mkdir /var/log/httpd
cd /usr/local/apache2
rmdir logs
ln -s /var/log/httpd /usr/local/apache2/logs
ln -s /etc/php.ini /usr/local/etc/php.ini
ln -s /etc/php56.ini /usr/local/lib/php56/etc/php.ini

Categories