【LAMP】二进制包搭建LAMP环境 (三) 安装PHP

搭建LAMP准备工作、Apache的安装、MySQL的安装,请见前两篇:

【LAMP】二进制包搭建LAMP环境 (一) 安装Apache

【LAMP】二进制包搭建LAMP环境 (二) 安装MySQL


【安装PHP】

移动到安装包所在目录

cd /usr/local/src/php-5.6.36/

建立安装目录

mkdir /usr/local/php

安装libxml2和libxml2-devel包

yum install libxml2

yum install libxml2-devel –y

安装完之后查找xml2-config文件是否存在

find / -name "xml2-config"


依次安装

yum install -y openssl-devel

yum install -y bzip2-devel

yum -y install curl-devel

yum install -y libjpeg-devel 

yum install -y libpng-devel

yum install -y freetype-devel

yum install -y libmcrypt-devel  (mcrypt这个库在扩展源里,如果没有安装就先装epel-release)

开始配置

./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

配置完成


编译安装

make && make install

配置PHP

添加软连接

ln -s /usr/local/php/bin/php /usr/bin/php
ln -s /usr/local/php/bin/php-config /usr/bin/php-config
ln -s /usr/local/php/bin/phpize /usr/bin/phpize

查看php.ini所在位置

php -r "phpinfo();" | grep 'php.ini'


将安装包中的php.ini-development文件复制到php安装目录下,并更名为php.ini

cp /usr/local/src/php-5.6.36/php.ini-development /usr/local/php/lib/php.ini

修改php.ini配置(建议使用ftp工具备份之后修改)

vi /usr/local/php/lib/php.ini 
short_open_tag = On  #开启短标签,默认是Off

date.timezone = PRC  #设置时区,删掉前面的分号,设置为PRC或者Asia/Shanghai

expose_php = Off   #禁止显示php版本的信息

列出PHP可以禁用的函数,如果某些程序需要用到这个函数,可以删除,取消禁用。
disable_functions=passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname


重启Apache

service httpd restar

移动到Apache的项目根目录,删除默认测试页,创建index.php文件并打印phpinfo()

cd /usr/local/apache/htdocs

rm -f index.html

vi index.php

访问主机地址发现一片空白,修改httpd.conf配置:

大约389行位置添加:
AddType application/x-httpd-php .php

大约251行位置修改:
<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php
</IfModule>

重启Apache,再次访问显示phpinfo()信息,PHP安装完成



到此完成二进制包搭建LAMP环境。


猜你喜欢

转载自blog.csdn.net/msllws/article/details/80983827