A. linux centos 7 下用yum 安裝iso鏡像里自帶的php5.4.16版本的但是沒有php-fqm文件不知道怎麼重啟php服務
systemctl restart php-fpm.service #這條命令是重啟php服務
下面是一個比較靠譜的php安裝步驟:
先刪除已有的php版本 ,執行下面的命令刪除php
yum remove php-common
然後像安裝那樣問你是否繼續的,輸入yes即可
添加 yum 源
CentOS 6.x 的源
# rpm -Uvh http://download.Fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
安裝 PHP
# yum install --enablerepo=remi,remi-php56 php php-opcache php-pecl-apcu php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof php-pdo php-pear php-fpm php-cli php-xml php-bcmath php-process php-gd php-common
註:安裝5.6版本為remi-php56,安裝5.5版本為remi-php55
B. 阿里雲上的centos 7.2怎麼yum安裝php 5.6
因之前通過網易的 centos 鏡像,將阿里雲的 centos 升級到最新版了,乘自己的項目尚未開始正式開發,遂將所有的相應環境都升級到最高。
查看 centos 版本:
[root@iZ23d ~]# cat /etc/centos-release
CentOS Linux release 7.2.1511 (Core)
1、刪除之前的 php 版本:
[root@iZ23d ~]# yum remove php* php-common
Loaded plugins: langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
No Match for argument: php-5.4.16
No Match for argument: php-5.4.16.tar.gz
No Match for argument: php-7.0.1RC1
No Match for argument: php-7.0.1RC1.tar.gz
No Match for argument: phpMyAdmin-4.4.0.tar.gz
No Match for argument: php-common
No Packages marked for removal
2、rpm 安裝 Php7 相應的 yum源:
[root@iZ23d ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
Retrieving https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
warning: /var/tmp/rpm-tmp.LhJKKR: Header V4 RSA/SHA1 Signature, key ID 62e74ca5: NOKEY
Preparing... ################################# [100%]
package webtatic-release-7-3.noarch is already installed
3、 直接yum安裝php7:
[root@iZ23d ~]# yum install php70w
Loaded plugins: langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Resolving Dependencies
--> Running transaction check
。。。 【省略】
Warning: RPMDB altered outside of yum.
Installing : php70w-common-7.0.0-1.w7.x86_64 1/3
Installing : php70w-cli-7.0.0-1.w7.x86_64 2/3
Installing : php70w-7.0.0-1.w7.x86_64 3/3
Verifying : php70w-7.0.0-1.w7.x86_64 1/3
Verifying : php70w-common-7.0.0-1.w7.x86_64 2/3
Verifying : php70w-cli-7.0.0-1.w7.x86_64 3/3
Installed:
php70w.x86_64 0:7.0.0-1.w7
Dependency Installed:
php70w-cli.x86_64 0:7.0.0-1.w7 php70w-common.x86_64 0:7.0.0-1.w7
Complete!
4、檢查 php 版本:
[root@iZ23d ~]# php -v
PHP 7.0.0 (cli) (built: Dec 2 2015 20:42:32) ( NTS )
Copyright (c) 1997-2015 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
[root@iZ23d2e6hoqZ ~]#
以上顯示安裝成功!
5、重啟 Apache,查看 phpinfo :
[root@iZ23d ~]# systemctl restart httpd.service
檢查phpinfo:
PHP Version 7.0.0
SystemLinux iZ23d 3.10.0-229.11.1.el7.x86_64 #1 SMP Thu Aug 6 01:06:18 UTC 2015 x86_64
Build DateDec 2 2015 20:43:38
Server APIApache 2.0 Handler
Virtual Directory Supportdisabled
Configuration File (php.ini) Path/etc
Loaded Configuration File/etc/php.ini
Scan this dir for additional .ini files/etc/php.d
Additional .ini files parsed/etc/php.d/bz2.ini, /etc/php.d/calendar.ini, /etc/php.d/ctype.ini, /etc/php.d/curl.ini, /etc/php.d/exif.ini, /etc/php.d/fileinfo.ini, /etc/php.d/ftp.ini, /etc/php.d/gettext.ini, /etc/php.d/gmp.ini, /etc/php.d/iconv.ini, /etc/php.d/json.ini, /etc/php.d/phar.ini, /etc/php.d/shmop.ini, /etc/php.d/simplexml.ini, /etc/php.d/sockets.ini, /etc/php.d/tokenizer.ini, /etc/php.d/xml.ini, /etc/php.d/zip.ini
PHP API20151012
PHP Extension20151012
Zend Extension320151012
Zend Extension BuildAPI320151012,NTS
PHP Extension BuildAPI20151012,NTS
Debug Buildno
Thread Safetydisabled
Zend Signal Handlingdisabled
Zend Memory Managerenabled
Zend Multibyte Supportdisabled
IPv6 Supportenabled
DTrace Supportenabled
Registered PHP Streamshttps, ftps, compress.zlib, php, file, glob, data, http, ftp, compress.bzip2, phar, zip
Registered Stream Socket Transportstcp, udp, unix, udg, ssl, sslv3, sslv2, tls, tlsv1.0, tlsv1.1, tlsv1.2
Registered Stream Filterszlib.*, string.rot13, string.toupper, string.tolower, string.strip_tags, convert.*, consumed, dechunk, bzip2.*, convert.iconv.*
This program makes use of the Zend Scripting Language Engine:
Zend Engine v3.0.0, Copyright (c) 1998-2015 Zend Technologies
Configuration
apache2handler
Apache VersionApache/2.4.6 (CentOS)
Apache API Version20120211
Server [email protected]
Hostname:Portxxxx.xxxxx.xxx:0
User/Groupapache(48)/48
Max RequestsPer Child: 0 - Keep Alive: on - Max Per Connection: 100
TimeoutsConnection: 60 - Keep-Alive: 15
Virtual ServerYes
Server Root/etc/httpd
Loaded Molescore mod_so http_core mod_access_compat mod_actions mod_alias mod_allowmethods mod_auth_basic mod_auth_digest mod_authn_anon mod_authn_core mod_authn_dbd mod_authn_dbm mod_authn_file mod_authn_socache mod_authz_core mod_authz_dbd mod_authz_dbm mod_authz_groupfile mod_authz_host mod_authz_owner mod_authz_user mod_autoindex mod_cache mod_cache_disk mod_data mod_dbd mod_deflate mod_dir mod_mpio mod_echo mod_env mod_expires mod_ext_filter mod_filter mod_headers mod_include mod_info mod_log_config mod_logio mod_mime_magic mod_mime mod_negotiation mod_remoteip mod_reqtimeout mod_rewrite mod_setenvif mod_slotmem_plain mod_slotmem_shm mod_socache_dbm mod_socache_memcache mod_socache_shmcb mod_status mod_substitute mod_suexec mod_unique_id mod_unixd mod_userdir mod_version mod_vhost_alias mod_dav mod_dav_fs mod_dav_lock mod_lua prefork mod_proxy mod_lbmethod_bybusyness mod_lbmethod_byrequests mod_lbmethod_bytraffic mod_lbmethod_heartbeat mod_proxy_ajp mod_proxy_balancer mod_proxy_connect mod_proxy_express mod_proxy_fcgi mod_proxy_fdpass mod_proxy_ftp mod_proxy_http mod_proxy_scgi mod_proxy_wstunnel mod_ssl mod_systemd mod_cgi mod_perl mod_php7
以上顯示 php7 安裝成功!
C. make: *** [sapi/cli/php] 錯誤 1 centos源碼安裝php5.4 make的時候出現以上錯誤,請問如何解決,謝謝
yum install libxml2
後重新編譯PHP看看
D. LINUX安裝PHP的RPM包遇到的提示: [root@localhost ~]# rpm -ivh /mnt/cdrom/CentOS/php-cli-5.1.6-20.el5
遇到什麼提示?
E. 如何在CentOS系統中把PHP 5.3.x更新到PHP 5.4.x
1.首頁安裝Webtatic EL6 YUM源
rpm -Uvh
2.停止web伺服器
service nginx stop
或者
service httpd stop
3.刪除當前的 php 安裝 php5.4
yum remove php*
yum install php54w
4.重啟web伺服器
service php-fpm restart
service nginx start
或者
service httpd restart
5.查看php版本
php -v
PHP 5.4.33 (cli) (built: Sep 19 2014 19:58:27)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2014 Zend Technologies
F. centos怎麼徹底卸載php
想把PHP卸載干凈,直接用yum的remove命令是不行的,需要查看有多少rpm包,然後按照依賴順序逐一卸載。
1.首先查看機器上安裝的所有php相關的rpm包
[root@localhost nginx]# rpm -qa | grep php
php-cli-5.3.3-22.el6.x86_64
php-pdo-5.3.3-22.el6.x86_64
php-gd-5.3.3-22.el6.x86_64
php-fpm-5.3.3-22.el6.x86_64
php-common-5.3.3-22.el6.x86_64
php-5.3.3-22.el6.x86_64
php-xml-5.3.3-22.el6.x86_64
php-pear-1.9.4-4.el6.noarch
2.按依賴順序進行刪除
rpm -e php-fpm-5.3.3-22.el6.x86_64
rpm-e php-pdo-5.3.3-22.el6.x86_64
rpm -e php-pear-1.9.4-4.el6.noarch
rpm-e php-cli-5.3.3-22.el6.x86_64
rpm -e php-5.3.3-22.el6.x86_64
rpm-e php-xml-5.3.3-22.el6.x86_64
rpm -e php-gd-5.3.3-22.el6.x86_64
rpm-e php-common-5.3.3-22.el6.x86_64
G. CentOS怎樣強制卸載PHP以及自定義安裝PHP
查看php版本命令:
#php -v
這個命令是刪除不幹凈的
#yum remove php
因為使用這個命令以後再用
#php -v
還是會看到有版本信息的。。。。。
必須強制刪除
#rpm -qa|grep php
提示如下
#php-pdo-5.1.6-27.el5_5.3
#php-mysql-5.1.6-27.el5_5.3
#php-xml-5.1.6-27.el5_5.3
#php-cli-5.1.6-27.el5_5.3
#php-common-5.1.6-27.el5_5.3
#php-gd-5.1.6-27.el5_5.3
注意卸載要先卸載沒有依賴的
pdo是mysql的依賴項;common是gd的依賴項;
例如:# rpm -e php-pdo-5.1.6-27.el5_5.3
error: Failed dependencies:
php-pdo is needed by (installed) php-mysql-5.1.6-27.el5_5.3.i386
所以正確的卸載順序是:
# rpm -e php-mysql-5.1.6-27.el5_5.3
# rpm -e php-pdo-5.1.6-27.el5_5.3
# rpm -e php-xml-5.1.6-27.el5_5.3
# rpm -e php-cli-5.1.6-27.el5_5.3
# rpm -e php-gd-5.1.6-27.el5_5.3
# rpm -e php-common-5.1.6-27.el5_5.3
再用# php -v
查看版本信息已經沒有提示
安裝最新的PHP
wget
tar xzvf php-5.3.6.tar.gz
cd php-5.3.6
./configure --prefix=/usr/local/php
H. 如何在CentOS 6上通過YUM安裝Nginx和PHP
在CentOS 6上通過YUM安裝Nginx和PHP-FPM:
第一步,在/etc/yum.repos.d/目錄下創建一個源配置文件nginx.repo:
cd /etc/yum.repos.d/
vim nginx.repo
填寫如下內容:
[nginx]
name=nginx repo
baseurl=nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
保存,則會產生一個/etc/yum.repos.d/nginx.repo文件。
下面直接執行如下指令即可自動安裝好Nginx:
yum install nginx -y
安裝完成,下面直接就可以啟動Nginx了:
/etc/init.d/nginx start
現在Nginx已經啟動了,直接訪問伺服器就能看到Nginx歡迎頁面了的。
I. 安裝centos時自動安裝的php怎麼卸載
CentOS 5/get/php-5.3.6.tar.bz2/from/this/mirror # tar -xjf php-5.3.6.tar.bz2 配置安裝參數 ./configure --build=i686-RedHat-linux-gnu --host=i686-redhat-linux-gnu --target=i686-RedHat-linux-gnu --with-apxs2=/usr/sbin/apxs --prefix=/usr/local --exec-prefix=/usr/local --with-exec-dir=/usr/local/bin --sysconfdir=/etc --libdir=/usr/local/lib/php --with-libdir=lib --sbindir=/usr/local/sbin --sharedstatedir=/usr/com --datadir=/usr/local/share --includedir=/usr/local/include --libexecdir=/usr/local/libexec --localstatedir=/var --cache-file=../config.cache --mandir=/usr/local/share/man --infodir=/usr/local/share/info --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-pic --with-curl=shared --with-freetype-dir --with-png-dir --with-gettext --with-gmp --with-iconv --with-jpeg-dir --with-png-dir --with-openssl --with-layout=GNU --with-libxml-dir --with-pcre-regex=/usr --with-mcrypt=shared --with-mhash --with-zlib --with-bz2=shared --with-pdo-mysql --with-mysql --with-mysql-sock=/var/lib/mysql/mysql.sock --with-pgsql --with-pdo-pgsql --with-sqlite=shared --with-pdo-sqlite=shared --enable-sqlite-utf8 --with-kerberos --with-imap --with-imap-ssl --with-pear --with-gd --enable-gd-native-ttf --enable-calendar=shared --enable-exif --enable-ftp --enable-sockets --enable-bcmath --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-intl --enable-mbstring --enable-zend-multibyte --enable-zip --without-unixODBC --disable-tokenizer 非RHEL/CentOS系統可以省略 --build,--host,--target 參數,程序會自動判斷(linux一般為i686-pc-linux-gnu)。如果沒安裝pgsql或者不需要pgsql的支持可以刪除相關參數(共2個)。 bz2, calendar, curl, mcrypt, pdo_sqlite, sqlite 這些模塊採用動態編譯,可採用下面將會提到的方法載入。編譯並安裝 # make && make install 安裝結果摘要,裡面有幾個主要的安裝路徑變數 libtool: install: warning: remember to run `libtool --finish /usr/local/src/php-5.3.6/libs [activating mole `php5 in /etc/httpd/conf/httpd.conf] Installing PHP CLI binary: /usr/local/bin/ Installing PHP CLI man page: /usr/local/share/man/man1/ Installing shared extensions: /usr/local/lib/php/20090626/ Installing build environment: /usr/local/lib/php/build/ Installing header files: /usr/local/include/php/ Installing helper programs: /usr/local/bin/ program: phpize program: php-config Installing man pages: /usr/local/share/man/man1/ Installing PEAR environment: /usr/local/share/pear/ 貌似要運行一次libtool --finish ....,不過我運行後也沒什麼奇特效果~ 更新httpd配置文件以便apache能解析php文件 # vim /etc/httpd/conf/httpd.conf 添加以下內容 AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps 如果在卸載原有PHP之前沒備份php.ini文件,那麼可以從PHP編譯目錄中把 php.ini-proction 拷貝到 /etc目錄下並改名為 php.ini # mv /usr/local/src/php-5.3.6/php.ini-proction /etc/php.ini 添加或者更新相關設置,比如: extension_dir = "/usr/local/lib/php/20090626" # 以下六個模塊可根據需要添加 extension = bz2.so extension = calendar.so extension = curl.so extension = mcrypt.so extension = pdo_sqlite.so extension = sqlite.so max_execution_time = 30 max_input_time = 60 memory_limit = 128M variables_order = "EGPCS" register_globals = Off register_long_arrays = Off post_max_size = 30M upload_max_filesize = 30M mbstring.internal_encoding = UTF-8 date.timezone = Asia/Chongqing 測試結果。在 /var/www/html 下面新建一個文件 phpinfo.php ,裡麵包含內容 Php代碼 <?php phpinfo(); ?> 重啟apache服務 # service httpd restart