PHP开发环境的配置(Linux平台上安装Apache和PHP)
PHP开发环境的配置(Linux平台上安装Apache和php):
下载Apache (httpd-2.4.12.tar.gz)、下载PHP(php-5.6.9.tar.gz)、下载与PHP安装相关的libxml2(libxml2-2.7.8.tar.gz)、下载与Apache安装相关的三个文件:apr(apr-1.5.2.tar.gz)、apr-util(apr-util-1.5.4.tar.gz)、pcre (pcre-8.10.zip)
(1)安装Apache:在安装apache之前必须先安装apr、apr-util和pcre,否则会出错:
安装apr:
Gunzip apr-1.5.2.tar.gz
Tar xvf apr-1.5.2.tar
进入apr-1.5.2目录,然后执行:
./configure --prefix=/usr/local/apr
Make && make install
安装apr-util:
解压后进入apr-util目录,然后执行:
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
Make && make install
安装pcre:在安装之前,必须先安装gcc,否则无法编译pcre文件
安装gcc:yum -y install gcc+ gcc-c++
然后安装pcre:
解压后进入pcre目录,然后执行:
./configure --prefix=/usr/local/pcre
Make && make install
安装好这几个文件后,可以安装apache了,解压httpd-2.4.12.tar.gz:
Gunzip httpd-2.4.12.tar.gz
Tar xvf httpd-2.4.12.tar
进入解压目录:cd httpd-2.4.12,然后执行:
./configure --prefix=/usr/local/apache --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util \
--with-pcre=/usr/local/pcre
Make && make install
(2)安装PHP:
安装php之前先安装libxml2:
解压后进入目录:libxml2-2.7.8,然后执行:
./configure --prefix=/usr/local/libxml2
Make && make install
安装php:解压后进入目录php-5.6.9,然后执行:
./configure --prefix=/usr/local/php --with-libxml-dir=/usr/local/libxml2 --with-apxs2=/usr/local/apache/bin/apxs
Make && make install
安装好php之后,将解压后的php-5.6.9目录里的php.ini-development复制到下面目录:
cp php.ini-development /usr/local/php/lib/php.ini
(3)配置Apache的conf文件夹里面的httpd-conf,添加下面内容(如果不存在的话):
LoadModule处添加LoadModule php5_module module/libphp5.so
在AddTypeapplication处添加AddType application/x-httpd-php .php
(4)启动或者重启Apache:
/usr/local/apache/bin/apachectl restart (或者start)
(5)测试Apache和PHP安装是否正确:
进入Apache里面的htdocs目录下面,
[root@Masterpc htdocs]# vim hello.php
echo "Hello world!";
phpinfo();
?>
在浏览器输入:http://172.16.2.42/hello.php (本人linux主机的ip地址是 172.16.2.42,通过远程访问),访问成功则显示如下:

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

WebStorm Mac version
Useful JavaScript development tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Notepad++7.3.1
Easy-to-use and free code editor
