PHP运行环境配置及需求
构建PHP运行环境在搭建PHP的前提把Apache,MySQL搭建完成。
安装PHP软件包(手工编译安装)
1:安装GD库和GD库关联程序 //用来处理和生成图片//
# yum install \
> libjpeg-devel \
> libpng-devel \
> freetype-devel \
> zlib-devel \
> gettext-devel \
> libXpm-devel \
> libxml2-devel \
> fontconfig-devel \
> openssl-devel \
> bzip2-devel -y
2:解压gd库和编译
tar zxvf /opt/lamp/gd-2.0.35.tar.gz -C /opt/
cd ../gd/2.0.35/
./configure --prefix=/usr/local/gd
make && make install
3:解压PHP源代码包并安装编译
tar zxvf /opt/lamp/php-5.5.38.tar.gz -C /opt/
./configure \
> --prefix=/usr/local/php \
> --with-apxs2=/usr/local/httpd/bin/apxs \
> --with-gd \
> --with-mysql=/usr/local/mysql \
> --with-config-file-path=/etc \
> --enable-sqlite-utf8 \
> --with-zlib-dir \
> --with-libxml-dir \
> --with-freetype-dir \
> --with-jpeg-dir \
> --with-png-dir \
> --with-ttf \
> --with-iconv \
> --with-openssl \
> --with-gettext \
> --enable-mbstring \
> --enable-gd-native-ttf \
> --enable-gd-jis-conv \
> --enable-static \
> --enable-zend-multibyte \
> --enable-inline-optimization \
> --enable-sockets \
> --enable-soap \
> --enable-ftp \
> --disable-ipv6
make && make install
4:让Apache支持PHP
#找到 AddType application/x-gzip .gz .tgz 在下面添加如下内容
vim /usr/local/apache/conf/httpd.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
# 搜索php5有没有下面这个配置
LoadModule php5_module modules/libphp5.so
# 找到这个标签在index.html后面加入index.php
DirectoryIndex index.html index.php
重新启动httpd服务
systemctl restart httpd.service
加入php测试页面
cd /usr/local/httpd/htdocs/
ls
index.html
vim index.html
accp #删除原有编辑的首页如果没有就不用
#加入下面的php测试页面
mv index.html index.php #修改原有html结尾的首页名称改为php结尾
ls
index.php
PHP搭建好后可是进行Apache的网页优化,自己可以先尝试搭建一个论坛下一个博客会讲到搭建简单的论坛
下面打开网页测试一下
如过不能访问查看一下防火墙有没有关
http://i2.运维网.com/images/blog/201807/05/837846e9501bdec562a2ebc0d4aa9328.png
页:
[1]