CentOS 7 php 5.6

回覆文章
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

CentOS 7 php 5.6

文章 yehlu »

https://webtatic.com/packages/php56/

PHP 5.6 on CentOS/RHEL 7.2 and 6.8 via Yum

PHP 5.6.25 has been released on PHP.net on 19th August 2016, and is also available for CentOS/RHEL 6.8 and 7.2 at Webtatic via Yum.

Update 2015-08-22 – Webtatic now has released PHP 7 RC1 for CentOS/RHEL 6 and 7


PHP 5.6 adds new features such as:

constant scalar expressions
variadic functions
argument unpacking
exponentiation operator
support for large(>2GiB) file uploads
SSL/TLS improvements including peer verification by default
a new command line debugger called phpdbg
To see what else has been added, check out the Migrating from PHP 5.5.x to PHP 5.6.x.

To install, first you must add the Webtatic EL yum repository information corresponding to your CentOS/RHEL version to yum:

CentOS/RHEL 7.x:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/e ... noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/web ... elease.rpm
CentOS/RHEL 6.x:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/e ... noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm
Now you can install PHP 5.6’s mod_php SAPI (along with an opcode cache) by doing:

yum install php56w php56w-opcache
You can alternatively install PHP 5.6’s php-fpm SAPI (along with an opcode cache by doing:

yum install php56w-fpm php56w-opcache
See the package list below for additional SAPIs and PHP extensions.

If you would like to upgrade php to this version it is recommended that you first check that your system will support the upgrade, e.g. making sure any CPanel-like software can run after the upgrade.

Unless you know what you are doing, it is risky upgrading an existing system. It’s much safer to do this by provisioning a separate server to perform the upgrade as a fresh install instead.

If you know what you are doing, you can upgrade PHP by:

yum install yum-plugin-replace

yum replace php-common --replace-with=php56w-common
It will likely give you a message “WARNING: Unable to resolve all providers …”. This is normal, and you can continue by tying “y“. You will be given a chance to see what packages will be installed and removed before again being given a chance to confirm.

SAPIs – different runtime environments of PHP

mod_php NTS
(non-thread safety) Contained in the php56w package, this SAPI integrates into Apache Httpd (2.2.* on RHEL/CentOS 6, 2.4.* on RHEL/CentOS 7). It is the standard SAPI for use with httpd prefork mpm (the default mode httpd is ran under. It is not thread-safe, but doesn’t need to be due to prefork not using threads. It’s located at /usr/lib[64]/httpd/modules/libphp5.so
cli
Contained in the php56w-cli package, this SAPI allows running scripts from the command-line, and also has a built-in web server for development-use. Located at /usr/bin/php
fpm
Contained in the php56w-fpm package, fpm (FastCGI Process Manager) is a scalable FastCGI process, which acts similar to how Httpd prefork mpm works managing it’s forks. Located at /usr/sbin/php-fpm, it is controlled using the /etc/init.d/php-fpm service script
phpdbg
Contained in the php56w-phpdbg package, phpdbg has the ability to debug scripts using breakpoints from the command-line, and also supports remote-debugging using an external Java client for remote communication.
embedded
Contained in the php56w-embedded package, this SAPI allows embedding PHP in other applications. It’s library is located at /usr/lib[64]/libphp5.so
cgi, fastcgi
Contained in the php56w-cli package, these SAPIs are not recommended for use, but are available where needed. They both exist in the binary at /usr/bin/php-cgi.
mod_php TS
(thread safety) Contained in the php56w package, this SAPI integrates into Apache Httpd (2.2.* on RHEL/CentOS 6, 2.4.* on RHEL/CentOS 7). It is the standard SAPI for use with httpd worker mpm. It’s supposed to be thread-safe, but can’t guarantee to be, and certainly not under additional PHP extensions. It’s better to use FastCGI SAPIs than this one. It’s located at /usr/lib[64]/httpd/modules/libphp5-zts.so
Packages

Package Provides
php56w mod_php, php56w-zts
php56w-bcmath
php56w-cli php-cgi, php-pcntl, php-readline
php56w-common php-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-ereg, php-exif, php-fileinfo, php-filter, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml, php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib
php56w-dba
php56w-devel
php56w-embedded php-embedded-devel
php56w-enchant
php56w-fpm
php56w-gd
php56w-imap
php56w-interbase php_database, php-firebird
php56w-intl
php56w-ldap
php56w-mbstring
php56w-mcrypt
php56w-mssql
php56w-mysql php-mysqli, php_database
php56w-mysqlnd php-mysqli, php_database
php56w-odbc php-pdo_odbc, php_database
php56w-opcache php56w-pecl-zendopcache
php56w-pdo php56w-pdo_sqlite, php56w-sqlite3
php56w-pear
php56w-pecl-apcu
php56w-pecl-gearman
php56w-pecl-geoip
php56w-pecl-imagick
php56w-pecl-memcache
php56w-pecl-xdebug
php56w-pgsql php-pdo_pgsql, php_database
php56w-phpdbg
php56w-process php-posix, php-sysvmsg, php-sysvsem, php-sysvshm
php56w-pspell
php56w-recode
php56w-snmp
php56w-soap
php56w-tidy
php56w-xml php-dom, php-domxml, php-wddx, php-xsl
php56w-xmlrpc
Opcode Caches

The PHP distribution now comes with an opcode cache. This is the Zend Optimizer+ opcode cache, now known as the Zend OPcache extension. This extension is optional, so does not preclude you from using an alternate one.

Due to it being included in the PHP source distribution, it will be well maintained and more suitable for use while other Opcode cache’s are being updated over the coming months.

yum install php56w-opcache
error_reporting E_ALL now includes E_STRICT

As mentioned in the PHP 5.4 guide:

You may get a lot more errors coming out of your error logs if by default your error_reporting is set to E_ALL now without explicitly turning off E_STRICT. The default php.ini that comes with the PHP package turns this off by default, but if you are upgrading from an existing installation, your php.ini may not be updated, meaning this will likely be turned on.
yehlu
Site Admin
文章: 3245
註冊時間: 2004-04-15 17:20:21
來自: CodeCharge Support Engineer

Re: CentOS 7 php 5.6

文章 yehlu »

http://jsnwork.kiiuo.com/archives/2118/ ... yadmin-ftp

Skip to content
jsnWork
偷懶是程設師的美德
CentOS 7 安裝 Apache + PHP 7 + MySQL + phpMyAdmin + FTP
安裝 EPEL
這款套件管理提供各種企業級的 Linux 一些額外的高品質套件 (參考)

1
2
3
4

rpm -Uvh https://dl.fedoraproject.org/pub/epel/e ... noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/web ... elease.rpm



安裝 MySQL,現在可改為 MariaDB
1
2
3
4
5

yum -y install mariadb-server mariadb
systemctl start mariadb.service
systemctl enable mariadb.service

如果出現這樣的錯誤,那就重開 Linux 吧,比較快…

1
2
3
4
5
6
7

Another app is currently holding the yum lock; waiting for it to exit...
The other application is: PackageKit
Memory : 136 M RSS (1.5 GB VSZ)
Started: Tue Dec 8 01:09:47 2015 - 01:21 ago
State : Uninterruptible, pid: 12947



最後設定 MySQL 安全程序,如 root 是否要設定帳號密碼,會利用詢問回答的方式進行。

1
2
3

mysql_secure_installation



安裝 Apache
1
2
3
4
5
6
7
8

yum -y install httpd
systemctl start httpd.service
systemctl enable httpd.service
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

查看 localhost 就會出現畫面了。讓 Apache 可以支援 .htaccess ,須要把 AllowOverride 的功能開啟。如使用框架 Codeigniter 就須要設定。

1
2
3

vim /etc/httpd/conf/httpd.conf

因為我的網頁預設在

1
2
3

DocumentRoot "/var/www/html"

所以將 None 修改為 All

1
2
3
4
5

<Directory "/var/www/html">
AllowOverride All
</Directory>

重新啟動

1
2
3

systemctl restart httpd.service



安裝 PHP (v7.0)
參考這篇英文教學

1
2
3
4

yum -y install php70w
systemctl restart httpd.service

php 根目錄會在 /var/www/html ,接著調整 PHP 的常用設定

1
2
3

vim /etc/php.ini

參考這篇修改php.ini



讓 MySQL 支援 PHP
1
2
3
4
5
6

yum search php
yum -y install php70w-mysql
yum -y install php70w-pdo php70w-gd php70w-ldap php70w-odbc php70w-pear.noarch php70w-xml php70w-xmlrpc php70w-mbstring php70w-snmp php70w-soap php70w-mcrypt curl curl-devel
systemctl restart httpd.service

這些是可以使用擴充的 PHP 掛件,可使用 『yum -y install 名稱』

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35

php70w
php70w-bcmath
php70w-cli
php70w-common
php70w-dba
php70w-devel
php70w-embedded
php70w-enchant
php70w-fpm
php70w-gd
php70w-imap
php70w-interbase
php70w-intl
php70w-ldap
php70w-mbstring
php70w-mcrypt
php70w-mysql
php70w-mysqlnd
php70w-odbc
php70w-opcache
php70w-pdo
php70w-pdo_dblib
php70w-pear.noarch
php70w-pgsql
php70w-phpdbg
php70w-process
php70w-pspell
php70w-recode
php70w-snmp
php70w-soap
php70w-tidy
php70w-xml
php70w-xmlrpc





安裝 phpMyAdmin
1
2
3
4

yum -y install phpMyAdmin
vim /etc/httpd/conf.d/phpMyAdmin.conf

透過 vi 指令修改,將

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18

#<Directory /usr/share/phpMyAdmin/>
# <IfModule mod_authz_core.c>
# # Apache 2.4
# <RequireAny>
# Require ip 127.0.0.1
# Require ip ::1
# </RequireAny>
# </IfModule>
# <IfModule !mod_authz_core.c>
# # Apache 2.2
# Order Deny,Allow
# Deny from All
# Allow from 127.0.0.1
# Allow from ::1
# </IfModule>
#</Directory>

修改成

1
2
3
4
5
6
7

<Directory /usr/share/phpMyAdmin/>
Options none
AllowOverride Limit
Require all granted
</Directory>

接著再修改

1
2
3

vim /etc/phpMyAdmin/config.inc.php

將 $cfg[‘Servers’][$i][‘auth_type’] 改為使用 http 的方式

1
2
3

$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http or cookie based)?

重新啟動伺服器

1
2
3

systemctl restart httpd.service



建立FTP
1
2
3
4

yum -y install vsftpd
vim /etc/vsftpd/vsftpd.conf

透過 vi 修改為

1
2
3

anonymous_enable=NO

接著下指令

1
2
3
4
5
6

systemctl restart vsftpd
systemctl enable vsftpd
firewall-cmd --permanent --add-port=21/tcp
firewall-cmd --reload

啟動FTP

1
2
3
4
5

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

1
2
3
4
5

firewall-cmd --permanent --add-port=21/tcp
firewall-cmd --permanent --add-service=ftp
firewall-cmd --reload

1
2
3
4

setsebool -P ftp_home_dir 1
setsebool -P ftpd_use_passive_mode 1

1
2
3
4
5

setsebool -P ftpd_anon_write 1
setsebool -P ftpd_full_access 1
setsebool -P httpd_can_network_connect on (要設定這個,才能透過smtp.gmail.com寄信)

1
2
3

service vsftpd restart

接著就可以使用 Linux 原本系統已存在的使用者做登入。但是 root 預設不可登入。

這時 Linux 預設的路徑可以看到整個系統,我們希望做一些限制,例如只能限制在 /var/www/html。

先修改使用者的家目錄
1
2
3

usermod -m -d /var/www 你的使用者名稱

不可離開家目錄
1
2
3

vim /etc/vsftpd/vsftpd.conf


修改以下為開啟
1
2
3
4
5

chroot_local_user=YES 是否要將使用者限制在自己的家目錄之內(chroot)
chroot_list_enable=YES 是否啟用 chroot 寫入列表的功能?與底下的 chroot_list_flie 有關
chroot_list_file=/etc/vsftpd/chroot_list 如果 chroot_list_enable=YES 那麼就可以設定


在檔案中添加『不會被限制在家目錄的使用者』,如果沒有就保持空白
1
2
3

vim /etc/vsftpd/chroot_list


使用者帳號的添加,一行一個。這樣 tom 跟 jason 都不會被限制在家目錄。
1
2
3
4

tom
jason


1
2
3

service vsftpd restart

修改 /var/www/html 擁有人與群組
因為 /var/www/html 預設屬於 root,我們要修改為 FTP 登入的使用者,這樣這個使用者才可以進行上傳、修改、刪除。詳細參考
1
2
3

chown -R jason:jason /var/www/html (chown [-R] 帳號名稱:群組名稱 檔案或目錄)

我目前正在 NU SKIN 代理客製化保養品 ageLOC me。

2016/06/07 預購截止喔,想要了解的朋友快跟我聯絡吧。







分享,才能讓我知道對你有幫助:



Linux - CentOS - 安裝 XAMPP
Linux - CentOS - 安裝 XAMPP
在「Web 程式設計」中
Linux - CentOS - 關閉防火牆
Linux - CentOS - 關閉防火牆
在「Web 程式設計」中
js - RequireJS 避免緩存(cache)方法
設定的地方這樣添加參數 require.config({ urlArgs: "bust=" + (n…
在「Web 程式設計」中
Categorized in: Web 程式設計

2015-12-032016-06-07JSN4 Comments
文章導覽
php – Codeigniter 關於資料庫管理 forge 類別的使用注意
php – Codeigniter – Composer – 使用 Translg 簡單轉換多國語言
4 thoughts on “CentOS 7 安裝 Apache + PHP 7 + MySQL + phpMyAdmin + FTP”
Kathy 說:
2016-05-06 at 16:32
關於完整替代的部分 … 請問MariaDB如何操作使用 ?
phpMyAdmin過去都可以用web的方式管理資料庫 ~
一樣有套件可以抓嗎 ?

回覆
jsn 說:
2016-05-26 at 11:56
基本上操作起來完全跟 MySQL 一樣喔!只是基底核心不一樣,仍然可以透過 phpMyAdmin 操作資料庫喔

回覆
Tai-Shun Huang 說:
2016-05-18 at 10:59
哇 每次搜尋php相關的東西 中文的 都會出現你的網站耶!!!

回覆
jsn 說:
2016-05-26 at 11:55
哈哈哈開心!!!!

回覆
發表迴響

Decode Theme by Macho Themes

搜尋關於:
搜尋 …
搜尋
最新發表
Apache – mod_rewrite 出現 No input file specified.
php – 浮水印,合併兩張圖片
jQuery – 修改在 $.each() 中使用 AJAX 的方式
jQuery – vpage.js 快速切換網址與對應事件
jQuery – 在IE中使用 $(“body") 捲動畫面無法運作的解決辦法
jQuery – 如何在 plugin 套件中,呼叫 callback 時可以使用 $(this)
php – 陣列合併,索引相同而不覆蓋的方法
php – 參數傳入 function 後,自動轉換參數為陣列的方式
jQuery – 按下ESC的觸發
Kolor – KRPano – 手動添加熱點,並觸發外部 JavsScript
也許你想用分類來找文章
Web 程式設計
回覆文章

回到「CentOS」