900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > linux版php运行环境 Linux系统搭建PHP运行环境

linux版php运行环境 Linux系统搭建PHP运行环境

时间:2020-08-14 20:45:48

相关推荐

linux版php运行环境 Linux系统搭建PHP运行环境

LAMP网站架构是目前国际流行的 Web 框架,该框架包括:Linux 操作系统,Apache 网络服务器,MySQL 数据库,所有组成产品均是开源软件,是国际上成熟的架构框架。

最近我在百度智能云上购买了一个服务器,需要搭建PHP网站运行环境(LAMP——Linux、Apache、MySQL、PHP)。现在,将搭建过程和遇到的问题记录一下,方便以后查看。本次搭建使用的是Linux系统的CentOS6版本和CentOS7版本,两个版本有什么不同将在安装各个软件详细说明。

服务器配置

操作系统

1、概述

服务器配置和操作系统:

服务器配置:1核CPU1G内存1Mbps带宽40G系统盘

操作系统:CentOS / 7.2 x86_64 (64bit)

这次搭建所使用的系统是Linux系统,安装的软件版本如下:

Apache: 2.4.6-88.el7.centos

MySQL:5.6.43 MySQL Community Server (GPL)

PHP:PHP 5.6.40 (cli)

2、安装Apache

为了方便起见,Linux系统中有默认的Apache版本,就不需要进行安装,只要启动Apache服务即可。

CentOS6版本默认的Apache版本:Apache2.2

CentOS7版本默认的Apache版本:Apache2.4

CentOS6下Apache启动、停止、重启

启动服务:service httpd start

停止服务:service httpd stop

重新启动:service httpd restart

CentOS7下Apache启动、停止、重启

启动服务:/bin/systemctl start httpd.service

停止服务:/bin/systemctl stop httpd.service

重新启动:/bin/systemctl restart httpd.service

设为开机启动

chkconfig httpd on

检查是否安装Apache

rpm -qa | grep httpd

3、安装Mysql

安装版本:5.6.43 MySQL Community Server (GPL)

(1)、检查系统是否已安装

yum list installed | grep mysql

(2)、如果发现有系统已安装,使用如下命令进行删除

yum -y remove 安装包名

(3)、下载mysql-community-release-el6-5.noarch.rpm包

wget /mysql-community-release-el6-5.noarch.rpm

(4)、执行mysql-community-release-el6-5.noarch.rpm包,获取mysql-community-source.repo和mysql-community.repo

rpm -ivh mysql-community-release-el6-5.noarch.rpm

(5)、用yum repolist mysql这个命令查看一下是否已经有mysql可安装文件

yum repolist all | grep mysql

(6)、安装mysql 服务器命令(一路yes)

yum install mysql-community-server

(7)、设置密码

mysql -u root

use mysql;

update user set password=PASSWORD("这里输入root用户密码") where User='root';

flush privileges;

(8)、设置开机启动

chkconfig --list | grep mysqld

chkconfig mysqld on

4、安装PHP

(1)、配置yum源

CentOS 6.5的epel及remi源:

rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm

rpm -Uvh /enterprise/remi-release-6.rpm

CentOS 7的epel及remi源:

yum install epel-release

rpm -ivh /enterprise/remi-release-7.rpm

使用yum list命令查看可安装的包(Packege)

yum list --enablerepo=remi --enablerepo=remi-php56 | grep php

(2)、安装PHP5.6

yum源配置好了,下一步就安装PHP5.6,执行下面命令一路yes即可。

yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof

查看PHP版本

php --version

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。