centos php -m?centos7安装php环境

老铁们,大家好,相信还有很多朋友对于centos php -m和centos7安装php环境的相关问题不太懂,没关系,今天就由我来为大家分享分享centos php -m以及centos7安装php环境的问题,文章篇幅可能偏长,希望可以帮助到大家,下面一起来看看吧!

CentOSyumphpmcrypt扩展安装方法

使用 yum install php-mcrypt安装mcrypt扩展时会提示没有安装包

Setting up Install Process

No package php-mcrypt available.

Error: Nothing to do

mcrypt是加密扩展库,加载了它可以用他里面自带的22种加密解密算法

CentOS6默认安装的是php5.3.2

默认的 redhat repos php中是没有 mcrypt扩展的

根据红帽的官方消息()RHEL不打算添加PHP的mcrypt的支持

Joe Orton 2010-08-05 04:47:17 EDT

Thanks for the report.

We are not planning to ship mcrypt support for PHP.

解决方法:

从php官网下载新的php 5.3源码包后,解压到本地目录

进入解压目录下的 ext目录后会发现有 mcrypt,

进入 mcrypt目录

#cd/ext/mcrypt

#phpize

注意:如果报-bash:phpize not Found那么 yum install php-devel就可以使phpize进行动态编译安装扩展

#./configure-with-php-config=/usr/sbin/php/bin/php-config

#make&& make install

出现:

----------------------------------------------------------------------

Libraries have been installed in:

/var/php-5.3.10/ext/mcrypt/modules

If you ever happen to want to link against installed libraries

in a given directory, LIBDIR, you must either use libtool, and

specify the full pathname of the library, or use the `-LLIBDIR'

flag during linking and do at least one of the following:

- add LIBDIR to the `LD_LIBRARY_PATH' environment variable

during execution

- add LIBDIR to the `LD_RUN_PATH' environment variable

during linking

- use the `-Wl,-rpath-Wl,LIBDIR' linker flag

- have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for

more information, such as the ld(1) and ld.so(8) manual pages.

----------------------------------------------------------------------

Build complete.

Don't forget to run'make test'.

Installing shared extensions:/usr/lib64/php/modules/

查看:

# php-m

...

libxml

mbstring

mcrypt

mysql

...

[Zend Modules]

已安装成功!

再次查看 phpinfo,可以看到mcrypt扩展详情。

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/6.5/6.4 下安装PostgreSQL 9.3 与 phpPgAdmin

1.安装PostgreSQL

使用以下命令来更新库:

yum update

使用以下命令来安装PostgreSQL:

yum install postgresql93-server postgresql93-contrib

使用以下命令来初始化PostgreSQL数据库:

在CentOS 6.x系统中:

service postgresql-9.3 initdb

在CentOS 7系统中:

/usr/pgsql-9.3/bin/postgresql93-setup initdb

然后启动PostgreSQL服务并使之开机自启:

在CentOS 6.x系统中:

service postgresql-9.3 start

chkconfig postgresql-9.3 on

在CentOS 7系统中:

systemctl enable postgresql-9.3

systemctl start postgresql-9.3

2.调整Iptables/Firewall

接下来调整防火墙出站规则:

在CentOS 6.x系统中:

vi/etc/sysconfig/iptables

并添加以下行

-A INPUT-m state--state NEW-m tcp-p tcp--dport 5432-j ACCEPT

-A INPUT-m state--state NEW-m tcp-p tcp--dport 80-j ACCEPT

退出并保存文件。重启iptables服务:

service iptables restart

在CentOS系统中:

firewall-cmd--permanent–add-port=5432/tcp

firewall-cmd--permanent–add-port=80/tcp

firewall-cmd--reload

3.访问PostgreSQL常用的命令提示符

默认情况下数据库名和用户名都是postgres。切换至用户以执行相关操作:

su– postgres

输入以下命令登陆:

psql

会有以下样例输出:

psql(9.3.5)

Type"help" for help.

Postgres=#

可通过输入\q退出postgresql返回命令终端:

4.设置用户密码

登陆至postgres命令提示符界面

su– postgres

psql

然后使用命令设置密码

postgres=# \password postgres

Enter new password:

Enter it again:

postgres=# \q

输入命令以建立PostgreSQL系统管理工具

postgres=# CREATE EXTENSION adminpack;

CREATE EXTENSION

5.创建用户和数据库

例如:用户名:senthil密码:centos数据库名:mydb

转到postgres用户

su– postgres

创建用户senthil

$ createuser senthil

创建数据库

$ createdb mydb

现在登陆至psql提示符界面,为用户senthil设置密码及授权对数据库mydb的访问:

$ psql

psql(9.3.5)

Type"help" for help.

postgres=# alter user senthil with encrypted password'centos';

ALTER ROLE

postgres=# grant all privileges on database mydb to senthil;

GRANT

postgres=#

6.删除用户和数据库

首先转到postgres界面

su– postgres

输入命令

$ dropdb<database-name>

删除用户名可输入

$ dropuser<user-name>

7.配置PostgreSQL-MD5认证

MD5认证需要客户端提供一个MD5-encrypted密码以便身份验证。你需要编辑/var/lib/pgsql/9.3/data/pg_hba.conf文件:

vi/var/lib/pgsql/9.3/data/pg_hba.conf

添加或修改的行如下:

[...]

# TYPE DATABASE USER ADDRESS METHOD

#"local" is for Unix domain socket connections only

local all all md5

# IPv4 local connections:

host all all 127.0.0.1/32 md5

host all all 192.168.1.0/24 md5

# IPv6 local connections:

host all all::1/128 md5

[...]

重启postgresql服务以应用更改

在CentOS 6.x系统中

service postgresql-9.3 restart

在CentOS 7系统中

systemctl restart postgresql-9.3

8.配置PostgreSQL-Configure TCP/IP

默认情况下,TCP/IP连接是不可行的,所以其他计算机用户不能连接到postgresql。编辑文件/var/lib/pgsql/9.3/data/postgresql.conf可以允许连接:

vi/var/lib/pgsql/9.3/data/postgresql.conf

找到下面的行:

[...]

#listen_addresses='localhost’

[...]

#port= 5432

[...]

把两行都取消并设置为你的postgresql服务器IP地址或设置为“*”监听所有客户端。如下所示:

listen_addresses='*'

port= 5432

重启以应用更改

在CentOS6.x系统中:

/etc/init.d/postgresql-9.3 restart

在CentOS7系统中:

systemctl restart postgresql-9.3

9.使用phpPgAdmin管理PostgreSQL

phpPgAdmin是使用PHP编写的基于web的管理工具,用于管理PostgreSQL。它只适用与PostgreSQL RPM库。

阅读剩余
THE END