大多數與 安裝PHP7 一樣,只有這部分有些區別!
[TOC]
## 編譯安裝php5.6.40
### 1.下載php5源碼包
```
$ cd /root & wget -O php5.tar.gz http://cn2.php.net/get/php-5.6.40.tar.gz/from/this/mirror
```
### 2.解壓源碼包
```
$ tar -xvf php5.tar.gz
```
### 3.進入目錄
```
$ cd php-5.6.40
```
### 4.安裝php依賴包
```
$ yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
```
### 5.編譯配置,這一步我們會遇到很多`configure error`,我們一一解決,基本都是相關軟件開發包沒有安裝導致
```
$ ./configure \
--prefix=/usr/local/php \
--with-config-file-path=/etc \
--enable-fpm \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-soap \
--with-libxml-dir \
--with-xmlrpc \
--with-openssl \
--with-mcrypt \
--with-mhash \
--with-pcre-regex \
--with-sqlite3 \
--with-zlib \
--enable-bcmath \
--with-iconv \
--with-bz2 \
--enable-calendar \
--with-curl \
--with-cdb \
--enable-dom \
--enable-exif \
--enable-fileinfo \
--enable-filter \
--with-pcre-dir \
--enable-ftp \
--with-gd \
--with-openssl-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--enable-gd-native-ttf \
--enable-gd-jis-conv \
--with-gettext \
--with-gmp \
--with-mhash \
--enable-json \
--enable-mbstring \
--enable-mbregex \
--enable-mbregex-backtrack \
--with-libmbfl \
--with-onig \
--enable-pdo \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-zlib-dir \
--with-pdo-sqlite \
--with-readline \
--enable-session \
--enable-shmop \
--enable-simplexml \
--enable-sockets \
--enable-sysvmsg \
--enable-sysvsem \
--enable-sysvshm \
--enable-wddx \
--with-libxml-dir \
--with-xsl \
--enable-zip \
--enable-mysqlnd-compression-support \
--with-pear \
--enable-opcache
```
安裝完成如圖:

### 6.編譯與安裝
```
$ make && make install
```
這里要make好久,要耐心一下,結果如下:
```
Build complete.
Don't forget to run 'make test'.
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
Installing PHP CLI binary: /usr/local/php/bin/
Installing PHP CLI man page: /usr/local/php/php/man/man1/
Installing PHP FPM binary: /usr/local/php/sbin/
Installing PHP FPM config: /usr/local/php/etc/
Installing PHP FPM man page: /usr/local/php/php/man/man8/
Installing PHP FPM status page: /usr/local/php/php/php/fpm/
Installing PHP CGI binary: /usr/local/php/bin/
Installing PHP CGI man page: /usr/local/php/php/man/man1/
Installing build environment: /usr/local/php/lib/php/build/
Installing header files: /usr/local/php/include/php/
Installing helper programs: /usr/local/php/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php/php/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php/lib/php/
[PEAR] Archive_Tar - installed: 1.4.4
[PEAR] Console_Getopt - installed: 1.4.1
[PEAR] Structures_Graph- installed: 1.1.1
[PEAR] XML_Util - installed: 1.4.3
[PEAR] PEAR - installed: 1.10.7
Wrote PEAR system config file at: /usr/local/php/etc/pear.conf
You may want to add: /usr/local/php/lib/php to your php.ini include_path
/root/php-5.6.40/build/shtool install -c ext/phar/phar.phar /usr/local/php/bin
ln -s -f phar.phar /usr/local/php/bin/phar
Installing PDO headers: /usr/local/php/include/php/ext/pdo/
```
### 7.添加 `PHP` 命令到環境變量
```
$ vim /etc/profile
```
在末尾加入
```
PATH=$PATH:/usr/local/php/bin
export PATH
```
要使改動立即生效執行
```
$ source /etc/profile
```
查看環境變量
```
$ echo $PATH
```
查看php版本
```
$ php -v
```
操作如圖:

### 8.配置`php-fpm`
```
$ cp /root/php-5.6.40/php.ini-production /etc/php.ini
$ cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
$ cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf
$ cp /root/php-5.6.40/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
$ chmod +x /etc/init.d/php-fpm
```
### 9.啟動`php-fpm`
```
$ /etc/init.d/php-fpm start
```
### 10.修改conf文件為自己的
例如:我們做一個網址,網址為 www.fanying.cn ,目錄是 /var/www/www_fanying
```
cp /etc/nginx/conf.d/default.conf /etc/nginx/init.d/fanying.conf
```
原先的 default.conf 是這樣的子
```
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
```
修改后是這樣子的
```
server {
listen 80;
server_name www.fanying.cn fanying.cn;
root /var/www/www_fangying;
index index.php
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
#location / {
# root /usr/share/nginx/html;
# index index.html index.htm;
#}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
```
簡寫形式
```
server {
listen 80;
server_name localhost
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
}
```
修改為:
```
server {
listen 80;
server_name www.fanying.cn fanying.cn;
root /var/www/www_fangying;
index index.php
#location / {
# root /usr/share/nginx/html;
# index index.html index.htm;
#}
location ~ \.php$ {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
```
- centos
- 安裝工具
- 安裝nginx
- 安裝PHP5
- 安裝PHP7.0.1
- 安裝PHP7.0.8
- 安裝redis
- redis允許遠程訪問
- 安裝php之redis擴展
- 安裝mysql
- 配置nginx虛擬機綁定域名
- xdebug下載配置
- phpStorm遠程調試配置
- 報錯解決:安裝PHP7解決問題方法
- 報錯解決:xdebug-解決問題
- yum丟失的解決辦法
- CentOS下安裝JDK的四種方法
- workman
- 某服務器配置情況
- 安裝PHP7.2.17
- 安裝PHP7.1.27
- 安裝MongoDB
- ubuntu
- mac
- window
- phpstrom+wamp+xdebug
- mysql
- MySql創建本地用戶和遠程用戶 并賦予權限
- 自建主從復制-mycat
- 數據庫優化
- 阿里云mysql主從復制
- 報錯解決
- SQL分析
- group by
- Mysql定時備份數據腳本
- MySQL數據庫遠程連接開啟方法
- 啟動報錯systemctl status
- 日志導出
- mysq進程
- mysql查詢正在執行的進程
- 命令
- nginx
- 安裝GIT
- access.log
- error.log分析
- 500 Internal Server Error錯誤
- 502解決方案
- 405 Not Allowed,nginx靜態文件響應post請求
- Linux基本操作
- 創建用戶
- chmod命令詳細用法設置文件的權限
- chown命令
- chgrp命令:改變文件的群組
- Linux 設置定時任務crontab命令
- 其他問題
- Win10 Subsystem Linux : Ubuntu 的root密碼
- 安全問題
- PHP安全設置
- redis
- 安裝
- 安裝2.8.17
- 問題
- 日志分析
- an upstream response is buffered to a temporary file
- too many open files
- worker_connections are not enough
- recv() failed
- 日志
- 系統日志
- apache訪問日志與錯誤日志
- nginx訪問日志與錯誤日志
- php錯誤日志
- php-fpm慢日志
- mysql慢日志
- 服務器優化
- php-fpm進程數優化
- 服務器安全
- RHSA-2018:2748: kernel security and bug fix update
- RHSA-2018:3408: git security update
- RHSA-2018:2570: bind security update
- RHSA-2018:3052: wget security and bug fix update
- RHSA-2018:3221: openssl security, bug fix, and enhancement update
- RHSA-2018:2384: kernel security and bug fix update
- RHSA-2018:3032: binutils security, bug fix, and enhancement update
- RHSA-2018:3157: curl and nss-pem security and bug fix update
- RHSA-2018:2285: yum-utils security update
- RHSA-2018:3092: glibc security, bug fix, and enhancement update
- CVE-2018-17182 on Ubuntu 14.04 LTS (trusty)
- CVE-2018-9415 on Ubuntu 14.04 LTS (trusty)
- CVE-2018-8043 on Ubuntu 14.04 LTS (trusty)
- CVE-2018-3620 on Ubuntu 14.04 LTS (trusty)
- CVE-2018-14634 on Ubuntu 14.04 LTS (trusty)
- CVE-2018-14609 on Ubuntu 14.04 LTS (trusty)
- CentOS Linux 7安全基線檢查
- Redis安全基線檢查
- RHSA-2019:1168-重要: 內核 安全更新
- RHSA-2019:1481-重要: 內核 安全更新
- RHSA-2019:0512-重要: 內核 安全和BUG修復更新
- ThinkPHP漏洞
- ThinkPHP 5.1.X <= 5.1.30 遠程代碼執行漏洞
- ThinkPHP 5 <=5.0.22 遠程代碼執行高危漏洞
- ThinkPHP <5.0.24 Request.php 遠程代碼執行漏洞
- PHP
- 怎樣獲取PHP各種版本
- 攻擊
- SSH暴力破解
- RDP暴力破解
- SQLSERVER暴力破解
- MYSQL暴力破解
- FTP暴力破解
- SQL注入
- 代碼執行
- XSS攻擊
- 本地文件包含
- 遠程文件包含
- 腳本木馬
- 上傳漏洞
- 路徑遍歷
- 越權訪問
- CSRF
- CRLF
- 其他