linux 安装 php

安装libmcrypt

cd /usr/local/src   

tar zxvf  libmcrypt-2.5.7.tar.gz   #解压   

cd  libmcrypt-2.5.7 #进入目录   

./configure    #配置   

make             #编译   

make install   #安装

安装php

cd /usr/local/src   

tar -zvxf php-5.3.13.tar.gz   

cd  php-5.3.13   

mkdir -p /usr/local/php5  #建立php安装目录   

./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv  --with-zlib  --enable-xml --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex  --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl --with-jpeg-dir --with-freetype-dir #配置

make   #编译   

make install    #安装

整合Apache与PHP,我们使用configure命令安装配置时,需使用--with-apxs2=/usr/local /apache242/bin/apxs选项以使Apache 2将PHP作为功能模块使用。但我们还要修改Apahce配置文件,添加PHP的支持,告 诉Apache将哪些后缀作为PHP解析。例如,让Apache把.php或.phtml后缀名解析为PHP.使用vi打开Apache的配置文件 /etc/httpd/httpd.conf,找到AddType application/x-gzip .gz .tgz指令选项,并在其下方添加一 条指令AddType application/x-httpd-php .php .phtml。也可以将任何后缀的文件解析为PHP,只要在添加的语 句中加入并用空格分开,这里以多添加一个.phtml来示例,如下示:

# If the AddEncoding directives above are commented-out, then you

# probably should define those extensions to indicate media types:

#

AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

AddType application/x-httpd-php .php .phtml

修改完成后必须重启Apache服务器,才能重新加载配置文件使修改生效。

原文地址:https://www.cnblogs.com/lizs/p/4224851.html