一、概述
PHP即“超文本预处理器”,是一种通用开源脚本语言。PHP是在服务器端执行的脚本语言,是常用的网站编程语言。
主要特点:1、开源性和免费性 2、快捷性 3、数据库连接的广泛性 4、面向过程和面向对象并用
二、搭建php
所需软件包:php-7.1.10.tar.bz2
上传php-7.1.10.tar.bz2至opt目录下并解压
[root@localhost ~]# cd /opt
[root@localhost opt]# tar xf php-7.1.10.tar.bz2
[root@localhost opt]# ll
drwxrwxr-x. 15 lhr lhr 4096 Sep 26 2017 php-7.1.10
-rw-r--r--. 1 root root 15069098 Sep 29 10:11 php-7.1.10.tar.bz2
安装PHP环境
yum -y install \
libjpeg libjpeg-devel \ //支持jpeg格式
libpng libpng-devel \ //支持pbg格式
freetype freetype-devel \ //字体样式
libxml2 libxml2-devel \ //xml库
zlib zlib-devel \ //压缩
curl curl-devel \ //curl是利用URL语法在命令行方式下工作的开源文件传输工具
openssl openssl-devel //安全 套接字协议
配置模块
[root@localhost opt]# cd php-7.1.10
[root@localhost php-7.1.10]# ./configure \
--prefix=/usr/local/php \
--with-apxs2=/usr/local/httpd/bin/apxs \
--with-mysql-sock=/usr/local/mysql/mysql.sock \
--with-mysqli \
--with-zlib \
--with-curl \
--with-gd \ //
--with-jpeg-dir \
--with-png-dir \
--with-freetype-dir \
--with-openssl \
--enable-mbstring \ //
--enable-xml \
--enable-session \ //
--enable-ftp \ //
--enable-pdo \ //
--enable-tokenizer \ //
--enable-zip
编译和安装
[root@localhost php-7.1.10]# make && make install
cp php.ini-development /usr/local/php/lib/php.ini //拷贝配置模板
vi /usr/local/php/lib/php.ini //修改模板内容
mysqli.default_socket = /usr/local/mysql/mysql.sock //指定接口
date.timezone = Asia/Shanghai //修改时区,保存退出
vi /etc/httpd.conf //在合适位置新增
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html
rm -f /usr/local/httpd/htdocs/index.html
vi /usr/local/httpd/htdocs/index.php //默认主页
<?php
phpinfo();
?>
systemctl restart httpd