CentOS7系统
1. 设置CentOS阿里仓库
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
- 将服务器上的软件包信息先在本地缓存,以提高搜索安装软件的速度。
yum makecache
yum update
2.设置服务器时间
下面两种方式,是因为在不同的地方一种方式不管用。
- 方式一
yum -y install ntp ntpdate timedatectl set-timezone Asia/Shanghai ntpdate cn.pool.ntp.org hwclock --systohc
- 方式二
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime hwclock
3.jdk安装
- 切换到
/usr/local/src
下,下载jdk安装包
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" "http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.rpm"
rpm -ivh jdk-8u131-linux-x64.rpm
java -version
4.Mysql安装
wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
yum localinstall mysql57-community-release-el7-11.noarch.rpm
yum install mysql-community-server
systemctl start mysqld
systemctl enable mysqld
cat /var/log/mysqld.log |grep password
- 使用密码登录,修改密码策略,修改root密码,并创建mysql用户
mysql> set global validate_password_policy=0; mysql> set global validate_password_length=1; mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'password'; mysql> GRANT ALL PRIVILEGES ON *.* TO 'mysql'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION; mysql> flush privileges ;
- 修改mysql配置文件
vim /etc/my.cnf
character_set_server=utf8init_connect='SET NAMES utf8'
systemctl restart mysqld
远程连接使用mysql用户,root只能本地连接。远程连接时注意关闭防火墙。下面安装的也同理
systemctl stop firewalld.servicesystemctl disable firewalld.service
5.MongoDB安装
vim /etc/yum.repos.d/mongodb-org-3.4.repo//内容如下[mongodb-org-3.4]name=MongoDB Repositorybaseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.4/x86_64/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-3.4.asc
yum install -y mongodb-org
- 修改配置文件
vim /etc/mongod.conf
net: port: 27017 bindIp: 0.0.0.0
systemctl start mongod
. -- .
6.安装Redis
yum install epel-release
yum install redis
- 修改配置文件
vim /etc/redis.conf
//修改内容bind 0.0.0.0
systemctl start redis
systemctl enable redis
7.安装Rabbitmq
- 切换到
/usr/local/src
下载erlang
wget http://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el7.centos.x86_64.rpm
rpm -ivh erlang-19.0.4-1.el7.centos.x86_64.rpm
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.10/rabbitmq-server-3.6.10-1.el7.noarch.rpm
yum install socatrpm -ivh rabbitmq-server-3.6.10-1.el7.noarch.rpm
systemctl enable rabbitmq-server
systemctl start rabbitmq-server
rabbitmq-plugins enable rabbitmq_management
注意:rabbitmq的默认用户guest,密码guest是只在本地可以登录,此处直接创建admin用户并赋权限,若想guest远程连接,请自行查资料修改
rabbitmqctl add_user admin adminrabbitmqctl set_user_tags admin administratorrabbitmqctl add_vhost adminrabbitmqctl set_permissions -p admin admin ".*" ".*" ".*"
8.安装FastDFS
wget https://github.com/happyfish100/fastdfs/archive/V5.05.tar.gz //下载fastdfswget https://github.com/happyfish100/libfastcommon/archive/V1.0.7.tar.gz //下载libfastcommon
mkdir -p /usr/local/fastdfs/{storage,tracker}
tar -xzvf V1.0.7.tar.gz #解压缩下载的libfastcommon源码包cd libfastcommon-1.0.7 #进入解压缩后得到的目录下./make.sh #编译./make.sh install #安装
tar -zxvf V5.05.tar.gzcd fastdfs-5.05/./make.sh./make.sh install
- 创建tracker和storage、client配置文件
cd /etc/fdfs #配置文件都在这个目录mv storage.conf.sample storage.confmv tracker.conf.sample tracker.confmv client.conf.sample client.conf
mkdir -p /data/fastdfs
bind_addr= #empty for bind all addresses of this hostbase_path=/data/fastdfs #在/data/下建立目录
group_name=group1bind_addr= # empty for bind all addresses of this hostbase_path=/data/fastdfsstore_path0= /data/fastdfstracker_server=trackerIP:22122
base_path=/data/fastdfstracker_server=trackerIP:22122
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf start/usr/bin/fdfs_storaged /etc/fdfs/storage.conf start
9.安装Nginx
yum -y install zlib zlib-devel pcre pcre-devel gcc gcc-c++ openssl openssl-devel libevent libevent-devel perl unzip net-tools wget
wget -O fastdfs-nginx-module.zip https://github.com/happyfish100/fastdfs-nginx-module/archive/5e5f3566bbfa57418b5506aaefbe107a42c9fcb1.zip //下载fastdfs、nginx中间件wget http://nginx.org/download/nginx-1.10.2.tar.gz //下载nginx源码
tar -xzvf nginx-1.10.2.tar.gz
- 解压中间件,并命名为fastdfs-nginx-module
unzip fastdfs-nginx-module.zipmv fastdfs-nginx-module-5e5f3566bbfa57418b5506aaefbe107a42c9fcb1 fastdfs-nginx-module
- 切换到
/usr/local/src/nginx-1.10.2
目录下,执行命令添加中间模块
./configure --prefix=/usr/local/nginx --add-module=/usr/local/src/fastdfs-nginx-module/src/
makemake install
vi /usr/local/nginx/conf/nginx.conf
配置nginx
server { listen 80; server_name localhost; location /group1/M00 { root /data/fastdfs/data; ngx_fastdfs_module; }}
cp /usr/local/src/fastdfs-nginx-module/src/mod_fastdfs.conf /etc/fdfs/cp /usr/local/src/fastdfs-5.05/http.conf /etc/fdfs/cp /usr/local/src/fastdfs-5.05/mime.types /etc/fdfs/
- 修改配置文件
vi /etc/mod_fastdfs.conf
base_path=/data/fastdfstracker_server=trackerIP:22122group_name=group1
ln -s /data/fastdfs/data /data/fastdfs/data/M00
/usr/local/nginx/sbin/nginx