centos7 php7 httpd
安装php之前,要先安装几个
1.下载php源码:http://cn2.php.net/distributions/php-7.0.6.tar.gz。
2.然后使用命令:tar -zxvf php-7.0.6.tar.gz,进行解压。
3.使用php时还要先安装几个其他的东西,否则安装会出错,或者不生成php.so扩展文件,
先从ftp://xmlsoft.org/libxml2/libxml2-2.7.2.tar.gz下载这个插件,注意不要下载最新版本除非需要,版本越新需要的依赖越多,下载完成后使用tar解压,
执行1../configure,2.make,3.make install ,三个命令来编译安装这个东西。
然后检查是否安装了httpd_devel,如果没有安装,执行yum install httpd-devel,进行安装,如果不安装的话,后期不会生成.so的扩展文件。
4.进入解压完的php文件,然后根据自己的需要,来配置./configure的参数
./configure \
--prefix=/usr/local/php7 \
--exec-prefix=/usr/local/php7 \
--bindir=/usr/local/php7/bin \
--sbindir=/usr/local/php7/sbin \
--includedir=/usr/local/php7/include \
--libdir=/usr/local/php7/lib/php \
--mandir=/usr/local/php7/php/man \
--with-config-file-path=/usr/local/php7/etc \
--with-mysql-sock=/var/run/mysql/mysql.sock \
--with-mcrypt=/usr/include \
--with-mhash \
--with-openssl \
--with-pdo-mysql=shared,mysqlnd \
--with-mysqli=shared,mysqlnd \
--with-pdo-mysql=shared,mysqlnd \
--with-gd \
--with-iconv \
--with-zlib \
--enable-zip \
--enable-inline-optimization \
--disable-debug \
--disable-rpath \
--enable-shared \
--enable-xml \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-mbregex \
--enable-mbstring \
--enable-ftp \
--enable-gd-native-ttf \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-soap \
--without-pear \
--with-gettext \
--enable-session \
--with-curl \
--with-jpeg-dir \
--with-freetype-dir \
--enable-fpm \
--without-gdbm \
--enable-opcache=no \
--disable-fileinfo
注意,每个参数都可能会有依赖,比如:--with-zlib \ --enable-zip,是需要事先安装对应文件的,如果不需要,可以不指定对应参数,最好指定的编译参数是:--prefix --with-mysqli --with-apxs2 。
编译完成如果么有错误,那就执行 make && make install .如果报错,看是否是缺少什么依赖,在重新编译前,先执行:make clean,否则可能会产生错误,错误信息:***lo' is not a valid libtool object。
5.复制配置文件:php的推荐配置文件,已经存在于源码文件中了,使用find命令查找一下,一般是两个:php.ini-production,php.ini-development,至于将那个当配置使用,就看自己的了。
6.根据安装位置,将对应的php文件位置添加到PATH中,文件位置:/etc/profile,在最后添加:
PATH=$PATH:/usr/local/webserver/php/bin:/usr/local/webserver/mysql/bin -- 注意添加的不是php可执行的本身,而是上一级目录,否则不能使用,
export PATH
最后执行source /etc/profile 重新加载配置文件,然后echo $PATH,来看路径是否添加进了环境变量。
7.以上修改完毕之后应该是已经可以在本地执行php文件了,如果不能,则是有问题,要查看是php文件,还是path路径配置问题。
8.配置httpd.conf文件,
在配置文件中搜素: AddType 关键字,在其后面追加下面三行,如果不追加,httpd会直接打印php文件内容,不会调用php执行。
AddType application/x-httpd-php .php
AddType application/x-httpd-php .php .phtml .php3
AddType application/x-httpd-php-source .phps
接下来添加默认搜索php文件,在配置文件中查找DirectoryIndex 关键字,如果后面没有index.php,就在后面追加index.php,这样httpd才能默认访问php文件
接下来添加对php的支持,搜索LoadModule关键字,添加:LoadModule php7_module modules/libphp7.so,如果后期出现不能加载libphp7.so,则表示php编译有问题,最大可能就是没添加--with-apxs2参数,或者设置错误,需要重编php源码文件,直到能 在系统内搜索到libphp7.so为止。
在httpd.conf内最好手动执行php的配置文件位置,方式为PHPIniDir "/usr/local/php7/bin",这样能保证重启httpd服务的时候,重新装载对的php配置。
以上完成之后应该是配置完毕,找到index.html正确位置,添加index.php文件并将其他命名为index的文件改成其他名字,否则默认不会加载index.php,在index.php中添加代码
<?php
phpinfo();
?>
然后重启httpd服务器,使用IP访问测试,如果不行,先检查防火墙是否关闭,或者开放了指定的端口。
测试端口是否打开:firewall-cmd --query-port=80/tcp
打开指定端口:firewall-cmd --add-port=80/tcp
或者直接关闭防火墙:
systemctl start firewalld.service#启动firewall
systemctl stop firewalld.service#停止firewall
systemctl disable firewalld.service#禁止firewall开机启动
编译过程中可能出现的错误和解决办法:
运行之后遇到的问题:
error 1
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 installation.
(看提示就明白 是一个lib库没装 先用 yum search 名字 看是否能搜到名字 ,找到名字后 把软件包 开发包装上)
解决办法
yum install libxml2-devel.x86_64
error 2
checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's <evp.h>
这是ssl没装
解决办法
yum install openssl.x86_64 openssl-devel.x86_64 -y
error 3
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution
这是bzip2软件包没有安装
解决办法
yum install bzip2-devel.x86_64 -y
error 4
configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
curl和curl库文件没有安装
解决办法
yum install libcurl.x86_64 libcurl-devel.x86_64 -y
error 5
checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... yes
checking for floorf... yes
configure: error: jpeglib.h not found
GD库没有安装
解决办法
yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y
error 6
checking for stdarg.h... (cached) yes
checking for mcrypt support... yes
configure: error: mcrypt.h not found. Please reinstall libmcrypt.
libmcrypt库没有安装 ,要是不能用yun安装的话 就要去下载个gz包 自己编译安装
(编译安装 ./configure --piefix=/usr/local/libmcrypt make && make install)
要是错误里面含有mysql的 那是mysql-devel 没有安装
centos7 php7 httpd的更多相关文章
- centos7启动httpd服务失败:Job for httpd.service failed because the control process exited with error code.
centos7启动httpd命令有两个可以用 service httpd start systemctl start httpd.service 如果出现如下报错 Job for httpd.s ...
- centos7 + php7 lamp全套最新版本配置,还有mongodb和redis
我是个懒人,能yum就yum啦 所有软件的版本一直会升级,注意自己当时的版本是不是已经更新了. 首先装centos7 如果你忘了设置swap分区,下面的文章可以教你怎么补一个上去: http://ww ...
- centos7 apache httpd安装和配置django项目
一.安装httpd服务 apache在centos7中是Apache HTTP server.如下对httpd的解释就是Apache HTTP Server.所以想安装apache其实是要安装http ...
- php7 httpd 2.4 编译
1.获取源码httpd-2.4.23.tar.gz php-7.1.0.tar.gz,安装顺序必须是先安装http然后php,lnmp同理 2.安装编译环境和php.httpd依赖包,红色字体 ...
- centos7安装httpd和php
centos7许多命令都变了,又要重新记了. centos7默认安装了httpd吧?记不清了,看一下: rpm -qa |grep httpd 没有的话,安装一下吧. yum -y install h ...
- CentOS7配置httpd虚拟主机
本实验旨在CentOS7系统中,httpd-2.4配置两台虚拟主机,主要有以下要求: (1) 提供两个基于名称的虚拟主机: www1.stuX.com,页面文件目录为/web/vhosts/www1: ...
- CentOS7使用httpd apache 和firewalld打开关闭防火墙与端口
Centos7 使用systemctl 工具操作命令 systemctl 是Centos7的服务管理工具中的主要工具 ,它融合之前service和chkconfig的功能于一体 一.httpd的设置 ...
- centos7+php7 swoole 安装
下载 swoole 首先下载swoole的源码包,这个操作很简单,没有太多说的. wget -c https://github.com/swoole/swoole-src/archive/v2.0.6 ...
- 安装最新LAMP环境(CentOS7+PHP7.1.5+Mysql5.7)
安装Apache&Nginx ①.升级一下yum源(不是必须的),升级会花点时间,需要选择的地方都选择都输入“y”即可 yum update ②. 安装Apache yum list |gre ...
随机推荐
- hdu.1044.Collect More Jewels(bfs + 状态压缩)
Collect More Jewels Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Othe ...
- springmvc之前后台传值
一.向后台传值 1.项目结构 2.jar包 3.spring-config.xml <?xml version="1.0" encoding="UTF-8" ...
- springmvc之log4j
1.工程结构 2.所需jar包 3.web.xml <?xml version="1.0" encoding="UTF-8"?> <web-a ...
- Code First04---关于上下文DbContext
这章主要讲怎么配置DbContext的子类访问的数据库的位置. 我相信大家最经常使用的数据库位置的配置方式就是配置文件了,也就是通过App.Config 或Web.Config来配置要访问的数据库. ...
- spring边边角角
我们在使用ssh框架的时候,很多人抱怨为什么之前都运行得好好的,第二天就报错了,我也是被这个问题纠结了很久. 我们来看看spring的配置文件: <?xml version="1.0& ...
- (原创)用Receiver和SystemService监听网络状态,注册Receiver的两种方式
android中网络编程不可避免地要监听网络状态,wifi或者3G以及以太网,并根据当前状态做出相应决策. 在MyReceiver类中的onReceive方法中获得系统服务 ConnectivityM ...
- BZOJ 4516: [Sdoi2016]生成魔咒
Description 给出一串数字,求每次插入一个数字后本质不同的子串. Sol SAM. 在 SAM 上添加节点的时候统计一下 \(val[np]-val[par[np]]\) 就可以了... 用 ...
- linux/windows下启用和停止VMware后台服务的脚本
linux/windows下启用和停止VMware后台服务的脚本 linux/windows下启用和停止VMware后台服务的脚本 linux平台 windows平台 本文由乌合之众 lym瞎编,欢迎 ...
- Yii中的错误及异常处理
Yii中的错误及异常处理 Yii已经默认已经在CApplication上实现了异常和错误的接管,这是通过php的set_exception_handler, set_error_handler实现的. ...
- 转帖:用五分钟重温委托,匿名方法,Lambda,泛型委托,表达式树
用五分钟重温委托,匿名方法,Lambda,泛型委托,表达式树 这些对老一代的程序员都是老生常谈的东西,没什么新意,对新生代的程序员却充满着魅力.曾经新生代,好多都经过漫长的学习,理解,实践才能掌握委托 ...