CentOS   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Centos7.0以上安装nginx+php7.0+mysql5.7+redis3作为开发php环境大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

CentOS 7 biuld 1611最小化安装@VMware redis 3.2.8 安装步骤: #安装gcc yum -y install gcc #下载redis curl -O  http://download.redis.io/releases/redis-3.2.8.tar.gz #解压 tar -zxvf redis-3.2.8.tar.gz #转换目录 cd redis-3.2.8


CentOS 7 biuld 1611最小化安装@VMware

redis 3.2.8


安装步骤:


#安装gcc

yum -y install gcc

#下载redis

curl -O http://download.redis.io/releases/redis-3.2.8.tar.gz

#解压

tar -zxvf redis-3.2.8.tar.gz

#转换目录

cd redis-3.2.8/deps/

#编译依赖

@H_316_14@make geohash-int hiredis jemalloc linenoise lua

#转换目录

cd ..

#编译redis

@H_316_14@make && make install

#转换目录

cd utils/

#使用脚本安装服务

./install_server.sh

#启动服务

systemctl start redis_6379

systemctl status redis_6379

#好了,就这些,尝试一下吧。


简单提示


当前版本中需要编译的依赖有五项,更早或未来的版本可能会有不同。如果您没有编译这些项目,编译redis会遇到错误


Fatal error: jemalloc/jemalloc.h: No such file or directory

cc: error: ../deps/hiredis/libhiredis.a: No such file or directory

cc: error: ../deps/lua/src/liblua.a: No such file or directory

cc: error: ../deps/geohash-int/geohash.o: No such file or directory

cc: error: ../deps/linenoise/linenoise.o: No such file or directory


在使用脚本安装服务的过程中,您可以一路【Enter】完成安装。之后您可以再次运行脚本文件,并通过输入不同的端口号建立多个redis服务。




1.先修改yum源 https://webtatic.com


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

rpm -Uvh http://dev.MysqL.com/get/MysqL57-community-release-el7-9.noarch.rpm


2.安装Nginx


yum install Nginx


3.安装MysqL5.7


yum -y install MysqL-community-server


4.安装PHP


yum install PHP70w-devel PHP70w.x86_64 PHP70w-pecl-redis PHP70w-cli.x86_64 PHP70w-common.x86_64 PHP70w-gd.x86_64 PHP70w-ldap.x86_64 PHP70w-mbString.x86_64 PHP70w-mcrypt.x86_64 PHP70w-pdo.x86_64 PHP70w-MysqLnd PHP70w-fpm PHP70w-opcache


5.开始简单的配置


MysqL 配置


vim /etc/my.cnf


在[client] 下面添加

default-character-set=utf8


在 [MysqLd] 下面添加


character_set_server=utf8

init_connect='SET NAMES utf8'


collation-server=utf8_general_ci


保存退出


获取初始密码


grep 'temporary password' /var/log/MysqLd.log




注意 里面包括开头的 ;号


然后登陆MysqL 修改密码


alter user root@localhost identified by 'zhonghui!8'


如果密码太过于简单可能不然修改因为MysqL认设置了密码复杂度 至少8位 必须包含 大小写字母数字及符号


查看密码策略:


show variables like '%password%';


说明:


validate_password_Dictionary_file:密码策略文件,策略为STRONG才需要


validate_password_length:密码最少长度


validate_password_mixed_case_count:大小写字符长度,至少1个


validate_password_@R_262_10793@er_count :数字至少1个


validate_password_special_char_count:特殊字符至少1个 上述参数是认策略MEDIUM的密码检查规则。


validate_password_policy:密码策略,认为MEDIUM策略 ,共有如下三种密码策略:


0 or LOW Length


1 or MEDIUM Length; numeric,lowercase/uppercase,and special characters


2 or STRONG Length; numeric,and special characters; Dictionary file


可以通过 set GLOBAL validate_password_policy=0修改


或者修改/etc/my.cnf文件


validate_password_policy=0 #0(LOW),1(MEDIUM),2(STRONG)其中一种,注意2需要提供密码字典文件


如果不需要密码策略,@L_964_29@my.cnf文件添加如下配置禁用即可:


validate_password = off


添加一个可以在外部登陆的MysqL用户


grant all privileges on *.* to 创建的用户名 @"%" identified by "密码";

flush privileges;



注意修改配置文件后需要重启MysqL


配置Nginx


Nginx可以的配置文件一般在:


/etc/Nginx/Nginx.conf


使用 cat 查看一下配置文件

这行表示Nginx会引用 conf.d 这个文件夹下面所有.conf后缀的文件


那么在conf.d下面我们来建立我们自己的配置文件


vim /etc/Nginx/conf.d/user.conf


然后写入

server {

listen 80;

server_name 192.168.88.3或者www.abc.com;

root /source/hld/bp.hldcanyin.com/public(项目目录绝对路径);

index index.PHP index.html index.htm;

charset utf-8;


access_log /var/log/Nginx/bp.hldcanyin.com.access.log main;

error_log /var/log/Nginx/bp.hldcanyin.com.error.log debug;


LOCATIOn / {

#try_files $uri $uri/ /index.PHP?_url=$uri&$args;

try_files $uri $uri/ /index.PHP?$query_String;

}


LOCATIOn ~ \.PHP {

# try_files $uri =404;


fastcgi_pass 127.0.0.1:9000;

fastcgi_index /index.PHP;


include fastcgi_params;

fastcgi_split_path_info ^(.+\.PHP)(/.+)$;

fastcgi_param PATH_INFO $fastcgi_path_info;

fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;

fastcgi_param SCRIPT_FILename $document_root$fastcgi_script_name;

}


LOCATIOn ~ /\.ht {

deny all;

}

}


这样 简单的lnmp就安装好了


systemctl restart PHP-fpm #启动PHP

systemctl restart Nginx #启动Nginx

systemctl restart MysqLd #启动MysqL


Nginx常见问题:使用Nginx -s reload时

Nginx报错 [error] open() “/usr/local/var/run/openresty.pid” Failed (2: No such file or directory)


解决: 服务没有启动 使用start启动服务,因为没有start而直接使用stop或者reload报错这个问题;

如果方法一没有解决,使用方法二:-C 指定配置文件Nginx.conf或者weblua.conf

大佬总结

以上是大佬教程为你收集整理的Centos7.0以上安装nginx+php7.0+mysql5.7+redis3作为开发php环境全部内容,希望文章能够帮你解决Centos7.0以上安装nginx+php7.0+mysql5.7+redis3作为开发php环境所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。