ubu下编译安装php7

第一步:

安装依赖库zlib、libpng、freetype、jpegsrc、libxml2、libgd、freetds、mhash、libmcrypt、mcrypt(依赖于mhash和libmcrypt)

 

第二步:

tar zxvf php.tar.gz
 cd php
 ./configure --prefix=/usr/local/php5 --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-gd=/usr/local/libgd --enable-gd-native-ttf --with-ttf --enable-gd-jis-conv --with-freetype-dir=/usr/local/freetype --with-jpeg-dir=/usr/local/libjpeg --with-png-dir=/usr/local/libpng --with-libxml-dir=/usr/local/libxml2 --with-zlib-dir=/usr/local/zlib --enable-xml --enable-mbstring --enable-sockets --with-mssql=/usr/local/freetds/ --with-curl=/usr/local/curl --with-mcrypt=/usr/local/mcrypt/  --with-openssl

 make
 make install

 

第三步:结合php配置Apache

Apache主配置文件为:/usr/local/apache2/conf/httpd.conf
# vim /usr/local/apache2/conf/httpd.conf
找到:
AddType application/x-gzip .gz .tgz
在该行下面添加
AddType application/x-httpd-php .php

找到:
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>
将该行改为
<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php
</IfModule>

找到:
#Include conf/extra/httpd-mpm.conf
#Include conf/extra/httpd-info.conf
#Include conf/extra/httpd-vhosts.conf
#Include conf/extra/httpd-default.conf
去掉前面的“#”号,取消注释。

 

第四步:

配置文件为:/usr/local/apache2/conf/extra/httpd-vhosts.conf
将配置文件中下面一段修改为如下:
<VirtualHost *:80>
   # ServerAdmin webmaster@dummy-host.example.com
    DocumentRoot "/data/www"
    ServerName www.example.com.cn
    ErrorLog "|/usr/local/apache2/bin/rotatelogs -l /www/logs/error.log-%Y%m%d 86400"
   CustomLog "|/usr/local/apache2/bin/rotatelogs -l /www/logs/access.log-%Y%m%d 86400" combined
   </VirtualHost>

说明:
ServerAdmin 参数后为管理员email
DocumentRoot 指的是论坛文件存放的目录
ServerName  是论坛的域名
ErrorLog 是论坛错误日志  通过管道使用apache自带的rotatelogs工具将日志切割为每天一个文件
CustomLog 是论坛访问日志,同样切割为每天一个文件

 

配置Apache缺省httpd设置
配置文件为:/usr/local/apache2/conf/extra/httpd-default.conf
将配置文件中下面一段:
将KeepAlive On 改为KeepAlive Off

配置Apache的访问权限
vim /usr/local/apache2/conf/httpd.conf
找到
<Directory />
Options FollowSymlinks
AllowOverride None
Order deny,allow
Deny form all
</Directory>
改成:
<Directory />
Options FollowSymlinks
AllowOverride None
Order deny,allow
Allow from all
</Directory>

配置apache运行账户:useradd www

vim  /usr/local/apache2/conf/httpd.conf
找到
User  daemon
Group daemon
改成
User www
Group www

配置完上述内容之后,启动Apache:

/usr/local/apache2/bin/apachectl start

 

 

测试LAMP是否成功

vim /data/www/1.php

写入:

<?php 
phpinfo();
?>

输入http://localhost:80/1.php,是否能显示php信息

posted on 2016-10-17 15:15  小马哥哥的哥哥  阅读(112)  评论(0编辑  收藏  举报

导航