centOS7+mariadb+Nginx+PHP7.0 安装

1.前期准备工作

更新 yum 源,自带的源没有 PHP5.6 

 rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

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

 yum install update

2.防火墙  

一、配置防火墙,开启80端口、3306端口
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
1、关闭firewall:
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
2、安装iptables防火墙
yum install iptables-services #安装
vi /etc/sysconfig/iptables #编辑防火墙配置文件
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
:wq! #保存退出
systemctl restart iptables.service #最后重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动
二、关闭SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq! #保存退出
setenforce 0 #使配置立即生效

3.安装Mysql/Mariadb

安装 Mariadb: yum -y install mariadb.x86_64 mariadb-server.x86_64 mariadb-devel.x86_64

使用下面命令设置root密码: mysql_secure_installation

从最新版本的linux系统开始,默认的是 Mariadb而不是mysql!

使用系统自带的repos安装很简单:

yum install mariadb mariadb-server

systemctl start mariadb ==> 启动mariadb

systemctl enable mariadb ==> 开机自启动

mysql_secure_installation ==> 设置 root密码等相关

mysql -uroot -p123456 ==> 测试登录!

4.安装Nginx

yum install nginx18

用systemctl status nginx.service查看

用systemctl restart nginx.service重启

5.安装PHP

yum install php70w-fpm php70w-mysql php70w-mysqli php70w php70w-opcache php70w-gd php70w-intl php70w-mbstring php70w-exif php70w-mcrypt php70w-openssl
之前试过没装够php extension , laravel 死活报错,现在怕了,一次装够他

6.安装composer

使用命令下载:
curl -sS https://getcomposer.org/installer | php -- --install-dir=安装路径
下载之后设置环境变量:
mv composer.phar /usr/local/bin/composer
并修改权限,否则执行的时候会报错
chmod -R 777 /usr/local/bin/composer
然后在终端直接输出composer即可看到安装成功的界面

7.配置

.首先配置下 php.ini 我的系统默认安装后 php.ini 的位置是 /etc/php.ini 主要需要修改的有下面这些:
cgi.fix_pathinfo=0 --这个原先是注释的,取消注释把值改成0就行.首先配置下 php.ini 我的系统默认安装后 php.ini 的位置是 /etc/php.ini 主要需要修改的有下面这些:
cgi.fix_pathinfo=0 --这个原先是注释的,取消注释把值改成0就行

vi /etc/nginx/nginx.conf

把配置文件里面的 server{ ****}这部分替换成下面这段就可以了

server {
    listen       80;
    server_name example.com;
    location / {
        root   /usr/share/nginx/html/;
        try_files $uri $uri/ /index.php?$query_string;
        index index.php  index.html index.htm;
    }
    error_page  404              /404.html;
    location = /404.html {
        root   /usr/share/nginx/html/;
    }
    #error_page   500 502 503 504  /50x.html;
    #location = /50x.html {
    #   root   /usr/share/nginx/html/;
    #}
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    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;
    }
}

配置 php-fpm :
vi /etc/php-fpm.d/www.conf
修改user和group
user = nginx`
group = nginx

原文地址:https://www.cnblogs.com/88phper/p/7325404.html