centos 编译安装 php 5.5 centos7安装python3

这篇文章给大家聊聊关于centos 编译安装 php 5.5,以及centos7安装python3对应的知识点,希望对各位有所帮助,不要忘了收藏本站哦。

阿里云上的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安装成功!

CentOS 6.2系统安装和基本软件环境配置

一、安装CentOS6.2系统

1、选择Desktop进行安装

注:如果修改了主机名,则需要在/etc/hosts文件中增加设置的主机名

2、ssh安全设置(配置文件:/etc/ssh/sshd_config):

1)更改默认22端口:去掉 Port的注释,改成如:22123

2)禁止root账号登录:去掉PermitRootLogin yes注释,改成:PermitRootLogin no

3)新增SSH登录用户,登录成功后再su到root:

复制代码

   

代码如下:

# useradd xiaoma

   # passwd xiaoma

然后修改ssh配置文件,最后加入:AllowUsers xiaoma

4)重启SSH服务:service sshd restart

5)更改防火墙配置,允许22123端口,加入:-A INPUT-m state–state NEW-m tcp-p tcp–dport 22123-j ACCEPT,并重启防火墙生效:service iptables restart

二、软件环境配置

1、安装编译环境:

复制代码

   

代码如下:

# yum install gcc gcc-c++

注:代理上网,命令行:export http_proxy=

2、安装一些必备的库

复制代码

   

代码如下:

# yum install ncurses-devel zlib-devel libjpeg* libpng* freetype*

注:ncurses-devel–编译安装mysql5.5时需要

zlib-devel–编译安装httpd需要

libjpeg*、libpng*、freetype*–编译安装php需要

3、安装clamAV杀毒软件

复制代码

   

代码如下:

# tar xzf clamav-0.97.4.tar.gz

   # cd clamav-0.97.4

   #./configure--prefix=/usr/local/clamav--disable-clamav

   # make

   # make install

# groupadd clamav

   # useradd-g clamav clamav

   # chown-R clamav.clamav/usr/local/clamav

操作示例:

1)更新病毒库:bin/freshclam(需要修改etc/freshclam.conf文件把Example行注释掉)

2)扫描指定的目录:bin/clamscan–bell-i-r/usr/local

4、安装JDK

复制代码

   

代码如下:

# chmod+x jdk-6u33-linux-i586.bin

   #./jdk-6u33-linux-i586.bin

   # mv jdk1.6.0_33//usr/local

设置JDK环境变量,/etc/profile文件中最后加入如下配置:

复制代码

   

代码如下:

JAVA_HOME=/usr/local/jdk1.6.0_33

   export JAVA_HOME

   export PATH=/usr/local/mysql5/bin:$JAVA_HOME/bin:$PATH

然后更新环境变量使之生效:

复制代码

   

代码如下:

# source/etc/profile

查看安装的java版本:

复制代码

   

代码如下:

# java-version

5、安装Mysql5.5(mysql5.5需要cmake编译,需要先安装cmake)

复制代码

   

代码如下:

# tar xzf cmake-2.8.7.tar.gz

   # cd cmake-2.8.7

   #./configure

   # make make install

# mkdir-p/usr/local/mysql5

   # groupadd mysql

   # useradd-g mysql mysql

   # chown mysql.mysql-R/usr/local/mysql5

# tar xzf mysql-5.5.19.tar.gz

   # cd mysql-5.5.19/

   # cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql5-DMYSQL_UNIX_ADDR=/usr/local/mysql5/mysql.sock-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS=all-DWITH_MYISAM_STORAGE_ENGINE=1-DWITH_INNOBASE_STORAGE_ENGINE=1-DWITH_MEMORY_STORAGE_ENGINE=1-DWITH_READLINE=1-DENABLED_LOCAL_INFILE=1-DMYSQL_DATADIR=/usr/local/mysql5/data-DMYSQL_USER=mysql-DMYSQL_TCP_PORT=3306

   # make

   # make install

配置Mysql,进行如下操作:

复制代码

   

代码如下:

# cp support-files/my-medium.cnf/etc/my.cnf

   # chmod 755 scripts/mysql_install_db

   # scripts/mysql_install_db--user=mysql--basedir=/usr/local/mysql5--datadir=/usr/local/mysql5/data

# cp support-files/mysql.server/etc/init.d/mysql

   # chmod 755/etc/init.d/mysql

   # chkconfig mysql on

启动mysql并设置root账号密码:

复制代码

   

代码如下:

#/etc/init.d/mysql start或 service mysql start

   #/usr/local/mysql5/bin/mysqladmin-uroot password'root'

加入环境变量,在/etc/profile文件中最后加入:

复制代码

   

代码如下:

export PATH=/usr/local/mysql5/bin:$PATH

修改默认的mysql最大连接数(默认只有151),打开/etc/my.cnf文件,在[mysqld]的下面加入:max_connections=1000,然后重启mysql即可生效,查看最大连接数:

复制代码

   

代码如下:

mysqlshow VARIABLES LIKE'%conn%';

6、安装httpd

复制代码

   

代码如下:

# tar xzf httpd-2.2.21.tar.gz

   # cd httpd-2.2.21/

   # cd srclib/apr

   #./configure--prefix=/usr/local/apr

   # make

   # make install

# cd../apr-util

   #./configure--prefix=/usr/local/apr-util--with-apr=/usr/local/apr

   # make

   # make install

# cd../..

   #./configure--prefix=/usr/local/apache2--enable-so--enable-mods-shared=all--with-apr=/usr/local/apr--with-apr-util=/usr/local/apr-util--enable-dav--enable-proxy--enable-proxy-ajp

   # make

   # make install

启动httpd并访问进行测试(注意iptables需要打开80端口):

复制代码

   

代码如下:

#/usr/local/apache2/bin/apachectl start

如果需要禁止对某个目录的访问,可以在该目录下新建.htaccess文件,并输入如下内容:

复制代码

   

代码如下:

order allow,deny

   deny from all

7、安装php

复制代码

   

代码如下:

# tar xzf libxml2-2.7.5.tar.gz

   # cd libxml2-2.7.5

   #./configure--prefix=/usr/local/libxml2

   # make

   # make install

# cd..

   # rpm-qa php

   # rpm-e--nodeps--allmatches php-5.1.6-27.el5

   # tar xzf php-5.3.1.tar.gz

   # cd php-5.3.1

   #./configure--prefix=/usr/local/php5--with-libxml-dir=/usr/local/libxml2/--with-mysql=/usr/local/mysql5/--with-apxs2=/usr/local/apache2/bin/apxs--with-mbstring--enable-mbstring=all--with-gd

   # make

   # make install

   # cp php.ini-production/usr/local/php5/lib/php.ini

修改httpd.conf文件:

1)在AddType application/x-gzip.gz.tgz之后加一行:AddType application/x-httpd-php .php

2)在DirectoryIndex index.html后加入index.php

重启httpd后即可使php生效!

8、安装Tomcat7

复制代码

   

代码如下:

# unzip-q apache-tomcat-7.0.23.zip

   # mv apache-tomcat-7.0.23 tomcat-7

配置tomcat的虚拟主机,打开conf/server.xml配置文件,加入如下段(多个则加入多个如下段即可):

复制代码

   

代码如下:

Host name="www." appBase="webapps"

   unpackWARs="true" autoDeploy="true"

   Aliaschinapis.com/Alias

   Context path="" docBase="/webapps/www."/

   /Host

配置完tomcat后,还需要配置apache的虚拟主机文件(conf/extra/httpd-vhosts.conf):

复制代码

   

代码如下:

VirtualHost*:80

   DocumentRoot"/kington/webapps/chinapis"

   ServerName www.

   ServerAlias

ErrorLog"|/usr/local/apache2/bin/rotatelogs/usr/local/apache2/logs/_%Y-%m-%d_error_log 86400 480"

   CustomLog"|/usr/local/apache2/bin/rotatelogs/usr/local/apache2/logs/_%Y-%m-%d_access_log 86400 480" common

ProxyPass/images/!

   ProxyPass/styles/!

ProxyPreserveHost On

   ProxyPass/ ajp://localhost:8009/

   ProxyPassReverse/ ajp://localhost:8009/

   /VirtualHost

上述配置中的说明如下:

1)ErrorLog和CustomLog配置了日志文件的轮询时间(86400表示秒是一天,480是时区的偏移)

三、常见问题

1、编译安装php时遇到:configure: error: libpng.(a|so) not found,首先安装各个依赖组件(libjpeg、libpng、freetype),然后做如下处理:

复制代码

   

代码如下:

# ln-s/usr/lib64/libjpeg.so/usr/lib/

   # ln-s/usr/lib64/libpng.so/usr/lib/

2、解压bin格式的jdk时候报错:/lib/ld-linux.so.2: bad ELF interpreter,需要安装一些缺少的文件:

复制代码

   

代码如下:

# yum install ld-linux.so.2

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这就是跟以前不同的行.好了,剩下的就不写了

阅读剩余
THE END