安装nginx

1.下载安装包
nginx-1.14.1.tar.gz 其他版本请自行下载 官网地址

2.上传并解压安装包

1
tar -zxvf nginx-1.14.1.tar.gz

3.设置配置信息

1
./configure --prefix=/usr/local/nginx  (安装后的文件存放路径)

如果出现以下异常信息

1
2
3
4
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

则执行命令安装pcre-devel

1
yum -y install pcre-devel

安装pcre-devel完成后再次执行命令

1
./configure --prefix=/usr/local/nginx

执行完后还有可能会出现这样的问题:

1
2
3
4
5
6
7
checking for PCRE JIT support ... not found
checking for system md library ... not found
checking for system md5 library ... not found
checking for OpenSSL md5 crypto library ... not found
checking for sha1 in system md library ... not found
checking for OpenSSL sha1 crypto library ... not found
checking for zlib library ... found

若出现上述问题则安装openssl

1
yum -y install openssl openssl-devel

安装openssl完成后再次执行命令

1
./configure --prefix=/usr/local/nginx

出现下图信息则说明配置成功
nginx-1

4.安装

1
2
make
make install

出现类似这样的就表示安装成功了

1
2
3
4
5
6
cp conf/nginx.conf '/usr/local/nginx/conf/nginx.conf.default'
test -d '/usr/local/nginx/logs' || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/logs' || mkdir -p '/usr/local/nginx/logs'
test -d '/usr/local/nginx/html' || cp -R html '/usr/local/nginx'
test -d '/usr/local/nginx/logs' || mkdir -p '/usr/local/nginx/logs'
make[1]: Leaving directory '/root/setup/nginx/nginx-1.14.1'

安装完后/usr/local/nginx 后出现几个文件夹conf、html、logs、sbin,配置nginx.conf在文件夹conf

启动nginx

1
./usr/nginx/sbin/nginx

部分nginx启动失败解决方法 关闭SELINUX

1
2
vi /etc/selinux/config
将SELINUX=enforcing改为SELINUX=disabled

这时候需要注意,开启nginx配置的防火墙端口 开启防火墙端口教程

安装redis

1.安装redis

1
yum install redis

2.下载fedora的epel仓库

1
yum install epel-release

3.安装redis数据库

1
yum install redis

4.修改redis.conf配置文件

1
2
3
4
5
6
7
8
9
10
11
12
原文件:
bind 127.0.0.1
protected-mode yes
appendonly no//持久化
# requirepass foobared

修改后:

#bind 127.0.0.1
protected-mode no
appendonly yes//持久化
requirepass yourpassword //redis密码

5.使用配置文件启动 redis

1
redis-server /etc/redis.conf &

6.启动redis相关命令

1
2
3
4
5
6
7
8
# 启动redis
service redis start 或 systemctl start redis.service
# 停止redis
service redis stop 或 systemctl stop redis.service
# 查看redis运行状态
service redis status 或 systemctl status redis.service
# 查看redis进程
ps -ef | grep redis

7.本机测试访问

1
2
redis-cli -h 127.0.0.1 -p 6379
quit

这时候需要注意,非本机访问redis需要开启防火墙端口 开启防火墙端口教程

最后更新: 2020年12月21日 22:12

原始链接: https://midkuro.gitee.io/2020/05/20/linux-software/

× 请我吃糖~
打赏二维码