centos php 安装目录?php安装

很多朋友对于centos php 安装目录和php安装不太懂,今天就由小编来为大家分享,希望可以帮助到大家,下面一起来看看吧!

Centos7如何安装PHP7最新版

方法一、简单安装(通过yum)

1.安装epel-release

rpm-ivh

2.安装PHP7的rpm源

rpm-Uvh

3.安装PHP7

yum install php70w

方法二、编译安装

1.下载php7

wget-O php7.tar.gz

2.解压php7

tar-xvf php7.tar.gz

3.进入php目录

cd php-7.0.4

4.安装依赖包

#直接复制下面一行(不包括本行)

yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel

5.编译配置(如果出现错误,基本都是上一步的依赖文件没有安装所致)

嫌麻烦的可以从这一步起参考PHP官方安装说明:

./configure\

--prefix=/usr/local/php\

--with-config-file-path=/etc\

--enable-fpm\

--with-fpm-user=nginx\

--with-fpm-group=nginx\

--enable-inline-optimization\

--disable-debug\

--disable-rpath\

--enable-shared\

--enable-soap\

--with-libxml-dir\

--with-xmlrpc\

--with-openssl\

--with-mcrypt\

--with-mhash\

--with-pcre-regex\

--with-sqlite3\

--with-zlib\

--enable-bcmath\

--with-iconv\

--with-bz2\

--enable-calendar\

--with-curl\

--with-cdb\

--enable-dom\

--enable-exif\

--enable-fileinfo\

--enable-filter\

--with-pcre-dir\

--enable-ftp\

--with-gd\

--with-openssl-dir\

--with-jpeg-dir\

--with-png-dir\

--with-zlib-dir\

--with-freetype-dir\

--enable-gd-native-ttf\

--enable-gd-jis-conv\

--with-gettext\

--with-gmp\

--with-mhash\

--enable-json\

--enable-mbstring\

--enable-mbregex\

--enable-mbregex-backtrack\

--with-libmbfl\

--with-onig\

--enable-pdo\

--with-mysqli=mysqlnd\

--with-pdo-mysql=mysqlnd\

--with-zlib-dir\

--with-pdo-sqlite\

--with-readline\

--enable-session\

--enable-shmop\

--enable-simplexml\

--enable-sockets\

--enable-sysvmsg\

--enable-sysvsem\

--enable-sysvshm\

--enable-wddx\

--with-libxml-dir\

--with-xsl\

--enable-zip\

--enable-mysqlnd-compression-support\

--with-pear\

--enable-opcache

6.正式安装

make make install

7.配置环境变量

vi/etc/profile

在末尾追加

PATH=$PATH:/usr/local/php/bin

export PATH

执行命令使得改动立即生效

source/etc/profile

8.配置php-fpm

cp php.ini-production/etc/php.ini

cp/usr/local/php/etc/php-fpm.conf.default/usr/local/php/etc/php-fpm.conf

cp/usr/local/php/etc/php-fpm.d/www.conf.default/usr/local/php/etc/php-fpm.d/www.conf

cp sapi/fpm/init.d.php-fpm/etc/init.d/php-fpm

chmod+x/etc/init.d/php-fpm

9.启动php-fpm

/etc/init.d/php-fpm start

如何在CentOS6下实现Apache+PHP+MySQL的快速安装

LAMP是一个免费、开源的解决方案,代表了Linux、Apache、MySQL、PHP,主要用作建立可行的通用的web服务器。那么如何在CentOS6下实现安装Apache+php+Mysql的快速安装?其具体安装配置步骤可以如下进行:

1.准备工作

使用yum进行安装,为了提高速度,最好先是修改为中国CentOS镜像服务器。目前国内有三个镜像可以选择,分别是:中国科学技术大学、163和Sohu的镜像,建议教育网用户选择中科大,电信用户选择163,他们的repo文件本博客作了备份如下:

下面命令是备份CentOS-Base.repo文件,并修改使用163镜像作为yum源:

mv/etc/yum.repos.d/CentOS-Base.repo/etc/yum.repos.d/CentOS-Base.repo.save

wget

mv CentOS6-Base-163.repo/etc/yum.repos.d/CentOS-Base.repo

2.更新系统内核

yum-y update

3.安装Apahce、Mysql、PHP

yum-y install httpd php mysql mysql-server

默认情况下,mysql数据目录位于/var/lib/mysql

4.安装相关组件:

yum install php-mysql php-gd php-imap php-ldap php-odbc

php-pear php-xml php-xmlrpc

5.安装MySQL管理工具phpMyAdmin

yum-y install phpMyAdmin

6.配置Apache随系统启动

chkconfig--levels 235 httpd on

/etc/init.d/httpd start

7.配置MySQL随系统启动

chkconfig--levels 235 mysqld on

/etc/init.d/mysqld start

8.设置数据库root密码

/usr/bin/mysqladmin-u root password'New+Password#www.yupengyan.com'

9.测试PHP是否安装成功

在 CentOS中 Apache的默认根目录是/var/www/html,配置文件/etc/httpd/conf/httpd.conf。其他配置存储在/etc/httpd/conf.d/目录。

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扩展详情。

阅读剩余
THE END