yum install -y libxml2-devel libtool* curl-devel libjpeg-devel libpng-devel freetype-develphp
2.下載php7源碼包進行編譯安裝html
[root@iZ2zef0e6br88incakir9rZ opt]# wget http://cn2.php.net/distributions/php-7.0.14.tar.gzmysql
[root@iZ2zef0e6br88incakir9rZ opt]# tar xf php-7.0.14.tar.gznginx
[root@iZ2zef0e6br88incakir9rZ opt]# cd php-7.0.14
[root@iZ2zef0e6br88incakir9rZ opt]# ./configure --prefix=/usr/local/php-7.0.14 --enable-fpm --enable-opcache --with-config-file-path=/usr/local/php-7.0.14/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-static --enable-sockets --enable-wddx --enable-zip --enable-calendar --enable-bcmath --enable-soap --with-zlib --with-iconv --with-freetype-dir --with-gd --with-jpeg-dir --with-xmlrpc --enable-mbstring --with-sqlite3 --with-curl --enable-ftp --with-mcrypt --with-openssl --disable-safe-mode --with-gettextsql
報錯:configure: error: mcrypt.h not found. Please reinstall libmcrypt.
解決:下載libmcrypt源碼庫數據庫
wget https://svwh.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gzvim
編譯安裝:
make && make installapi
3.配置文件php.inicookie
[PHP]
engine = On #是否啓用php解析引擎
short_open_tag = On #是否使用簡介標誌
precision = 14 #浮點數中顯示有效數字的位數
output_buffering = 4096 #輸出緩衝區的大小
zlib.output_compression = Off #是否開啓zlib輸出壓縮
implicit_flush = Off #unserialize_callback_func = #serialize_precision = 17 disable_functions = #disable_classes = #zend.enable_gc = On #激活循環引用收集器。
expose_php = On #max_execution_time = 300 #程序執行最大時間,默認爲30s,0表示沒有時間限制,這裏設置300s,能夠自定義設置
max_input_time = 300 memory_limit = 128M error_reporting = E_ALL display_errors = Off display_startup_errors = On php有錯誤出理,就會提示,並且在事件查看器中有記錄。若是設置爲display_startup_errors = Off,則不會有任何提示
log_errors = On log_errors_max_len = 1024 error_log=/data/log/php/error_php7.log 設置錯誤日誌文件保存路徑
ignore_repeated_errors = Off ignore_repeated_source = Off report_memleaks = On track_errors = On html_errors = On variables_order = "GPCS" 此指令描述了PHP註冊GET, POST, Cookie, 環境 和 內置變量的順序 (各自使用G, P, C, E 和 S , 通常使用 EGPCS 或 GPC). 註冊使用從左往右的順序, 新的值會覆蓋舊的值
request_order = "GP" register_argc_argv = Off auto_globals_jit = On post_max_size = 16M auto_prepend_file = auto_append_file = default_mimetype = "text/html"
default_charset = "UTF-8"
doc_root = user_dir = enable_dl = Off file_uploads = On upload_max_filesize = 2M max_file_uploads = 20 allow_url_fopen = On allow_url_include = Off default_socket_timeout = 60 cgi.fix_pathinfo= 1
[CLI Server]
cli_server.color = On
[Date]
date.timezone = Asia/Shanghai 設置區域時間
[Pdo_mysql]
pdo_mysql.cache_size = 2000 pdo_mysql.default_socket= 默認的socket時間
[Phar]
[mail function] 郵件功能
SMTP = localhost smtp_port = 25 mail.add_x_header = On 是否開啓最大的header
[SQL]
sql.safe_mode = Off 對於每一個不一樣數據庫的鏈接函數,其默認值請參考相應的手冊頁面。
[ODBC]
odbc.allow_persistent = On
odbc.check_persistent = On
odbc.max_persistent = -1
odbc.max_links = -1
odbc.defaultlrl = 4096
odbc.defaultbinmode = 1
[Interbase]
ibase.allow_persistent = 1
ibase.max_persistent = -1
ibase.max_links = -1
ibase.timestampformat = "%Y-%m-%d %H:%M:%S"
ibase.dateformat = "%Y-%m-%d"
ibase.timeformat = "%H:%M:%S"
[MySQLi]
mysqli.max_persistent = -1 mysqli.allow_persistent = On mysqli.max_links = -1 mysqli.cache_size = 2000 mysqli.default_port = 3306 mysqli.default_socket = mysqli.default_host = mysqli.default_user = mysqli.default_pw = mysqli.reconnect = Off [mysqlnd]
mysqlnd.collect_statistics = On
mysqlnd.collect_memory_statistics = On
[PostgreSQL]
pgsql.allow_persistent = On pgsql.auto_reset_persistent = Off pgsql.max_persistent = -1 pgsql.max_links = -1 pgsql.ignore_notice = 0 pgsql.log_notice = 0
[bcmath]
bcmath.scale = 0
[Session]
session.save_handler = files session.use_strict_mode = 0
session.use_cookies = 1 session.use_only_cookies = 1 session.name = PHPSESSID session.auto_start = 0 session.cookie_lifetime = 0 session.cookie_path = / session.cookie_domain = cookie的有效域名
session.cookie_httponly = session.serialize_handler = php session.gc_probability = 1 session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.referer_check =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5
url_rewriter.tags = "a=href,area=href,frame=src,input=src,form=fakeentry"
[Assertion]
zend.assertions = 1
[Tidy]
tidy.clean_output = Off
[soap]
soap.wsdl_cache_enabled=1
soap.wsdl_cache_dir="/tmp"
soap.wsdl_cache_ttl=86400
soap.wsdl_cache_limit = 5
[sysvshm]
[ldap]
ldap.max_links = -1
4.進程服務的配置文件php-fpm,把php-fpm引入www.conf文件中的配置
[root@iZ2zef0e6br88incakir9rZ etc]# cat /usr/local/php-7.0.14/etc/php-fpm.conf
include=/usr/local/php-7.0.14/etc/php-fpm.d/*.conf
[root@iZ2zef0e6br88incakir9rZ etc]# vim /usr/local/php-7.0.14/etc/php-fpm.d/www.conf
[global] 全局定義
log_level = notice 錯誤級別. 可用級別爲: alert(必須當即處理), error(錯誤狀況), warning(警告狀況), notice(通常重要信息), debug(調試信息). 默認: notice.
error_log=/data/log/php/error_php-fpm7.log 錯誤日誌文件保存路徑
[www] 定義www的pool
user = www 啓動進程的賬戶
group = www 啓動進程組
listen = 127.0.0.1:9999 fpm監聽端口,即nginx中php處理的地址
pm = dynamic pm的模式,分爲static|dynamic兩種
pm.max_children = 50 子進程最大數
pm.start_servers = 10 啓動時的進程數
pm.min_spare_servers = 10 保證空閒進程數最小值,若是空閒進程小於此值,則建立新的子進程
pm.max_spare_servers = 50 保證空閒進程數最大值,若是空閒進程大於此值,此進行清理
5.複製服務控制腳本php-fpm到系統服務腳本目錄:
cp /opt/php-7.0.14/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm7 && chmod 755 /etc/init.d/php-fpm7
設置php7開啓啓動:
chkconfig --add php-fpm7
chkconfig php-fpm7 on
啓動php:
service php-fpm7 start
6 做者:z寒江雪 出處:http://www.cnblogs.com/wenwei-blog/ 原址:https://www.cnblogs.com/wenwei-blog/p/6261637.html