CentOs7 搭建php 7 + ngnix+ laravel环境

镜像文件下载,安装centos7

阿里云

修改网络配置

vi  /etc/sysconfig/network-scripts/ifcfg-eno*

HWADDR=00:0C:29:8D:24:73
TYPE=Ethernet
BOOTPROTO=static  #启用静态IP地址
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
NAME=eno16777736
UUID=ae0965e7-22b9-45aa-8ec9-3f0a20a85d11
ONBOOT=yes  #开启自动启用网络连接
IPADDR0=192.168.21.128  #设置IP地址
PREFIXO0=24  #设置子网掩码
GATEWAY0=192.168.21.2  #设置网关
DNS1=8.8.8.8  #设置主DNS
DNS2=8.8.4.4  #设置备DNS

:wq!  #保存退出
service network restart
ping www.baidu.com #检测网络

开始安装

#安装yum市场
yum -y install epel-release
#安装wget
yum -y install wget
#安装ius
wget https://dl.iuscommunity.org/pub/ius/stable/CentOS/7/x86_64/ius-release-1.0-14.ius.centos7.noarch.rpm
rpm -ivh ius-release-1.0-14.ius.centos7.noarch.rpm
#安装PHP php-fpm 因为yum会自动解决软件之间的依赖,所以会自动安装php
yum -y install php70u php70u-fpm php70u-opcache
#启动php-fpm
systemctl start php-fpm
#安装PHP常用拓展
yum install -y php70u-gd php70u-mysqlnd php70u-pdo php70u-mcrypt php70u-mbstring php70u-json php70u-cli php70u-intl php70u-xsl
#重新加载php-fpm
systemctl reload php-fpm

nginx

yum -y install nginx

mysql

#下载mysql repo源
wget http://repo.mysql.com//mysql57-community-release-el7-7.noarch.rpm
#安装mysql repo源
rpm-ivh mysql57-community-release-el7-7.noarch.rpm
#安装mysql
yum install mysql-server
启动mysql
service mysqld restart

设置开机自启动

chkconfig mysqld on
chkconfig nginx on
chkconfig php-fpm on

允许远程访问

centos7采用的是service firewalld而不是iptables作为防火墙 , firewalld会阻止远程对linux的80端口的访问先禁用service firewalld,再安装iptables
即使安装了iptables也需要开放80端口。

#禁止firewall
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)

#装iptables-servie
yum install -y iptables-services 
vi /etc/sysconfig/iptables 
#添加如下一行
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 8080 -j ACCEPT
#最后重启防火墙使配置生效
systemctl restart iptables.service 
#设置防火墙开机启动
systemctl enable iptables.service 

安装 composer 和laravel

wget https://dl.laravel-china.org/composer.phar -O /usr/local/bin/composer
chmod a+x /usr/local/bin/composer
#添加系统环境变量
vi /etc/environment
PATH="/root/.config/composer/vendor/bin"
#需要重启系统使变量生效
composer global require "laravel/installer"
laravel new blog

设置文件夹共享

文件夹共享

你可能感兴趣的:(CentOs7 搭建php 7 + ngnix+ laravel环境)