centos重新安装php?centos如何安装软件
各位老铁们,大家好,今天由我来为大家分享centos重新安装php,以及centos如何安装软件的相关问题知识,希望对大家有所帮助。如果可以帮助到大家,还望关注收藏下本站,您的支持是我们最大的动力,谢谢大家了哈,下面我们开始吧!
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
centos系统编译安装nginx+php环境另加独立mysql教程
前端(nginx+php)ip:192.168.10.8
后端(独立mysql)ip:192.168.10.5
软件版本:libiconv-1.14.tar.gz mysql-5.1.63.tar.gz php-5.2.17.tar.gz php-5.2.17-fpm-0.5.14.diff.gz php-5.2.17-max-input-vars.patch
1.先在后端安装mysql
在192.168.10.5上只安装mysql.方法可以去看centos编译安装nginx+php-fpm+mysql里的mysql安装.
2.在前端安装php-fpm nginx和mysql-client
这里只说下安装mysql-client和php的编译安装.
代码如下 tar zxf mysql-5.1.63.tar.gz cd mysql-5.1.63
./configure--prefix=/usr/local/mysql--without-server
这里只需要加上--without-server就可以让mysql变成客户端了.
如果出现/bin/rm: cannot remove `libtoolt': No such file or directory,可以去看这篇文章Mysql安装:/bin/rm: cannot remove `libtoolt': No such file or directory.
没有问题后,执行命令:
代码如下 make make install
编译php的时候只需要加上--with-mysql=mysql客户端安装目录就可以了.这里我给出编译参数:
代码如下 ./configure--prefix=/usr/local/php--enable-fastcgi--enable-fpm--with-fpm-log=/var/log/php-fpm.log\
--with-fpm-conf=/etc/php-fpm.conf--with-fpm-pid=/var/run/php-fpm.pid--with-config-file-path=/etc\
--with-config-file-scan-dir=/etc/php.d--with-openssl--with-zlib--enable-bcmath--with-bz2--with-curl\
--enable-ftp--with-gd--enable-gd-native-ttf--with-jpeg-dir--with-png-dir--with-gettext--with-mhash\
--enable-mbstring--with-mcrypt--enable-soap--enable-zip--with-iconv=/usr/local/libiconv\
--with-mysql=/usr/local/mysql--with-mysqli=/usr/local/mysql/bin/mysql_config--without-pear
nginx的编译没有什么好说的了,我前面centos编译安装nginx+php-fpm+mysql这篇文章里已经有讲过了.
3.进行测试验证
当上面的一切都安装好之后,在后端的mysql里给出远程权限,如下:
代码如下 GRANT ALL PRIVILEGES ON*.* TO'root'@'%' IDENTIFIED BY'123456';
然后iptables上只允许192.168.10.8访问mysql端口,其他都拒绝.如:
代码如下 iptables-A RH-Firewall-1-INPUT-s 192.168.10.8-p tcp-m tcp--dport 3306-j ACCEPT
iptables-A RH-Firewall-1-INPUT-p tcp--dport 3306-j DROP
services iptables save
services iptables restart
然后在192.168.10.8上进行测试,是否可以远程连上mysql
mysql-h 192.168.10.5-u root-p
如果可以连上,就继续下一步的操作,不能连上的话请检查上面是否有错误的地方.
现在我们加个php页面来测试php是否可以连上mysql,脚本如下:
代码如下 ?php
$link=mysql_connect("192.168.10.5","root","123456");
if(!$link) echo"bad!";
else echo"ok!";
mysql_close();
?
成功的话是ok!的输出,失败的话是bad!的输出,我这里是成功的
mysql 5.5.x的只安装客户端.
需要的软件:libiconv-1.14.tar.gz mysql-5.5.25a.tar.gz
1.安装前的准备
安装前的准备,可以去看这篇文章centos编译安装nginx+php-fpm+mysql
2.安装libiconv
代码如下 ./configure--prefix=/usr/local/libiconv
make make install
3.只安装mysql客户端
代码如下 cmake. make mysqlclient libmysql
make install
这样就只安装了mysql客户端,然后可以输入whereis mysql来查看mysql安装位置.
whereis mysql
好了,可以看到跟yum安装的差不多.
4.安装php
以前mysql是5.1的时候,只需要加上--with-mysql=mysql客户端安装目录就可以了,但在mysql 5.5.x这个参数就要改变下了,下面是php的编译参数:
代码如下 ./configure--prefix=/usr/local/php--enable-fastcgi--enable-fpm--with-fpm-log=/var/log/php-fpm.log--with-fpm-conf=/etc/php-fpm.conf\
--with-fpm-pid=/var/run/php-fpm.pid--with-config-file-path=/etc--with-config-file-scan-dir=/etc/php.d\
--with-openssl--with-zlib--enable-bcmath--with-bz2--with-curl--enable-ftp\
--with-gd--enable-gd-native-ttf--with-jpeg-dir--with-png-dir--with-gettext--with-mhash\
--enable-mbstring--with-mcrypt--enable-soap--enable-zip--with-iconv=/usr/local/libiconv\
--with-mysql=shared,/usr--with-mysqli=shared,/usr/bin/mysql_config
大家可以看最后一行,--with-mysql=shared,/usr--with-mysqli=shared,/usr/bin/mysql_config这就是跟以前不同的行.好了,剩下的就不写了
阿里云上的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
Retrieving
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 Administratorxxxxxx@xxxxxx.com
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 Modulescore 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_dumpio 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安装成功!