下载Apache并解压:
6 wget http://apache.fayea.com//httpd/httpd-2.2.29.tar.gz
28 tar zxvf httpd-2.2.29.tar.gz
29 cd httpd-2.2.29
配置:
83 ./configure –prefix=/usr/local/apache2 –with-mpm=worker –enable-cache –enable-disk-cache –enable-mem-cache –enable-file-cache –enable-nonportable-atomics –enable-mods-shared=most –enable-so –enable-rewrite –enable-ssl
遇到错误:
configure: error: mod_ssl has been requested but can not be built due to prerequisite failures;
解决办法:
84 yum install openssl-devel
再次配置:
85 ./configure –prefix=/usr/local/apache2 –with-mpm=worker –enable-cache –enable-disk-cache –enable-mem-cache –enable-file-cache –enable-nonportable-atomics –enable-mods-shared=most –enable-so –enable-rewrite –enable-ssl
编译并安装:
86 make;make install
修改配置:
87 cd /usr/local/apache2/conf
90 vi httpd.conf
增加ServerName localhost:80
启动Apache:
148 cd /usr/local/apache2/
149 ls
150 cd bin/
151 ls
152 ./apachectl start
访问测试192.168.80.205,发现无法访问,测试127.0.0.1,It works.
根据之前的文章修改 Deny -> ALlow ;发现还是不能访问。
想了半天,service iptables stop
再次访问,ok,一切正常。
下载并解压php:
200 wget http://cn2.php.net/get/php-5.4.41.tar.gz/from/this/mirror
201 tar zxvf php-5.4.41.tar.gz
202 cd php-5.4.41
203 ls
配置:
./configure –prefix=/usr/local/php –enable-fpm –with-mcrypt=/usr/local/libmcrypt –with-zlib –enable-mbstring –with-openssl –with-mysql –with-mysqli –with-mysql-sock –with-gd –with-jpeg-dir=/usr/lib –enable-gd-native-ttf –enable-pdo –with-pdo-mysql –with-pdo-pgsql –with-gettext –with-curl –with-mbstring –enable-sockets –enable-bcmath –enable-xml –with-bz2 –enable-zip –enable-freetype –enable-xmlrpc
遇到错误:
onfigure: error: xml2-config not found. Please check your libxml2 installation.
安装libxml2,再次配置发现还是报错,安装 libxml2-devel,错误解决。
205 yum install libxml2
206 ./configure –prefix=/usr/local/php –enable-fpm –with-mcrypt=/usr/local/libmcrypt –with-zlib –enable-mbstring –with-openssl –with-mysql –with-mysqli –with-mysql-sock –with-gd –with-jpeg-dir=/usr/lib –enable-gd-native-ttf –enable-pdo –with-pdo-mysql –with-pdo-pgsql –with-gettext –with-curl –with-mbstring –enable-sockets –enable-bcmath –enable-xml –with-bz2 –enable-zip –enable-freetype –enable-xmlrpc
207 yum install libxml2-devel
208 ls
209 ./configure –prefix=/usr/local/php –enable-fpm –with-mcrypt=/usr/local/libmcrypt –with-zlib –enable-mbstring –with-openssl –with-mysql –with-mysqli –with-mysql-sock –with-gd –with-jpeg-dir=/usr/lib –enable-gd-native-ttf –enable-pdo –with-pdo-mysql –with-pdo-pgsql –with-gettext –with-curl –with-mbstring –enable-sockets –enable-bcmath –enable-xml –with-bz2 –enable-zip –enable-freetype –enable-xmlrpc
再次配置遇到新错误:
configure: error: Please reinstall the BZip2 distribution
解决方法:
yum install bzip2-devel
遇到错误再安装:
configure: error: Please reinstall the libcurl distribution -
easy.h should be in
[root@localhost php-5.4.41]# yum install libcurl libcurl-devel
configure: error: jpeglib.h not found.
安装一些相关库
yum install libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel
configure: error: mcrypt.h not found. Please reinstall libmcrypt
居然没有可用的包
[root@localhost php-5.4.41]# yum install libmcrypt-devel
Loaded plugins: fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
Loading mirror speeds from cached hostfile
- base: mirrors.aliyun.com
- extras: mirrors.aliyun.com
- updates: mirrors.aliyun.com
No package libmcrypt-devel available.
wget http://www.atomicorp.com/installers/atomic
sh ./atomic
sed -i ‘s/\$releasever/6/g’ /etc/yum.repos.d/atomic.repo
再次执行:
yum install libmcrypt libmcrypt-devel
configure: error: Cannot find libpq-fe.h. Please specify correct PostgreSQL installation path
yum install postgresql-devel
configure: WARNING: unrecognized options: –with-mbstring, –enable-freetype, –enable-xmlrpc
./configure –prefix=/usr/local/php –enable-fpm –with-mcrypt=/usr/local/libmcrypt –with-zlib –enable-mbstring –with-openssl –with-mysql –with-mysqli –with-mysql-sock –with-gd –with-jpeg-dir=/usr/lib –enable-gd-native-ttf –enable-pdo –with-pdo-mysql –with-pdo-pgsql –with-pgsql –with-gettext –with-curl –enable-sockets –enable-bcmath –enable-xml –with-bz2 –enable-zip –with-apxs2=/usr/local/apache2/bin/apxs
没有报错了,
make;make install
使Apache支持PHP
cd /usr/local/apache2/conf。 编辑文件:vi httpd.conf
查找字符串AddType,并增加
AddType application/x-httpd-php .php .php3 .htm .phtml .php4
AddType application/x-httpd-php-source .phps
然后重启apache使配置生效
查找字符串DirectoryIndex,并修改为 DirectoryIndex index.html index.php3 index.php default.php
cp /root/php-5.4.41/php.ini-development /usr/local/php/lib/php.ini
查找extension=
去掉要打开的库前面的分号
测试PHP vi /usr/local/apache2/htdocs/index.php
< ?php
phpinfo();
?>
附录:网上找的php各个版本的编译参数如下。
Fast-CGI:
./configure –prefix=/usr/local/php –enable-fastcgi –enable-force-cgi-redirect –with-config-file-path=/etc –with-zlib –with-mysql –with-xml –with-gd –enable-gd-native-ttf –enable-gd-jis-conv –with-freetype-dir –with-jpeg-dir –with-png-dir –enable-mbstring
PHP4-Server:
./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs –with-mysql –with-config-file-path=/etc –with-gd –enable-gd-native-ttf –enable-gd-jis-conv –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –enable-xml –enable-mbstring
PHP4-Max:
./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache/bin/apxs –mandir=/usr/share/man –with-mysql=/usr/local/mysql –with-config-file-path=/usr/local/php/etc –with-openssl=/usr/local/openssl-0.9.7e –with-gd –enable-gd-native-ttf –enable-gd-jis-conv –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib –with-bz2 –with-inifile –with-hyperwave –enable-xml –enable-track-vars –enable-dba –enable-dbase –enable-filepro –enable-ftp –enable-versioning –enable-memory-limit –enable-calendar –enable-session –enable-sockets –enable-sysmsg –enable-sysvsem –enable-sysvshm –enable-tokenizer –enable-overload –enable-ctype –enable-sigchild –enable-magic-quotes –enable-roxen-zts –enable-fastcgi –enable-dbx –enable-dio –enable-shmop –enable-mbstring
PHP5-Server:
./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache2/bin/apxs –with-zlib-dir –with-bz2 –with-tiff-dir –with-libxml-dir –with-gd –with-freetype-dir –with-jpeg-dir –with-png-dir –with-ttf –enable-mbstring –with-mysql=/usr/lib/mysql –with-config-file-path=/etc –disable-ipv6 –enable-gd-native-ttf
PHP5-Standard:
./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache/bin/apxs –mandir=/usr/share/man –with-openssl=/usr/local/openssl-0.9.7e –with-zlib –with-bz2 –with-tiff-dir –with-libxml-dir –enable-dio –enable-ftp –with-gd –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib-dir –with-bz2-dir –with-ttf –enable-mbstring –with-mysql=/usr/local/mysql –with-config-file-path=/usr/local/php/etc –disable-ipv6 –enable-gd-native-ttf
PHP5-Max:
./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache/bin/apxs –mandir=/usr/share/man –with-openssl=/usr/local/openssl-0.9.7e –with-zlib –with-bz2 –with-tiff-dir –with-libxml-dir –enable-dio –enable-ftp –with-gd –with-freetype-dir –with-jpeg-dir –with-png-dir –with-zlib-dir –with-bz2-dir –with-ttf –with-inifile –enable-dba –enable-dbase –enable-filepro –enable-versioning –enable-memory-limit –enable-calendar –enable-sockets –enable-sysvsem –enable-sigchild –enable-magic-quotes –enable-roxen-zts –enable-fastcgi –enable-dbx –enable-shmop –enable-mbstring –with-mysql=/usr/local/mysql –with-config-file-path=/usr/local/php/etc –disable-ipv6 –enable-gd-native-ttf