LAMPの紹介と基本的なインストール


1、LAMPアーキテクチャの紹介
LAMP(linux+apache(httpd)+mysql+php略称はLAMP(LAMP指のLinux(オペレーティングシステム)、Apache HTTPサーバ、MySQL(MariaDB、データベースソフトウェアも指す場合もある)とPHP(PerlまたはPythonも指す場合もある)の最初のアルファベットで、一般的にwebアプリケーションプラットフォームを構築するために使用される.)3つのロールは異なるサーバにインストールできますが、apache+phpは1台のサーバ上でLAMPの3つの作業構想でなければなりません.1つ目は動的アクセスです.まず、ユーザーがユーザー名を登録してapache(httpd)にアクセスし、apacheはphpのmodule(モジュール)を経てmysqlで対応するユーザー名とパスワードを読み取る必要があります.(mysqlには画像は一切存在しません.ファイルです.保存されている内容は、ユーザー名などのパスワードです.)2つ目は静的アクセスです.ユーザーがウェブサイトにログインすると、見える画像が静的アクセスになります.(サーバから直接取得したコンテンツはmysqlを経由しない静的アクセス)
2、MySQL_MariaDB紹介
MySQL公式サイトhttps://www.mysql.comMariadb公式サイトhttps://mariadb.com/
MySQLは関係型データベースで、mysql ab社が開発し、mysqlは2008年にsun社に買収され(10億刀)、2009年にsun社がoracle社に買収され(74億刀)MariadbはMySQLの支店であり、MariaDBは主にSkySQL社(現在はMariaDB社と改称)が維持し、SkySQL社はMySQLの原作者が大部分の元クラスの人馬を率いて創立した.Communityコミュニティバージョン(オープンソースバージョン)、Enterpriseエンタープライズバージョン、GA(GenerallyAvailable)とは、汎用バージョンが生産環境で使用されるDMR(Development Milestone Release)開発マイルストーンリリースバージョン、RC(Release Candidate)リリース候補バージョン、Betaオープンテストバージョン、Alpha内部テストバージョンMariadb 5を指す.5バージョンはMySQLの5.5に対応し、10.0はMySQL 5に対応する.6
3、MySQLインストール(まとめ)
mysqlのいくつかの一般的なインストール方法:rpm(インストールのパスを定義できない)、ソースコード、バイナリフリーコンパイル(インストールのパスを定義できるrpmとは異なる)ここでバイナリ方式を選択してインストールします.バイナリパッケージは解凍するだけでいいので、cmake/configure、manke、make installなどのプロセスを実行する必要はありません.簡単な構成でご利用いただけます
[root@chy01 src]# uname -a
Linux chy01 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
(    linux   32  64    mysql )
[root@chy01 src]# wget http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz  
(     mysql )
[root@chy01 src]# tar zxvf mysql-5.6.35-linux-glibc2.5-x86_64.tar.gz 
(  mysql )
[root@chy01 src]# mv mysql-5.6.35-linux-glibc2.5-x86_64 /usr/local/mysql (  mysql /usr/local/mysql )
[root@chy01 src]# cd /usr/local/mysql/ (      )
[root@chy01 mysql]# ls (       )
bin      data  include  man         README   share      support-files
COPYING  docs  lib      mysql-test  scripts  sql-bench
[root@chy01 mysql]# useradd -s /sbin/nologin -M mysql  (  mysql  )
[root@chy01 mysql]# mkdir -p /data/mysql
(  data  ,           )
[root@chy01 mysql]# useradd mysql (  mysql  )
[root@chy01 mysql]#  chown -R mysql /data/mysql    mysql     
[root@chy01 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
FATAL ERROR: please install the following Perl modules before executing ./scripts/mysql_install_db:
Data::Dumper
(          ,      
[root@chy01 mysql]# yum list |grep perl |grep -i dumper
perl-Data-Dumper.x86_64                 2.145-3.el7                    base     
perl-Data-Dumper-Concise.noarch         2.020-6.el7                    epel     
perl-Data-Dumper-Names.noarch           0.03-17.el7                    epel     
perl-XML-Dumper.noarch                  0.81-17.el7                    base    
(    perl    dumper )
[root@chy01 mysql]# yum install -y perl-Data-Dumper.x86_64 
(  4 dumper          ,    )
[root@chy01 mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql
(                 dumper     )
[root@chy01 mysql]# echo $?
0
(      echo   ,                          )
              (     ok,        )
OK
Filling help tables...2017-07-26 08:23:02 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2017-07-26 08:23:02 0 [Note] Ignoring --secure-file-priv value as server is running with --bootstrap.
2017-07-26 08:23:02 0 [Note] ./bin/mysqld (mysqld 5.6.35) starting as process 4652 ...
2017-07-26 08:23:02 4652 [Note] InnoDB: Using atomics to ref count buffer pool pages
2017-07-26 08:23:02 4652 [Note] InnoDB: The InnoDB memory heap is disabled
2017-07-26 08:23:02 4652 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2017-07-26 08:23:02 4652 [Note] InnoDB: Memory barrier is not used
2017-07-26 08:23:02 4652 [Note] InnoDB: Compressed tables use zlib 1.2.3
2017-07-26 08:23:02 4652 [Note] InnoDB: Using Linux native AIO
2017-07-26 08:23:02 4652 [Note] InnoDB: Using CPU crc32 instructions
2017-07-26 08:23:02 4652 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2017-07-26 08:23:02 4652 [Note] InnoDB: Completed initialization of buffer pool
2017-07-26 08:23:02 4652 [Note] InnoDB: Highest supported file format is Barracuda.
2017-07-26 08:23:02 4652 [Note] InnoDB: 128 rollback segment(s) are active.
2017-07-26 08:23:02 4652 [Note] InnoDB: Waiting for purge to start
2017-07-26 08:23:02 4652 [Note] InnoDB: 5.6.35 started; log sequence number 1625977
2017-07-26 08:23:02 4652 [Note] Binlog end
2017-07-26 08:23:02 4652 [Note] InnoDB: FTS optimize thread exiting.
2017-07-26 08:23:02 4652 [Note] InnoDB: Starting shutdown...
2017-07-26 08:23:04 4652 [Note] InnoDB: Shutdown completed; log sequence number 1625987
OK
[root@chy01 mysql]# ls support-files/my-default.cnf 
support-files/my-default.cnf
(   mysql       )
[root@chy01 mysql]# cat /etc/my.cnf
(mysql       /etc/my.cnf,                   )
[root@chy01 mysql]# rpm -qf /etc/my.cnf
mariadb-libs-5.5.52-1.el7.x86_64
(         mysq rpm   )
[root@chy01 mysql]# cp support-files/my-default.cnf  /etc/my.cnf 
cp:    "/etc/my.cnf"? y
(  cp mysql     /etc/my.cnf )
[root@chy01 mysql]# cp support-files/mysql.server /etc/init.d/mysqld
(cp support-files/mysql.server   /etc/init.d/mysqld(          )
[root@chy01 mysql]# vi /etc/init.d/mysqld  (        )
basedir=/usr/local/mysql(   mysql    )
datadir=/data/mysql(  mysql      )
[root@chy01 mysql]# ls -l /etc/init.d/mysqld 
-rwxr-xr-x 1 root root 10902 7   26 08:40 /etc/init.d/mysqld (       755)
[root@chy01 mysql]# chkconfig --add mysqld(         )
[root@chy01 mysql]# chkconfig --list
  :         SysV   ,       systemd   。SysV           systemd     。 
             systemd   ,    'systemctl list-unit-files'。
             target         
      'systemctl list-dependencies [target]'。
mysqld          0:  1:  2:  3:  4:  5:  6: 
[root@chy01 mysql]# /etc/init.d/mysqld start
Starting MySQL.Logging to '/data/mysql/chy01.err'.
. SUCCESS! (  mysql     )
[root@chy01 mysql]# service mysqld start 
Starting MySQL. SUCCESS! 
(  mysql     )
[root@chy01 mysql]# /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql & 
(         )
[root@chy01 mysql]# ps -aux |grep mysql
root       5570  0.0  0.1 113256  1584 pts/0    S    08:50   0:00 /bin/sh /usr/local/mysql/bin/mysqld_safe --defaults-file=/etc/my.cnf --user=mysql --datadir=/data/mysql
mysql      5673  0.2 29.7 973048 455708 pts/0   Sl   08:50   0:00 /usr/local/mysql/bin/mysqld --defaults-file=/etc/my.cnf --basedir=/usr/local/mysql --datadir=/data/mysql --plugin-dir=/usr/local/mysql/lib/plugin --user=mysql --log-error=/data/mysql/chy01.err --pid-file=/data/mysql/chy01.pid
root       5721  0.0  0.0 112664   976 pts/0    R+   08:53   0:00 grep --color=auto mysql
[root@chy01 mysql]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2053/sshd           
tcp        0      0 127.0.0.1:25            0.0.0.0:*               LISTEN      2875/master         
tcp6       0      0 :::3306                 :::*                    LISTEN      5673/mysqld         
tcp6       0      0 :::22                   :::*                    LISTEN      2053/sshd           
tcp6       0      0 ::1:25                  :::*                    LISTEN      2875/master        
(    )
[root@chy01 mysql]# killall mysqld
(           )

mysqlユーザーへのログイン
[root@chy01 mysql]# echo  'export  PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile  (   mysql     ,            mysq  )
[root@chy01 mysql]# tail -n1 /etc/profile(           )
export  PATH=/usr/local/mysql/bin:$PATH
[root@chy01 mysql]# source /etc/profile
[root@chy01 mysql]# mysql -uroot ( root        )
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.6.35 MySQL Community Server (GPL)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> quit
Bye

4、MariaDB取付
以上mysqlのインストール方法を紹介しましたが、以下はmariadbのインストール方法で、考え方は同じです.
[root@chy01 src]# cd /usr/local/src
(   cd /usr/local/src   )
[root@chy src]#  wget https://downloads.mariadb.com/MariaDB/mariadb-10.2.6/bintar-linux-glibc_214-x86_64/mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
( mariadb   /src   )
[root@chy src]# tar zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz 
(    /src   )
[root@chy src]# mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb (  mariadb      )
[root@chy src]# cd !$
cd /usr/local/mariadb
(   mariadb   )
[root@chy mariadb]# useradd -s /sbin/nologin -M mysql1 (  mysql1       mysql1    )
[root@chy mariadb]# mkdir -p /data/mariadb (  mariadb    /data/)
[root@chy mariadb]# chown -R mysql1 /data/mariadb (  /data    mysql1)
[root@chy mariadb]# ./scripts/mysql_install_db --user=mysql1 --basedir=/usr/local/mariadb/ --datadir=/data/mariadb
(   mariadb,               --basedir   basedir   datadir                   mysql,         datadir,               )
[root@chy mariadb]# echo $?
0
(          )
[root@chy mariadb]# ./scripts/mysql_install_db --user=mysql1 --basedir=/usr/local/mariadb/ --datadir=/data/mariadb
Installing MariaDB/MySQL system tables in '/data/mariadb' ...
OK
(              OK  ,     )
[root@chy mariadb]# ls support-files/
binary-configure        my-large.cnf            mysql-log-rotate        wsrep_notify
magic                   my-medium.cnf           mysql.server            
my-huge.cnf             my-small.cnf            policy/                 
my-innodb-heavy-4G.cnf  mysqld_multi.server     wsrep.cnf       
(   mariadb      mysql            。 mariadb                      )
[root@chy mariadb]# cp support-files/my-small.cnf /usr/local/mariadb/my.cnf 
(            /usr/local/mariadb/my.cnf (           my.cnf   mysql                cp my.cnf       cp /usr/local/mariadb      my.cnf)
[root@chy mariadb]# cp support-files/mysql.server /etc/init.d/mariadb
(         /etc/init.d/mariadb   )
[root@chy mariadb]# vim /usr/local/mariadb/my.cnf  (               )
[root@chy mariadb]# vim /etc/init.d/mariadb 
(  mariadb     ,    )
basedir=/usr/local/mariadb
datadir=/data/mariadb
conf=$basedir/my.cnf
(       ,                     )
case "$mode" in
  'start')
    # Start daemon

    # Safeguard (relative paths, core dumps..)
    cd $basedir

    echo $echo_n "Starting MySQL"
    if test -x $bindir/mysqld_safe
    then
      # Give extra arguments to mysqld with the my.cnf file. This script
      # may be overwritten at next upgrade.
      $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" &
      wait_for_ready; return_value=$?
(        $bindir/mysqld_safe  --datadir="$datadir"      --defaults-file="$conf")
$bindir/mysqld_safe  --defaults-file="$conf" --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" &
(              )
       :
[root@chy ~]# /etc/init.d/mariadb start 
Starting mariadb (via systemctl):  Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details.
                                                           [  ]
       :
 [root@chy mariadb]# vim /etc/my.cnf
   [mysqld]
port            = 3306
socket          = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 240K
user=mysql1(            mysql1)

     :http://www.debugrun.com/a/o5rqKfE.html  (        )

5、apache取付総括
Apache公式サイトhttp://www.apache.org
[root@chy src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.26.tar.gz
[root@chy src]#  wget http://mirrors.hust.edu.cn/apache/apr/apr-1.5.2.tar.gz
[root@chy src]#  wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.5.4.tar.gz
(  3  ,       qpr  apr-util,     :apache 2.2 2.4        ,    :2.4    apr apr-util   , 2.2         )
apr apr-util         ,  httpd              ,        ( linux   windows)
)
[root@chy src]# tar zxvf httpd-2.4.26.tar.gz
[root@chy src]#  tar zxvf apr-util-1.5.4.tar.gz
[root@chy src]#  tar zxvf apr-1.5.2.tar.gz
(     )
[root@chy src]# cd apr-1.5.2/
(    apr)
[root@chy apr-1.5.2]# ./configure --prefix=/usr/local/apr
[root@chy apr-1.5.2]# echo $?
0
[root@chy apr-1.5.2]# make && make install
[root@chy apr-1.5.2]# echo $?
0
[root@chy apr-1.5.2]# cd /usr/local/src/apr-util-1.5.4
(    util)
[root@chy apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
(    )
[root@chy apr-util-1.5.4]# echo $?
0
[root@chy apr-util-1.5.4]# make && make install
[root@chy apr-util-1.5.4]# echo $?
0(    )
[root@chy apr-util-1.5.4]# cd /usr/local/src/httpd-2.4.26
(      httpd)
[root@chy httpd-2.4.26]#./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
(        checking for pcre-config... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/)
[root@chy httpd-2.4.26]# yum list |grep pcre 
pcre.x86_64                                8.32-15.el7_2.1             @anaconda
pcre.i686                                  8.32-15.el7_2.1             base     
pcre-devel.i686                            8.32-15.el7_2.1             base     
pcre-devel.x86_64                          8.32-15.el7_2.1             base     
pcre-static.i686                           8.32-15.el7_2.1             base     
pcre-static.x86_64                         8.32-15.el7_2.1             base     
pcre-tools.x86_64                          8.32-15.el7_2.1             base    
(    pcre     ,pcre-devel         )
[root@chy httpd-2.4.26]# ./configure --prefix=/usr/local/apache2.4 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-so --enable-mods-shared=most
(     ,      )
[root@chy httpd-2.4.26]# echo $?
0
(    )
[root@chy httpd-2.4.26]# make && make install
[root@chy httpd-2.4.26]# echo $?
0
(    )
[root@chy httpd-2.4.26]# /usr/local/apache2.4/bin/httpd -M =[root@chy apache2.4]# /usr/local/apache2.4/bin/apachectl -M
(  apache     )
[root@chy httpd-2.4.26]# /usr/local/apache2.4/bin/apachectl start
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using fe80::338e:589c:fa07:65e5. Set the 'ServerName' directive globally to suppress this message
[root@chy httpd-2.4.26]# ps aux |grep httpd
root      42811  0.0  0.1  95476  2532 ?        Ss   15:47   0:00 /usr/local/apache2.4/bin/httpd -k start
daemon    42812  0.0  0.2 382304  4428 ?        Sl   15:47   0:00 /usr/local/apache2.4/bin/httpd -k start
daemon    42813  0.0  0.2 382304  4428 ?        Sl   15:47   0:00 /usr/local/apache2.4/bin/httpd -k start
daemon    42814  0.0  0.2 382304  4428 ?        Sl   15:47   0:00 /usr/local/apache2.4/bin/httpd -k start
root      42897  0.0  0.0 112664   972 pts/0    R+   15:48   0:00 grep --color=auto httpd
(    ,    )
      :
./configure \   //           ,                
--prefix=/usr/local/apache2.4 \(  apache  )
--with-apr=/usr/local/apr \(  apacehe apr)
--with-apr-util=/usr/local/apr-util \(  apache apr-util)
--enable-so \ (           ,      .so   )
--enable-mods-shared=most(          )
[root@chy apache2.4]# ls bin/httpd 
bin/httpd (apache    )
[root@chy apache2.4]# ls conf/
extra  httpd.conf  magic  mime.types  original
(apache    )
[root@chy apache2.4]# ls htdocs/
index.html
(     )
[root@chy apache2.4]# ls logs/
access_log  error_log  httpd.pid
(apache       )
[root@chy apache2.4]# ls modules/
httpd.exp               mod_buffer.so               mod_lbmethod_heartbeat.so  mod_request.so
mod_access_compat.so    mod_cache_disk.so           mod_log_config.so          mod_rewrite.so
mod_actions.so          mod_cache.so                mod_log_debug.so           mod_sed.so
mod_alias.so            mod_cache_socache.so        mod_logio.so               mod_session_cookie.so
(         ,            ,                      /bin/httpd ,       .so   ,    [root@chy apache2.4]# ls /usr/local/apache2.4/modules/
  。

apache電源オン設定
[root@chy ~]# cp /usr/local/apache2.4/bin/apachectl /etc/init.d/apache2
(     apache     cp /etc/inid.d    ,apache2        ,          )
[root@chy ~]# vim /etc/init.d/apache2 
(       )
# chkconfig: 35 20 80
#description: Apache2
(       ,      3         :         apache(3,5);    (S20);    (K80)。
3 5                          apache
20                    ,             ,    
80          ,         80   
  : 2     ,#     ,    )
[root@chy ~]# chkconfig --add apache2 (       ,   apache2     /etc/init.d/apache2     )
[root@chy ~]# netstat -antp |grep 80
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      1980/sshd           
tcp6       0      0 :::80                   :::*                    LISTEN      2596/httpd          
tcp6       0      0 :::22                   :::*                    LISTEN      1980/sshd    
(         httpd)

6インストールphp 5まとめ
php公式サイトhttp://www.php.net
[root@chy src]# wget http://cn2.php.net/distributions/php-5.6.30.tar.gz
(  php )
[root@chy src]# tar zxvf php-5.6.30.tar.gz 
(  php )
[root@chy src]# cd php-5.6.30
(   Php)
[root@chy php-5.6.30]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc  --with-mysql=/usr/local/mariadb --with-pdo-mysql=/usr/local/mariadb --with-mysqli=/usr/local/mariadb/bin/mariadb_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
(           ,checking for RAND_egd... no
checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's 
    :[root@chy php-5.6.30]# yum install -y openssl-devel.x86_64   
     checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
    :[root@chy php-5.6.30]# yum install -y bzip2-devel.x86_64 
     hecking whether to enable JIS-mapped Japanese font support in GD... no
If configure fails try --with-vpx-dir=
configure: error: jpeglib.h not found.
    :[root@chy php-5.6.30]# yum install -y libjpeg-devel
     :If configure fails try --with-xpm-dir=
configure: error: freetype-config not found.
    :[root@chy php-5.6.30]# yum install -y freetype-devel.x86_64 
)
     :checking for mcrypt support... yes
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
    :[root@chy php-5.6.30]# yum install epel-release
     :[root@chy php-5.6.30]# yum install libmcrypt
[root@chy php-5.6.30]# yum install libmcrypt-devel
(      )
     :configure: error: Cannot find libmysqlclient_r under /usr/local/mariadb.
Note that the MySQL client library is not bundled anymore!
    :
[root@chy php-5.6.30]# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php/etc   --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
(     ,  --with-mysql=/usr/local/mariadb --with-pdo-mysql=/usr/local/mariadb --with-mysqli=/usr/local/mariadb/bin/mariadb_config (      )
[root@chy php-5.6.30]# make && make install  (make  make install)
[root@chy php-5.6.30]# echo $?
0
(    )
[root@chy php-5.6.30]# cp php.ini-production  /usr/local/php/etc/php.ini
(  cp      /etc/php.ini  )
[root@chy php-5.6.30]# ls /usr/local/php/
bin  etc  include  lib  php
(php     )
[root@chy php-5.6.30]# ls /usr/local/php/bin/
pear  peardev  pecl  phar  phar.phar  php  php-cgi  php-config  phpize
(php     )
[root@chy php-5.6.30]# du -sh /usr/local/apache2.4/modules/libphp5.so 
36M /usr/local/apache2.4/modules/libphp5.so
(    php apache     )
[root@chy php-5.6.30]# /usr/local/php/bin/php -m
(  php   )
[root@chy php-5.6.30]# cp php
php5.spec            php5.spec.in         php.gif              php.ini-development  php.ini-production
(php.ini-development  php.ini-production          php.ini-development          ,php.ini-production        )

7、apache7
[root@chy src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2
[root@chy src]# tar jxf php-7.1.6.tar.bz2 
(   )
[root@chy src]# cd php-7.1.6
[root@chy php-7.1.6]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-mariadb=/usr/local/mariadb --with-mariadbi=/usr/local/mariadb/bin/mariadb_config  --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif
   make && make install 

mysqlとphpのバージョンは自分のニーズに合わせて服装を見ればいいです.私は実験をするためにインストールしただけです.ヒント:上記の操作はcentos 7オペレーティングシステムに基づいています.