1、备份
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
2、下载新的CentOS-Base.repo 到/etc/yum.repos.d/
CentOS 5
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
或者 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo
CentOS 6
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
或者 curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
CentOS 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
1.清理系统默认自带的jdk
rpm -qa | grep jdk
2.下载JDK
登录网址:http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.htm
3. 在usr目录下建立java安装目录
cd /usr
mkdir java
4. 将jdk-8u60-linux-x64.tar.gz拷贝到java目录下
5. 解压jdk到当前目录
tar -zxvf jdk-8u60-linux-x64.tar.gz
得到文件夹 jdk1.8.0_60
6. 编辑配置文件,配置环境变量
vim /etc/profile
添加如下内容:JAVA_HOME根据实际目录来
JAVA_HOME=/usr/java/jdk1.8.0_60
CLASSPATH=$JAVA_HOME/lib/
PATH=$PATH:$JAVA_HOME/bin
export PATH JAVA_HOME CLASSPATH
7. 重启机器或执行命令 :source /etc/profile
sudo shutdown -r now
8. 查看安装情况
java -version
1.查看yum库中都有哪些jdk版本(暂时只发现了openjdk)
yum search java|grep jdk
2.选择版本安装JDK
yum install java-1.7.0-openjdk
1.下载Tomcat
http://tomcat.apache.org/官网下载Core: tar.gz (pgp, sha512)
apache-tomcat-8.0.53.tar.gz
2.解压apache-tomcat-8.0.50.tar.gz
tar -zxvf apache-tomcat-8.0.50.tar.gz
3.进入tomcat安装bin目录并启动
cd usr/local/tomcat/apache-tomcat-8.0.50/bin/
./startup.sh
成功启动后浏览器输入curl http://localhost:8080/查看信息,最后再通过远程访问
1.进入一个目录
cd /usr/local
2.创建一个文件夹
mkdir maven
3.下载maven的tar包
wget http://mirror.reverse.net/pub/apache/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.tar.gz
4.解压tar包
tar -xvf apache-maven-3.5.2-bin.tar.gz
5.配置环境变量
export JAVA_HOME=/usr/java/jdk1.8.0_60
export MAVEN_HOME=/usr/local/maven/apache-maven-3.5.2
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$MAVEN_HOME/bin:$PATH
1. 卸载vsftpd
sudo yum remove vsftpd
2. 安装vsftpd
sudo yum install vsftpd
3. 创建vsftpd文件夹
cd /
sudo mkdir ftpfile
cd ftpfile
4. 创建对该ftpfile文件夹有权限的用户
sudo useradd ftpuser -d /ftpfile/ -s /sbin/nologin
5. 赋予该文件夹读写权限
sudo chown -R ftpuser.ftpuser /ftpfile/
6. 查看已创建的ftp权限
cd ..
ll | grep ftp
7. 重置密码
sudo passwd ftpuser
8. 创建ftpfile.html文件
sudo vim index.html
填写内容比如:here is ftp file
9. 查找vsftpd
whereis vsftpd
10.修改vsftpd
sudo vim /etc/vsftpd/vsftpd.conf
11. 查找并创建以下
local_enable=YES
write_enable=YES
local_umask=022
dirmessage_enable=YES
xferlog_enable=YES
connect_from_port_20=YES
xferlog_file=/var/log/vsftpd.log
idle_session_timeout=600
data_connection_timeout=6
listen=YES
listen_port=21
allow_writeable_chroot=YES
local_root=/home/www
chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
userlist_enable=YES
userlist_deny=YES
userlist_file=/etc/vsftpd/user_list
pasv_enable=YES
pasv_min_port=10240
pasv_max_port=10260
pam_service_name=vsftpd
guest_enable=YES
guest_username=ftpuser
virtual_use_local_privs=YES
user_config_dir=/etc/vsftpd/vsftpd_user_conf
reverse_lookup_enable=NO
12. 执行以下命令:
sudo cat /etc/vsftpd/vsftpd.conf
看到名字为chroot_list路径为/etc/vsftpd/,然后:
cd /etc/vsftpd/
sudo vim chroot_list
13. 重启vsftpd
sudo service vsftpd restart
14. 配置防火墙
1.关闭防火墙(重启后不生效)
systemctl stop firewalld.service
2.禁用防火墙(永久关闭)
systemctl disable firewalld.service
如果不关闭防火墙的话,我们可以把ftp服务添加了防火墙外
3.开放ftp服务添加到防火墙外
firewall-cmd --permanent --add-service=ftp
4.使其生效
firewall-cmd --reload
5.重启防火墙
systemctl restart firewalld.service
6.防火墙的配置
sudo vim /etc/sysconfig/iptables
添加一下配置到防火墙(最好加到前面)
-A INPUT -p TCP --dport 61001:62000 -j ACCEPT
-A OUTPUT -p TCP --sport 61001:62000 -j ACCEPT
-A INPUT -p TCP --dport 20 -j ACCEPT
-A OUTPUT -p TCP --sport 20 -j ACCEPT
-A INPUT -p TCP --dport 21 -j ACCEPT
-A OUTPUT -p TCP --sport 21 -j ACCEPT
wq保存退出 sudo service iptables restart 重启防火墙
# 以上仅供参考
7.云环境端口暴露21/22
8.通过ftp://********访问ftp服务器
下载并执行FTP Server,然后直接访问
1. 安装依赖库
sudo yum install gcc-c++
sudo yum install pcre pcre-devel
sudo yum install zlib zlib-devel
sudo yum install openssl openssl-devel
2.安装nginx
1.1在线安装
sudo yum install -y nginx
如果无法安装:
centos 7
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
或者
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
然后 yum install epel-release
1.2解压安装
官网下载稳定版本nginx-1.14.0 pgp
http://nginx.org/en/download.html
--> nginx-1.14.0.tar
tar -zxvf nginx-1.14.0.tar.gz
1.3安装
进入nginx-1.14.0 cd /nginx-1.14.0
执行./configure
执行./make
执行./make install
执行:whereis nginx
执行:cd /usr/local/nginx/sbin
执行:./nginx启动
执行:ps aux|grep nginx查看进程
1.4配置Nginx域名转发
在etc/nginx/.conf下配置jindian.ai-gogo.cn.conf
server {
server_name jindian.ai-gogo.cn;
access_log /var/log/nginx/mule.access.log main;
location /{
proxy_pass http://localhost:10001/;
}
location /product/{
proxy_pass http://localhost:30001/;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/jindian.ai-gogo.cn/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/jindian.ai-gogo.cn/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = jindian.ai-gogo.cn) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
return 404; # managed by Certbot
}
1.5 重启nginx
cd /sbin目录
sudo ./nginx -s reload
1. 执行yum -y install mysql-server
2. rpm -qa|grep mysql-server
3. 查看默认配置文件:/etc/my.cnf
4. 字符集配置vim /etc/my.cnf
default-character-set=utf8
character-set-server=utf8
注意版本
5. 自启动配置
1.chkconfig mysqld on(设置自启动)
2.chkconfig --list mysqld(查看2-5位都是on)
6. 命令启动
service mysqld start
注意
账号权限控制:
dql:select
dml: insert & update
ddl: create view & create table
dcl: grant
1.官网下载git
https://github.com/git/git/releases
wget https://github.com/git/git/archive/v2.8.0.tar.gz
2.安装git依赖
sudo yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
3.解压进入git文件夹
tar -zxvf git-v2.8.0.tar.gz
cd git-2.8.0/
4.进行编译
sudo make prefix=/usr/local all
5.执行安装
sudo make prefix=/usr/local install
6.验证安装版本
git -version
7.创建目录gitdown
mkdir gitdownload
8.clone相关代码
git clone [email protected]:imooccode/mmall.git
注:如果没有下载权限,需要设置秘钥
ssh-keygen -t rsa -C "[email protected]"
ssh-add ~/.ssh/id_rsa
cat ~/.ssh/id_rsa.pub 查看秘钥
复制控制台的秘钥到码云或git hub
aliyun:
1. 创建用户
登录root账户
$ useradd username
$ password username
2. 改变权限
$ chmod a+w /etc/sudoers
$ vi /etc/sudoers
# 然后添加
username ALL=(ALL:ALL) ALL
到 root ALL ** 下
$ chmod a-w /etc/sudoers
centos7
1. 创建用户
登录root账户
$ useradd username
$ passwd username
1. 移除旧的版本:
$ sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-selinux \
docker-engine-selinux \
docker-engine
2. 安装一些必要的系统工具:
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
3. 添加软件源信息:
sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
4. 更新 yum 缓存:
sudo yum makecache fast
5.安装 Docker-ce:
sudo systemctl start docker
6.测试运行 hello-world
docker run hello-world
1.拉取官方的镜像
docker pull tomcat
2.查到REPOSITORY为tomcat的镜像
docker image|grep tomcat
3.创建Dockerfile
首先,创建目录tomcat,用于存放后面的相关东西。
runoob@runoob:~$ mkdir -p ~/tomcat/webapps ~/tomcat/logs ~/tomcat/conf
docker pull jenkinsci/blueocean
touch Dockerfile
vim Dockerfile
FROM jenkins
USER root
#清除了基础镜像设置的源,切换成腾讯云的jessie源
#使用非腾讯云环境的需要将 aliyun 改为 aliyun
RUN echo '' > /etc/apt/sources.list.d/jessie-backports.list \
&& echo "deb http://mirrors.aliyun.com/debian jessie main contrib non-free" > /etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/debian jessie-updates main contrib non-free" >> /etc/apt/sources.list \
&& echo "deb http://mirrors.aliyun.com/debian-security jessie/updates main contrib non-free" >> /etc/apt/sources.list
#更新源并安装缺少的包
RUN apt-get update && apt-get install -y libltdl7 && apt-get update
ARG dockerGid=999
RUN echo "docker:x:${dockerGid}:jenkins" >> /etc/group
# 安装 docker-compose 因为等下构建环境的需要
RUN curl -L https://github.com/docker/compose/releases/download/1.16.1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
docker build . -t auto-jenkins
mkdir -p /home/jarries/jenkins
sudo docker run --name jenkins -p 30010:8080 -p 50000:50000 -v /var/run/docker.sock:/var/run/docker.sock -v $(which docker):/bin/docker -v jenkins-data:/home/jarries/jenkins -d auto-jenkins
http://47.95.119.34:30010/login
首选进入容器:
docker exec -it jenkins /bin/bash
然后查看密码:
cat /var/jenkins_home/secrets/initialAdminPassword
http://www.cnblogs.com/stulzq/p/8627360.html