[root@wadeson ~]# /usr/local/apache2.4/bin/httpd -V
AH00557: httpd: apr_sockaddr_info_get() failed for wadeson
AH00558: httpd: Could not reliably determine the server‘s fully qualified domain name, using 127.0.0.1. Set the ‘ServerName‘ directive globally to suppress this message
Server version: Apache/2.4.25 (Unix)
Server built: Jul 7 2017 00:38:29
Server‘s Module Magic Number: 20120211:67
Server loaded: APR 1.6.2, APR-UTIL 1.6.0
Compiled using: APR 1.6.2, APR-UTIL 1.6.0
Architecture: 64-bit
Server MPM: prefork 支持的prefork模块,于是php没有上述选项
threaded: no
forked: yes (variable process count)
Server compiled with....
-D APR_HAS_SENDFILE
-D APR_HAS_MMAP
-D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
-D APR_USE_SYSVSEM_SERIALIZE
-D APR_USE_PTHREAD_SERIALIZE
-D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
-D APR_HAS_OTHER_CHILD
-D AP_HAVE_RELIABLE_PIPED_LOGS
-D DYNAMIC_MODULE_LIMIT=256
-D HTTPD_ROOT="/usr/local/apache2.4"
-D SUEXEC_BIN="/usr/local/apache2.4/bin/suexec"
-D DEFAULT_PIDLOG="logs/httpd.pid"
-D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
-D DEFAULT_ERRORLOG="logs/error_log"
-D AP_TYPES_CONFIG_FILE="/etc/httpd2.4/mime.types"
-D SERVER_CONFIG_FILE="/etc/httpd2.4/httpd.conf"
复制php.ini主配置文件:
cp php.ini-production /etc/php.ini
然后将httpd与php进行连接,因为httpd是编译安装的2.4的版本:
[root@wadeson httpd2.4]# pwd
/etc/httpd2.4
[root@wadeson httpd2.4]# ll
total 124
drwxr-xr-x. 2 root root 4096 Jul 7 00:40 extra
-rw-r--r--. 1 root root 18991 Jul 7 16:22 httpd.conf
-rw-r--r--. 1 root root 18759 Jul 7 15:46 httpd.conf.bak
-rw-r--r--. 1 root root 13077 Jul 7 00:40 magic
-rw-r--r--. 1 root root 60855 Jul 7 00:40 mime.types
drwxr-xr-x. 3 root root 4096 Jul 7 00:40 original
在http.conf配置文件中加入以下:
DirectoryIndex index.html index.php
AddType application/x-httpd-php-source .phps
AddHandler php5-script .php
AddType text/html .php
并且确认php的模块已经被启用:(因为这种模式是和httpd模块的方式)
LoadModule php5_module modules/libphp5.so (这是针对prefork模式)
区分:
<IfModule prefork.c>
LoadModule php5_module modules/libphp5.so
</IfModule>
<IfModule worker.c>
LoadModule php5_module modules/libphp5-zts.so
然后在网站目录编写index.php测试页面:
[root@wadeson htdocs]# cat index.php
<?php
phpinfo();
?>
然后测试是否与数据库mysql连接:
[root@wadeson htdocs]# vim index.php
<?php
phpinfo();
$link = mysql_connect(‘127.0.0.1‘,‘root‘,‘‘);
if ($link)
echo "successful";
else
echo "failure";
mysql_close()
?>
/usr/local/php/bin/php -i:查看所有配置信息
为php5.6增加xcache模块:
tar xf xcache-3.0.1.tar.gz
cd xcache-3.0.1
/usr/local/php/bin/phpize
./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
make && make install 后执行报错
报错如下:
.0.1/xcache.c -fPIC -DPIC -o .libs/xcache.o
/root/tools/xcache-3.0.1/xcache.c: In function ??zif_xcache_get_special_value?ˉ:
/root/tools/xcache-3.0.1/xcache.c:324: error: ??IS_CONSTANT_ARRAY?ˉ undeclared (first use in this function)
/root/tools/xcache-3.0.1/xcache.c:324: error: (Each undeclared identifier is reported only once
/root/tools/xcache-3.0.1/xcache.c:324: error: for each function it appears in.)
make: *** [xcache.lo] Error 1
上面的内容会报错,原因是php5.6 xcache3.0并不支持,所以官网下载最新版,所以还是多去官网或权威网站比较好
于是下载新版本:
tar xf xcache-3.2.0.tar.gz
cd xcache-3.2.0
/usr/local/php/bin/phpize
./configure --enable-xcache --with-php-config=/usr/local/php/bin/php-config
make && make install
出现下面所示:
Installing shared extensions: /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
[root@wadeson xcache-3.2.0]# ll /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/
total 1264
-rwxr-xr-x. 1 root root 589332 Jul 7 15:46 opcache.so
-rwxr-xr-x. 1 root root 701379 Jul 7 16:48 xcache.so
把主配置文件放到php的碎片配置小分队
[root@wadeson xcache-3.2.0]# mkdir /etc/php.d
[root@wadeson xcache-3.2.0]# cp xcache.ini /etc/php.d/
修改/etc/php.d/xcache.ini文件中的指定地方
extension = /usr/local/php/lib/php/extensions/no-debug-non-zts-20131226/xcache.so
重启服务:
[root@wadeson httpd2.4]# /usr/local/apache2.4/bin/apachectl restart
于是整个lamp环境已经编译成功
note:
如果在编译php遇见了其他错误可以参考如下内容:
http://www.poluoluo.com/jzxy/201505/364819.html