PHP环境搭建

7 篇文章 0 订阅

安装版本:mysql8.0.16-php7.2.16 -nginx1.16

nginx安装

  1. 安装Nginx源
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
  1. 安装nginx
yum install -y nginx
  1. 启动nginx并设置开机自动运行
systemctl start nginx  #启动,restart-重启,stop-停止
systemctl enable nginx #开机启动

安装PHP

  1. 安装源
 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
  1. 搜索是否存在PHP72w
yum search php72w 

3.安装所需扩展

yum install php72w.x86_64 php72w-fpm.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-gd.x86_64 php72w-ldap.x86_64 php72w-mbstring.x86_64 php72w-mcrypt.x86_64 php72w-mysql.x86_64 php72w-pdo.x86_64 php72w-pecl-redis.x86_64 php72w-devel php72w-pear
  1. 启动php并设为开机启动
 systemctl start php-fpm #启动,restart-重启,stop-停止
 
 systemctl enable php-fpm #开机启动

配置nginx监听php-fpm

  1. copy 一份/etc/nginx/conf.d/default.conf 文件
cp default.conf my.conf

  1. 修改my.conf配置如下
 location / {
        root   /data;
        index  index.php index.html index.htm;
    }

 location ~ \.php$ {
        root           /data;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

配置过程中遇到的报错

2019/05/03 12:20:12 [error] 2600#2600: *5 "/data/index.php" is forbidden (13: Permission denied), client: 10.0.2.2, server: my.nginx.cn, request: "GET / HTTP/1.1", host: "my.nginx.cn"
Connection closing...Socket close.

百度得到解决方案:具体原因就是服务器的SELinux设置为了开启(enabled)状态。

#直接行下面的命令:

setenforce 0

#这种方法我没有尝试,不知道有效性。
vim /etc/selinux/config

#将配置文件中的SELINUX=enforcing修改为SELINUX=disabled即可,修改完成后需要重启下机器。

#这种方法应该是有效的,至少在我的机器中是通过该方式解决了问题。
#借鉴网站:https://blog.csdn.net/hbysj/article/details/80615330

安装mysql

  • 官方安装文档
    http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
  1. 下载rpm包
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
  1. 安装源
rpm -Uvh mysql80-community-release-el7-1.noarch.rpm
  1. 安装mysql服务端
yum install mysql-community-server
  1. 启动mysql
systemctl start mysqld.service

systemctl enable mysqld
  1. 获取临时密码
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log
2019-05-03T12:58:47.220498Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: jI!:dTges0?#
  1. 修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
#解决方法
#修改两个全局变量的参数
set global validate_password.policy=0;

set global validate_password.length=1;
#修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456789';
  1. 授权其他客户机登录
use mysql;

select host,user,authentication_string,plugin from user;

update user set host = "%" where user = "root";

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456789';

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值