centos7.3安装php7.0

需求:在Centos7.3下搭建LNMP环境

文章转载自:http://blog.csdn.net/wszll_alex/article/details/76285324  作者:狂热森林
1. 关闭防火墙和selinux

打开文件selinux

vim  /etc/sysconfig/selinux

将文件中SELINUX=enforcing改为disabled,然后执行”setenforce 0″不用重启地关闭selinux。

SELINUX=disabled

关闭放火墙

systemctl stop firewalld.service

2.安装软件
2.1.MYSQL安装

下载MySQL的repo源

wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm

安装mysql-community-release-el7-5.noarch.rpm包

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

安装MYSQL

? sudo yum install -y  mysql-server

? 更改MYSQL用户权限:

sudo chown -R root:root /var/lib/mysql

? 重启服务:

systemctl restart mysql.service

登录,并修改密码:

mysql -u root
mysql > use mysql;
mysql > update user set password=password(‘123456‘) where user=‘root‘;
mysql > exit;

2.2nginx安装

下载对应当前系统版本的nginx包

? wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

建立nginx的yum仓库(默认yum是没有nginx的)

 rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm

下载并安装nginx

? yum install -y nginx

nginx启动

? systemctl start nginx.service

2.3安装php

rpm 安装 Php7 相应的 yum源

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

安装php7.0

yum install -y php70w

安装PHP扩展

yum install -y  php70w-mysql.x86_64   php70w-gd.x86_64   php70w-ldap.x86_64   php70w-mbstring.x86_64  php70w-mcrypt.x86_64

安装php FPM

? yum install -y php70w-fpm

3. 修改配置文件
3.1修改Nginx配置文件

nginx配置文件位置:(/etc/nginx/conf.d/default.conf)

vim /etc/nginx/conf.d/default.conf

? 修改 root目录,可自定义:

root   /forest/nginxDir/html;

? 配置php解析,修改 下面代码中黑色加粗部分:

 location ~.php$ {
 root   /forest/nginxDir/html;
? fastcgi_pass 127.0.0.1:9000;
? fastcgi_index index.php;
 ?fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
? include    fastcgi_params;
? }

3.2 修改php-fpm配置文件

php-fpm配置文件位置:(/etc/php-fpm.d/www.conf)
? 修改

user =nginx
? group=nginx

4.放入测试文件

cd /forest/nginxDir/html
echo ‘hello eric‘ >index.php

5.启动服务
5.1启动nginx服务:

systemctl start nginx.service

? 查看启动状态:

systemctl status nginx  

看到以下字眼说明启动成功!
?Active: active (running) since 六 2016-11-19 13:40:04 CST; 50min ago
5.2.启动PHP-FPM:

systemctl start php-fpm.service

? 查看启动状态:

systemctl status php-fpm.service 

看到以下字眼说明启动成功!
?Active: active (running) since 六 2016-11-19 14:14:33 CST; 18min ago
6.测试

在浏览器打开192.168.44.129:80/index.php
看到 hello eric 就大功告成~

设置开机自启动服务systemctl enable php-fpm.servicesystemctl enable nginx.service

如项目框架为lavarel,则配置文件可用下面这个:server {   listen  80;   server_name learn.laravel5.com;   root /var/www/html/learnlaravel5/public;   index index.html   index.php;   location / {        try_files $uri $uri/        /index.php$is_args$query_string;    }    location ~ \.php$ {        try_files $uri =404;        fastcgi_pass 127.0.0.1:9000;        fastcgi_index index.php;        fastcgi_param SCRIPT_FILENAME        $document_root$fastcgi_script_name;        include fastcgi_params;    }}
时间: 2024-12-11 16:30:04

centos7.3安装php7.0的相关文章

CentOS7快速安装PHP7.0指南

一.删除旧版本 rpm -qa|grep php* or yum list installed |grep php yum remove php* 二.安装新版本 1.更新yum安装包 rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm 2.安装php和其它组件 yum install php7

Linux Centos7.2 编译安装PHP7.0.2

操作环境: 1.系统:Centos7.2 2.服务:Nginx 1.下载PHP7.0.2的安装包解压,编译,安装: $ cd /usr/src/ $ wget http://cn2.php.net/distributions/php-7.0.2.tar.gz $ tar -zxvf php-7.0.2.tar.gz $ cd php-7.0.2 1.1 编译前检查 请检查是否安装了gcc ,没有的话执行yum install gcc 检查是否安装了libxml2 ,没有的话执行yum insta

centos7.2源码安装php7.0.9和nginx1.10.3服务器

下载nginx-1.10.3.tar.gz,php-7.0.9.tar.gz.也可以去nginx官网,php官网下载想要的版本.我选择nginx1.10.3稳定版和php7.0.9最新版.php源码包下载速度可能会很慢,建议使用迅雷等工具,下载完成后通过stfp工具把源码包上传到服务器上,为方便测试,我直接放置在root家目录下: 使用源码安装要确保服务器安装好gcc(编辑工具)和make(安装工具),若没安装可以执行命令安装: # yum install gcc # yum install m

centos7.5环境下编译安装php7.0.30并安装redis和mongo扩展

1.安装php7.0.30的脚本 # vim install_php.sh #!/bin/bash # 安装基本依赖 yum install -y gcc gcc-c++ htop telnet iotop iptraf iftop make logrotate xinetd ntsysv sysstat perl autoconf libjpeg libjpeg-devel libpng libpng-devel glibc glibc-devel glib2 glib2-devel bzip

Centos7 离线安装 php7

问题:因内部管控,机器无法连接公有yum源安装php. 正常安装php7可以参考CentOS7.2 安装 PHP7.2 下面的代码也是一种方法 yum -y install libmcrypt libmcrypt-devel mcrypt mhashrpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpmrpm -Uvh https://mirror.webtatic.com/yum/el7/w

centos7抢先安装docker1.0

1.关闭selinux [[email protected] ~]#setenforce 0 2.安装 Fedora EPEL [[email protected] ~]#yum install -y http://ftp.riken.jp/Linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm 3.安装docker [[email protected] ~]#yum install -y docker-io [[email protecte

图解Linux下源码安装PHP7.0.9 +Nginx

上一次,在<Linux下源码安装php7.0.6>,安装过PHP7.0.3,本文将记录安装PHP7.0.9过程. 测试环境 Linux 2.6.32-279.el6.i686 nginx-1.9.15.tar http://nginx.org/download/nginx-1.9.15.tar.gz php-7.0.9.tar.gz http://am1.php.net/distributions/php-7.0.9.tar.gz 安装Nginx wget http://nginx.org/d

Centos7.2安装zabbix3.0

Centos7.2YUM安装zabbix3.0 防火墙和selinux关闭,这个我就不说了. 1.启动apache yum -y install httpd systemctl start httpd.service systemctl enable httpd.service systemctl status httpd.service 2. 启动mariadb yum install mariadb mariadb-server -y systemctl start mariadb syst

CentOS 7.2 下编译安装PHP7.0.10+MySQL5.7.14+Nginx1.10.1的方法

这篇文章主要介绍了CentOS 7.2 mini版本下编译安装PHP7.0.10+MySQL5.7.14+Nginx1.10.1的方法,非常不错,具有参考借鉴价值,需要的朋友可以参考下一.安装前的准备工作 1.yum update #更新系统 2.yum install gcc gcc-c++ autoconf automake cmake bison m4 libxml2 libxml2-devel libcurl-devel libjpeg-devel libpng-devel libicu