개발모음집

centos7에서 h2o와 php 7 설치하기 본문

Server

centos7에서 h2o와 php 7 설치하기

void 2017. 12. 2. 10:00

결과적으로 실패한 설치방법입니다.

그래도

누군가에겐 도움이 될 것 같아서

공개해놓습니다.





처음에 이걸 꼭 해줘야함.


$ cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)

처음에 이걸 꼭 해서 확인해야함. 이 블로그에서는 위와 같이 나왔지만, 나는 아래와 같이 나옴

CentOS Linux release 7.4.1708 (Core) 


# firewall-cmd --list-all
public (default, active)
  interfaces: eth0
  sources:
  services: dhcpv6-client ssh
  ports:
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:

SSH はすでに開いているので、HTTPS (443) を開放する

# firewall-cmd --add-service=https --zone=public --permanent
success
# firewall-cmd --reload
success
# firewall-cmd --list-all
public (default, active)
  interfaces: eth0
  sources:
  services: dhcpv6-client https ssh
  ports:
  masquerade: no
  forward-ports:
  icmp-blocks:
  rich rules:
# vi /etc/ssh/sshd_config
PermitRootLogin no

変更後、設定の再読込

systemctl reload sshd

一般ユーザーを鍵認証のみ許可

一般ユーザーでログインし ~/.ssh/authorized_keys にクライアントのSSH公開鍵を追記する
その後、クライアントから パスワードなし で SSHログイン できるか確認する

確認できたら、パスワード認証によるSSHログインを禁止する

# vi /etc/ssh/sshd_config
PasswordAuthentication no

変更後、設定の再読込

systemctl reload sshd

SELinux を Permissive に

# setenforce Permissive

MariaDB

CentOS 7 から 標準のパッケージ群には MySQL はなくなり、
MariaDB に置き換わっていた

インストール

# yum install mariadb mariadb-server

サービス起動

# systemctl enable mariadb.service
# systemctl start mariadb.service

初期セットアップ

# mysql_secure_installation

PHP 7

必要なパッケージをインストール

# rpm -ihv ftp://195.220.108.108/linux/centos/7.2.1511/extras/x86_64/Packages/epel-release-7-5.noarch.rpm # yum install libxml2-devel openssl-devel libpng-devel libjpeg-devel bzip2-devel libcurl-devel freetype-devel libmcrypt-devel libxslt-devel wget


Retrieving ftp://195.220.108.108/linux/centos/7.2.1511/extras/x86_64/Packages/epel-release-7-5.noarch.rpm

curl: (9) Server denied you to change to the given directory

error: skipping ftp://195.220.108.108/linux/centos/7.2.1511/extras/x86_64/Packages/epel-release-7-5.noarch.rpm - transfer failed

이 블로거처럼  # rpm -ihv ftp://195.220.108.108/linux/centos/7.2.1511/extras/x86_64/Packages/epel-release-7-5.noarch.rpm를 복붙했는데 안되었다. 왜냐하면 위에 코어가 다르기 때문에!

그래서 나는 브라우저에서 url을 입력해서 들어갔다.
브라우저에 ftp://195.220.108.108/를 입력하면 페이지 하나가 나온다.
루트따라가다보면
linux/centos/7.4.1708/extras/x86_64/Packages/

나같은 경우 7.4.1708이었기때문에 이쪽으로 간거.. 
그리고 나는 epel-release-7-9 파일이 있는 것을 확인하고 
# rpm -ihv ftp://195.220.108.108/linux/centos/7.2.1511/extras/x86_64/Packages/epel-release-7-9.noarch.rpm
로 변경하여 코드를 입력하였다.
며칠만에 7.2.1511 디프리케이트됨 ㅋㅋ

# rpm -ihv ftp://195.220.108.108/linux/centos/7/extras/x86_64/Packages/epel-release-7-9.noarch.rpm
로 변경하여 코드를 입력하였다.
git clone해야하기 때문에 git 깔아주고!

# yum install git

ソースを取得

# git clone --depth=1 -b php-7.0.2 https://github.com/php/php-src.git

ビルド

# cd php-src/


# ./buildconf --force

했더니 아래와 같은 에러 발생

Forcing buildconf

Removing configure caches

buildconf: checking installation...

buildconf: autoconf not found.

           You need autoconf version 2.59 or newer installed

           to build PHP from Git.

make: *** [buildmk.stamp] Error 1

# yum install autoconf (참고 사이트)

# ./buildconf --force

configure: WARNING: You will need re2c 0.13.4 or later if you want to regenerate PHP parsers.

# yum install re2c (참고 사이트)


# ./buildconf --force

configure: WARNING: This bison version is not supported for regeneration of the Zend/PHP parsers (found: none, min: 204, excluded: ).

checking for re2c... re2c

checking for re2c version... 0.14.3 (ok)

configure: error: bison is required to build PHP/Zend when building a GIT checkout!


1
2
3
4
5
6
wget http://ftp.gnu.org/gnu/bison/bison-2.4.1.tar.gz
tar -zxvf bison-2.4.1.tar.gz
cd bison-2.4.1/
./configure
make
make install


출처 : 일본 블로그


# ./buildconf --force # ./configure \ --with-zlib-dir \ --with-freetype-dir \ --enable-mbstring \ --with-libxml-dir=\ --enable-soap \ --enable-calendar \ --with-curl \ --with-mcrypt \ --with-zlib \ --with-gd \ --disable-rpath \ --enable-inline-optimization \ --with-bz2 \ --with-zlib \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-pcntl \ --enable-mbregex \ --enable-exif \ --enable-bcmath \ --with-mhash \ --enable-zip \ --with-pcre-regex \ --with-pdo-mysql \ --with-mysqli \ --with-mysql-sock=/var/run/mysqld/mysqld.sock \ --with-jpeg-dir=/usr \ --with-png-dir=/usr \ --enable-gd-native-ttf \ --with-openssl \ --with-fpm-user=USER \ --with-fpm-group=USER \ --with-libdir \ --enable-ftp \ --with-kerberos \ --with-gettext \ --with-xmlrpc \ --with-xsl \ --enable-opcache \ --enable-fpm # make && make install


H2O

必要なパッケージのインストール

# yum install cmake

ソースの取得

# cd ~/
# git clone --depth=1 https://github.com/h2o/h2o.git
# cd h2o

ビルド&インストール

# cmake -DWITH_BUNDLED_SSL=off .


CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found.   Please set CMAKE_CXX_COMPILER to a valid compiler path or name.



# yum install gcc-c++
# yum install cmake     
# yum install -y ncurses-devel

출처 : 사이트



# cmake -DWITH_BUNDLED_SSL=off .

-- Could NOT find LIBUV (missing:  LIBUV_LIBRARIES LIBUV_INCLUDE_DIR) 

-- checking for module 'libwslay'

--   package 'libwslay' not found

-- Could NOT find WSLAY (missing:  WSLAY_LIBRARIES WSLAY_INCLUDE_DIR) 


# git clone https://github.com/tatsuhiro-t/wslay.git


cd wslay/

# autoreconf -i

Can't exec "aclocal": No such file or directory at /usr/share/autoconf/Autom4te/FileUtils.pm line 326.
autoreconf: failed to run aclocal: No such file or directory


# yum install automake (참고 : 사이트 )



configure.ac:34: installing './config.guess'
configure.ac:34: installing './config.sub'
configure.ac:40: installing './install-sh'
configure.ac:40: installing './missing'
Makefile.am: installing './INSTALL'
examples/Makefile.am: installing './depcomp'
lib/Makefile.am:32: error: Libtool library used but 'LIBTOOL' is undefined
lib/Makefile.am:32:   The usual way to define 'LIBTOOL' is to add 'LT_INIT'
lib/Makefile.am:32:   to 'configure.ac' and run 'aclocal' and 'autoconf' again.
lib/Makefile.am:32:   If 'LT_INIT' is in 'configure.ac', make sure
lib/Makefile.am:32:   its definition is in aclocal's search path.
parallel-tests: installing './test-driver'
autoreconf: automake failed with exit status: 1

# automake --add-missing --copy --force-missing (출처 : 깃헙)


#autoreconf -i

lib/Makefile.am:32: error: Libtool library used but 'LIBTOOL' is undefined
lib/Makefile.am:32:   The usual way to define 'LIBTOOL' is to add 'LT_INIT'
lib/Makefile.am:32:   to 'configure.ac' and run 'aclocal' and 'autoconf' again.
lib/Makefile.am:32:   If 'LT_INIT' is in 'configure.ac', make sure
lib/Makefile.am:32:   its definition is in aclocal's search path.

# yum install libtool
#autoreconf -i

# automake
# autoconf
#./configure
# make


make[2]: Entering directory `/root/h2o/wslay/doc'
make[2]: *** No rule to make target `man/wslay_event_context_server_init.3', needed by `all-am'.  Stop.
make[2]: Leaving directory `/root/h2o/wslay/doc'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/root/h2o/wslay'
make: *** [all] Error 2

검색해보니 sphinx-doc를 깔라고 한다. 듣도 보도 못한... 파일.. (참고 : 깃헙)
sudo yum install python-pip
sudo pip install -U Sphinx
sudo sphinx-build --version
출처 : 사이트 


./configure
# make
# make install



# cd h2o

# make && make install


systemd で起動するために設定ファイル用意

vi /usr/lib/systemd/system/h2o.service
[Unit]
Description=H2O optimized HTTP server

[Service]
Type=forking
PIDFile=/var/run/h2o/h2o.pid
ExecStartPre=-/usr/bin/mkdir -p /var/run/h2o /var/log/h2o
ExecStartPre=-/usr/bin/chown USERNAME:USERNAME /var/run/h2o /var/log/h2o
ExecStart=/usr/local/bin/h2o -c /etc/h2o/h2o.conf -m daemon
ExecReload=/usr/bin/kill -HUP $MAINPID
LimitNOFILE=infinity

[Install]
WantedBy=multi-user.target

ちなみに、php-fpm は H2O が呼び出す

H2O 設定ファイル

# mkdir /etc/h2o
# vi /etc/h2o.conf
user: USERNAME
pid-file: /var/run/h2o/h2o.pid
access-log: /var/log/h2o/access.log
error-log: /var/log/h2o/error.log
http2-reprioritize-blocking-assets: ON
max-connections: 1024
num-threads: 2

listen:
  port: 443
  ssl:
    certificate-file: /path/to/certificate/file.pem
    key-file: /path/to/private/key.pem

file.custom-handler:
  extension: .php
  fastcgi.spawn: "PHP_FCGI_CHILDREN=10 exec /usr/local/bin/php-cgi"
hosts:
  "DOMAIN_NAME:443":
    paths:
      /:
        file.dir: /home/USERNAME/wordpress/
        file.dirlisting: OFF
        redirect:
          url: /index.php/
          internal: YES
          status: 307

SSL 証明書の用意

nginx の場合と同じように証明書を用意する

サービスの起動


# systemctl start h2o.service






# systemctl start h2o.service
























블로그보고 참고


11  yum -y update

   12  yum -y install ibus-kkc vlgothic-*

   13  source /etc/locale.conf

   14  echo $LANG

   15  timedatectl set-timezone Asia/Seoul

   16  timedatectl

   18  yum -y install epel-release

   20  yum -y install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

   21  yum install --enablerepo=remi,remi-php71 php php-devel php-mbstring php-pdo php-gd

   22  yum install cmake

   23  cd ~/

   25  yum install git

   26  git clone --depth=1 https://github.com/h2o/h2o.git

   27  cd h2o

   29  yum install epel-release

   30  yum install zlib-devel

   32  yum install gcc-c++   (ask ubuntu 참고)


   34  yum install cmake

   35  yum install -y ncurses-devel

   36  cmake -DWITH_BUNDLED_SSL=off .


   37  yum info openssl

   38  cd /usr/src

   39  wget https://www.openssl.org/source/openssl-1.0.2-latest.tar.gz

   40  tar -zxf openssl-1.0.2-latest.tar.gz

   44  cd openssl-1.0.2m

   46  ./config

   47  make

   48  make test

   49  make install

   50  mv /usr/bin/openssl /root/

   51  ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl

   52  openssl version


이 블로그 참고


   58  cd h2o

   59  cmake -DWITH_BUNDLED_SSL=off .


cmake -DWITH_BUNDLED_SSL=off .

-- Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the system variable OPENSSL_ROOT_DIR (missing:  OPENSSL_LIBRARIES OPENSSL_INCLUDE_DIR) 

CMake Error at CMakeLists.txt:94 (MESSAGE):

  OpenSSL not found (nor H2O was configured to used the bundled libressl)



-- Configuring incomplete, errors occurred!

See also "/root/h2o/CMakeFiles/CMakeOutput.log".

See also "/root/h2o/CMakeFiles/CMakeError.log".


   62  yum install openssl-devel     ( 스택오버플로우 참고)

   63  cmake -DWITH_BUNDLED_SSL=off .