gqinvs 发表于 2018-12-17 12:04:51

Centos下的PHP安装手册

  1、环境检查
  php的安装依赖于apache和mysql,所以说php要安装就要先检查apache和mysql的安装情况。
  检查的版本的命令:
  /apache/bin/apachectl -v
  /mysql -uroot -p'' -e "selectversion();"
  php开发时会调用一些诸如gd等函数库,因此需要确认下面的LIB库是否已经安装。这些lib库都要进行检查,首先是php安装需要,而且php的一些功能才能够使用。如果没有的话,我们也可以通过yum来直接安装。
  rpm -qa zlib libxml libjpegfreetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devellibpng-develgd-devel curl-devely
  在检查结构中如果我们发现有devel就能确定是安装成功的。如果没有安装的,可以用yum install进行安装。
  2、安装libiconv库
  系统默认的时候是没有这个库的,需要我们手动安装一下。
  wgethttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz
  tar zxf libiconv-1.14.tar.gz
  cd libiconv-1.14
  ./configure--prefix=/usr/local/libiconv
  make
  make install
  cd ../
  3、开始安装PHP软件
  1)获取php软件包
  wgethttp://hk2.php.net/distributions/php-5.3.27.tar.gz
  http://hk2.php.net/distributions/php-5.2.17.tar.gz
  2)编译安装
  ./configure\
  --prefix=/usr/local/php-5.2.17\
  --with-apxs2=/usr/local/apache/bin/apxs \
  --with-config-file-path=/usr/local/php/etc \
  --with-mysql=/usr/local/mysql\
  --with-xmlrpc \
  --with-openssl \
  --with-zlib \
  --with-freetype-dir \
  --with-gd \
  --with-jpeg-dir \
  --with-png-dir \
  --with-iconv=/usr/local/libiconv \
  --enable-short-tags \
  --enable-sockets \
  --enable-zend-multibyte \
  --enable-soap \
  --enable-mbstring \
  --enable-static \
  --enable-gd-native-ttf \
  --with-curl \
  --with-xsl \
  --enable-ftp \
  --with-libxml-dir \
  --enable-sigchild \
  --enable-pcntl \
  --enable-bcmath
  make
  make install
  ln -s /application/php-5.2.17 /application/php
  具体的编译参数含义可以去通过man去查看下,这些是网络上人家生产环境中的可正常使用的配置参数,具体的实际生产环境是不是这样有待考究。【注意编译参数里的路径一定要正确了。要不会提示错误的。】
  4、配置apache支持php
  编辑http.conf配置文件,在311行后面添加以下两行:
  AddType application/x-httpd-php.php .php3
  AddType application/x-httpd-php-source.phps
  在166行,DirectoryIndex index.php index.html添加index.php
  并且如果在编译的时候有指定apxs参数,那么php在编译的时候,会在httpd.conf中增加一个模块的加载配置。
  LoadModule php5_module      modules/libphp5.so
  这样保存配置文件。然后在站点主目录里创建一个文件index.php内容如下,访问是否出现php信息:
  
  如果能够出现php的信息就表示已经安装成功了。
http://img1.运维网.com/attachment/201312/134444118.png
  本文出自 “从头开始” 博客,请务必保留此出处http://atong.blog.运维网.com/2393905/1342702

页: [1]
查看完整版本: Centos下的PHP安装手册