linux安装php开发环境(Centos7)

安装PHP开发环境,有多种方法,我这里介绍两种常见的方法。
安装前先安装php所需要的依赖:

yum -y install libxml2 libxml2-devel openssl openssl-devel libcurl libcurl-devel install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel

在这里插入图片描述
一、源码安装。
1、下载,地址为:https://www.php.net:
在这里插入图片描述
这里下载这个版本:
在这里插入图片描述
如果需要下载其他的版本,可以在这个页面往下拉,找到需要的版本即可。
在这里插入图片描述
2、下载方式:这里选择wget方式下载,如果是某某会员的话,可以先下载后再上传。
在这里插入图片描述
下载:
首先linux要有wget下载工具,如果没有,利用yum工具安装:
yum -y install wget:
在这里插入图片描述
yum源的更换这里不做介绍,系统本身自带的是国外的源,所以建议换成国内的阿里云或者网易的或者其他的。
然后就是下载:
在这里插入图片描述
下载完成后:

3、安装:
解压:tar -zxvf php-7.0.0.tar.gz,解压后:
在这里插入图片描述
进入php-7.0.0目录,cd php-7.0.0:
在这里插入图片描述
编译安装:

./configure --prefix=/usr/local/php

在这里插入图片描述
然后安装:
在这里插入图片描述
缺少gcc:
yum -y install gcc gcc-c++:
在这里插入图片描述
安装完成重新编译安装php:
结果如下:
在这里插入图片描述
make && make install
在这里插入图片描述
在这里插入图片描述

4、安装之后:
在这里插入图片描述
5、查看安装php的版本:
在这里插入图片描述
6、添加系统环境变量;
vim /etc/profile
在这里插入图片描述
在这里插入图片描述
然后:
source /etc/profile
在这里插入图片描述

二、利用工具安装(yum)。
yum -y install php
这样一般安装的是不是自己指定的版本,所以根据自己的需求来实现即可。

三、卸载
如果是yum 安装的,就用yum来卸载或者用
yum remove php
rpm -qa | grep php --查看安装的包
rpm -e 安装包 -----卸载安装的包

如果是源码安装的话,停掉服务,删除配置安装目录,和配置即可。

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以使用 LAMP 或 LNMP 等一键安装包来快速搭建 CentOS 上的 PHP 开发环境。 LAMP(Linux + Apache + MySQL + PHP)是常用的一键安装包,以下是安装步骤: 1. 安装 Apache ```bash yum install httpd -y systemctl start httpd systemctl enable httpd ``` 2. 安装 MySQL ```bash yum install mariadb-server mariadb -y systemctl start mariadb systemctl enable mariadb mysql_secure_installation ``` 3. 安装 PHP ```bash yum install php php-mysql php-devel php-gd php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml -y ``` 4. 配置 PHP 编辑 `/etc/httpd/conf.d/php.conf` 文件,将以下内容复制到文件末尾: ``` <FilesMatch \.php$> SetHandler application/x-httpd-php </FilesMatch> ``` 重启 Apache: ```bash systemctl restart httpd ``` LNMP(Linux + Nginx + MySQL + PHP)也是常用的一键安装包,以下是安装步骤: 1. 安装 Nginx ```bash yum install nginx -y systemctl start nginx systemctl enable nginx ``` 2. 安装 MySQL 参考 LAMP 安装步骤。 3. 安装 PHP ```bash yum install php-fpm php-mysql php-devel php-gd php-pecl-memcache php-pspell php-snmp php-xmlrpc php-xml -y ``` 4. 配置 Nginx 和 PHP 编辑 `/etc/nginx/conf.d/default.conf` 文件,将以下内容复制到文件中: ``` location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } ``` 编辑 `/etc/php-fpm.d/www.conf` 文件,将以下内容修改为: ``` listen = 127.0.0.1:9000 ``` 重启 Nginx 和 PHP-FPM: ```bash systemctl restart nginx systemctl restart php-fpm ``` 以上是简单的一键安装步骤,如果需要更复杂的配置,可以参考相关文档进行设置。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值