LAMP (linux+apache(httpd)+mysql+php 簡稱爲LAMP(LAMP指的Linux(操做系統)、Apache HTTP 服務器,MySQL(有時也指MariaDB,數據庫軟件) 和PHP(有時也是指Perl或Python) 的第一個字母,通常用來創建web應用平臺。)
三個角色能夠裝在不一樣的服務器上可是apache+php 必須在一臺服務器上
LAMP三者工做思路:
第一種是動態訪問:首先用戶登陸用戶名訪問apache(httpd),apache須要通過php的module(模塊)在mysql中讀取相應的用戶名與密碼。(mysql中是不存在任何的圖片,與文件的。存的內容是數據如,用戶名對應的密碼。)
第二種是靜態訪問:用戶登陸一個網站後,能夠看到的圖片就是靜態的訪問。(直接從服務器獲取到的內容不通過mysql的是靜態訪問)php
MySQL官網 https://www.mysql.com
Mariadb官網 https://mariadb.com/html
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內部測試版本
Mariadb5.5版本對應MySQL的5.5,10.0對應MySQL5.6mysql
mysql的幾個經常使用的安裝方式:rpm(不能定義安裝的路徑)、源碼、二進制免編譯(能定義安裝的路徑這是與rpm的不一樣之一)
這裏選擇二進制方式進行安裝, 由於二進制包只需解壓便可,不須要執行cmake/configure,manke,make install等過程,而後進行簡單配置後就可使用了linux
[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用戶web
[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
如上介紹了mysql的安裝方法,以下是mariadb的安裝方法,思路都是同樣的。sql
[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 (此文檔能夠查思路)
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 設置開機自啓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)
php 官網 http://www.php.netbootstrap
[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 <evp.h> 解決方法:[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=<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=<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線上的環境中運行)
[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的版本根據本身的需求看着裝便可,我是由於要作實驗就都安裝了而已。
小提示:如上的操做是基於centos7操做系統。vim