centos6 yum安装apache+php7

一、 环境

Linux操作系统: centos6.9

Apache版本: Apache2.2

 

二、 安装步骤

1、 检查系统上是否有旧版本的apache

[root@VM_0_11_centos ~]# rpm -qa httpd

      如果有旧版本就执行卸载

[root@VM_0_11_centos ~]# rpm -e httpd

2、 查看yum上的apache版本

[root@VM_0_11_centos ~]# yum list httpd
Loaded plugins: fastestmirror, priorities, security
Repository epel is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * webtatic: uk.repo.webtatic.com
Available Packages
httpd.x86_64                                                2.2.15-69.el6.centos   

3、 安装apache2.2

[root@VM_0_11_centos ~]# yum install httpd

4、 启动apache(默认端口为80)

[root@VM_0_11_centos httpd]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                           [  OK  ]

5、 访问apache

centos6 yum安装apache+php7_第1张图片

6、 apahce 主要配置目录

[root@VM_0_11_centos httpd]# cd /etc/httpd/

7、 服务器默认部署根目录

[root@VM_0_11_centos httpd]# cd /var/www/html/

8、 设置开机自动启动

[root@VM_0_11_centos html]# chkconfig --add httpd

9、 监听端口修改(默认 80)

[root@VM_0_11_centos ~]# vi /etc/httpd/conf/httpd.conf

  centos6 yum安装apache+php7_第2张图片

三、支持php

1、 安装php7环境

先卸载掉旧版本的php,查看系统上所有的关于php的安装包

[root@VM_0_11_centos httpd]# rpm -qa|grep php 
php71w-common-7.1.18-1.w6.x86_64
php71w-cli-7.1.18-1.w6.x86_64
php71w-pdo-7.1.18-1.w6.x86_64
php71w-gd-7.1.18-1.w6.x86_64
php71w-mbstring-7.1.18-1.w6.x86_64
php71w-mcrypt-7.1.18-1.w6.x86_64
php71w-ldap-7.1.18-1.w6.x86_64
php71w-mysql-7.1.18-1.w6.x86_64
php71w-fpm-7.1.18-1.w6.x86_64

    按顺序卸载

[root@VM_0_11_centos httpd]# rpm -e php71w-mysql-7.1.18-1.w6.x86_64
[root@VM_0_11_centos httpd]# rpm -e php71w-pdo-7.1.18-1.w6.x86_64
[root@VM_0_11_centos httpd]# rpm -e php71w-cli-7.1.18-1.w6.x86_64
[root@VM_0_11_centos httpd]# rpm -e php71w-gd-7.1.18-1.w6.x86_64
[root@VM_0_11_centos httpd]# rpm -e php71w-mcrypt-7.1.18-1.w6.x86_64
[root@VM_0_11_centos httpd]# rpm -e php71w-mbstring-7.1.18-1.w6.x86_64
[root@VM_0_11_centos httpd]# rpm -e php71w-ldap-7.1.18-1.w6.x86_64
[root@VM_0_11_centos httpd]# rpm -e php71w-fpm-7.1.18-1.w6.x86_64
[root@VM_0_11_centos httpd]# rpm -e php71w-common-7.1.18-1.w6.x86_64

查询是否卸载干净

[root@VM_0_11_centos httpd]# php -v
-bash: /usr/bin/php: No such file or directory

卸载干净后,开始安装php7

  安装epel-release

[root@VM_0_11_centos httpd]# yum -y install epel-release

  获取php7的yum源

[root@VM_0_11_centos ~]# rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm

  安装php7

[root@VM_0_11_centos ~]# yum install php70w

  验证php是否安装完成

[root@VM_0_11_centos ~]# php -v
PHP 7.0.30 (cli) (built: Apr 28 2018 10:41:40) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

 

3、 重启httpd服务

[root@VM_0_11_centos httpd]# service httpd restart         
Stopping httpd:                                            [  OK  ]
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
                                                           [  OK  ]

4、 在服务器根目录创建index.php

5、 打开浏览器访问index.php

        ip地址 / index.php

centos6 yum安装apache+php7_第3张图片

6、 php7的扩展

[root@VM_0_11_centos html]# yum install php70w.x86_64 php70w-bcmath.x86_64 php70w-cli.x86_64 php70w-common.x86_64 php70w-dba.x86_64 php70w-devel.x86_64 php70w-embedded.x86_64 php70w-enchant.x86_64 php70w-fpm.x86_64 php70w-gd.x86_64 php70w-imap.x86_64 php70w-ldap.x86_64 php70w-mbstring.x86_64 php70w-mcrypt.x86_64 php70w-mysqlnd.x86_64 php70w-odbc.x86_64 php70w-opcache.x86_64 php70w-pdo.x86_64 php70w-pdo_dblib.x86_64 php70w-pear.noarch php70w-pecl-apcu.x86_64 php70w-pecl-apcu-devel.x86_64 php70w-pecl-imagick.x86_64 php70w-pecl-imagick-devel.x86_64 php70w-pecl-mongodb.x86_64 php70w-pecl-redis.x86_64 php70w-pecl-xdebug.x86_64 php70w-pgsql.x86_64 php70w-xml.x86_64 php70w-xmlrpc.x86_64 nginx php70w-intl -y
[root@VM_0_11_centos html]# yum install php70w-mysqlnd.x86_64

 

你可能感兴趣的:(服务器配置)