0%

各种安装

goroutine退出只能由本身控制,不允许从外部强制结束该goroutine,只有两种情况例外——main函数结束或程序崩溃结束运行。

一、LNMP

  1. 安装目录规划

    • nginx: /usr/local/nginx-1.15.8
    • mysql: /usr/local/mysql-5.7.14
    • php5.6: /usr/local/php/5.6.40
  2. 安装 nginx

    • groupadd nginx(groupname)
    • useradd -g nginx(groupname) nginx(username)
    • 安装gcc-c++编译器:sudo apt-get install build-essential (gcc g++)
    • 下载nginx并解压,假设解压目录:/usr/local/src/nginx
    • 下载pcre并解压,假设解压目录:/usr/local/src/pcre
    • 下载zlib并解压,假设解压目录:/usr/local/src/zlib
    • 下载openssl 并解压,假设解压目录:/usr/local/src/openssl
    • cd /usr/local/src/nginx
    • sudo ./configure --prefix=/usr/local/nginx --with-pcre=/usr/local/src/pcre --with-zlib=/usr/local/src/zlib --with-openssl=/usr/local/src/openssl --user=username --group=groupname
    • sudo make && make install

nginx编译问题:make[1]: *** [/usr/local/pcre//Makefile] Error 127

nginx高版本的需要使用pcre原文件路径,而不是编译好的路径。

  1. 安装mysql5.6

    • 下载cmake并解压安装,传送门
    • groupadd mysql(groupname)
    • useradd -g mysql(groupname) mysql(username)
    • TODO
  2. 安装php5.6

    • 安装依赖openssl、zlib、curl、libxml2、libmcrypt、libiconv等
    • 下载php源码
    • 解压tar -zxvf php-5.6.14.tar.gz
    • sudo ./configure --prefix=/usr/local/php/5.6 --enable-fpm --with-iconv=/your_path/libiconv --with-curl --with-libxml-dir=/your_path/libxml

二、RabbitMQ

  1. 安装依赖 erlang

    rabbitmq官网有多种安装方法,这里选择了第一种:

    • Team RabbitMQ produces a package stripped down to only provide those components needed to run RabbitMQ. It might be easiest to use if installing Erlang’s dependencies is proving difficult.
    • Erlang Solutions produces packages that are usually reasonably up to date and involve installation of a potentially excessive list of dependencies.
    • EPEL (“Extra Packages for Enterprise Linux”); part of the Red Hat/Fedora organisation, provides many additional packages, including Erlang. These are the most official packages but tend to be out of date. The packages are split into many small pieces.
    • openSUSE produces Erlang packages for each distribution (openSUSE and SLES)

    具体步骤:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    1.切换至/etc/yum.repos.d目录,新建rabbitmq_erlang.repo并编辑:

    [rabbitmq-erlang]
    name=rabbitmq-erlang
    baseurl=https://dl.bintray.com/rabbitmq-erlang/rpm/erlang/21/el/7
    gpgcheck=1
    gpgkey=https://dl.bintray.com/rabbitmq/Keys/rabbitmq-release-signing-key.asc
    repo_gpgcheck=0
    enabled=1

    2.执行命令 yum install erlang,一路yes等待安装
    3.测试安装成功与否 终端输入:erl,输出相关信息则成功
  2. 安装rabbitmq

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    1.导入key
    rpm --import https://github.com/rabbitmq/signing-keys/releases/download/2.0/rabbitmq-release-signing-key.asc

    2.配置源 cd /etc/yum.repos.d && vim rabbitmq.repo
    [bintray-rabbitmq-server]
    name=bintray-rabbitmq-rpm
    baseurl=https://dl.bintray.com/rabbitmq/rpm/rabbitmq-server/v3.7.x/el/7/
    gpgcheck=0
    repo_gpgcheck=0
    enabled=1

    3.yum install rabbitmq-server

    4.设置开机启动 chkconfig rabbitmq-server on

    5.启动服务 service rabbitmq-server start

    6.开启界面管理 rabbitmq-plugins enable rabbitmq_management

    7.开启远程访问
    cd /etc/rabbitmq
    cp /usr/share/doc/rabbitmq-server-3.5.6/rabbitmq.config.example /etc/rabbitmq/
    mv rabbitmq.config.example rabbitmq.config
    vim /etc/rabbitmq/rabbitmq.config
    将 %% {loopback_users, []}, 修改为 {loopback_users, []} **注意逗号**
    service rabbitmq-server reload

三、GitLab

  1. 安装依赖yum -y install policycoreutils openssh-server openssh-clients postfix

  2. 设置postfix开机自启动(postfix支持gitlab发信功能)

  3. 通过rpm方式安装gitlab

    • 下载 wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm
    • 安装 rpm -i gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm
    • 修改配置文件 vim /etc/gitlab/gitlab.rb,将external_url 'http://localhost'改为external_url 'http://192.168.10.10:8082'
    • 保存并重启 gitlab-ctl reconfigure && gitlab-ctl restart
  4. 卸载rpm -e gitlab-ce-8.0.0-ce.0.el7.x86_64.rpm

四、centos查看卸载

  1. 查看已安装的应用

    • yum list installed [| grep package]
    • rpm -qa [| grep package]
  2. 卸载已安装的应用

    • yum remove package
    • rpm -e package

五、Jenkins

  1. 查看centos版本 cat /etc/redhat-release

  2. 安装java yum install java

    • java -veriosn 查看java版本
    • centos不可以安装成gcj,否则会导致jenkins不工作
    • 如果安装了gcj版本,卸载yum remove java
    • 搜索jdk版本 yum search openjdk
    • 安装jdk版本 yum install java-1.8.0-openjdk
  3. 安装release版Jenkins(通过添加repos源)

    • 获取源 sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo

    • 导入公钥 sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key

    • 安装 sudo yum -y install jenkins

    • 或安装stable版如下:

      1
      2
      3
      sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat-stable/jenkins.repo
      sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
      sudo yum install jenkins
    • 或用rpm方式安装

      1
      2
      wget https://prodjenkinsreleases.blob.core.windows.net/redhat-stable/jenkins-2.89.2-1.1.noarch.rpm
      rpm -ivh jenkins-2.89.2-1.1.noarch.rpm
  4. 更新Jenkins yum update jenkins

  5. 配置文件

    • 查看配置文件 vim /etc/sysconfig/jenkins
      • JENKINS_USER=”root” ## 修改启动用户为root
      • JENKINS_PORT=”8081” ## 修改端口号
      • JENKINS_HOME=”/var/lib/jenkins” ## jenkins配置及工作文件
  6. 启动

    • 启动/停止 service jenkins start/stop
    • 访问 IP:端口
    • 获取初始密码 vim /var/lib/jenkins/secrets/initialAdminPassword
  7. 防火墙设置

1
2
3
4
5
6
7
8
firewall-cmd --permanent --new-service=jenkins
firewall-cmd --permanent --service=jenkins --set-short="Jenkins Service Ports"
firewall-cmd --permanent --service=jenkins --set-description="Jenkins service firewalld port exceptions"
firewall-cmd --permanent --service=jenkins --add-port=8081/tcp
firewall-cmd --permanent --add-service=jenkins
firewall-cmd --zone=public --add-service=http --permanent
firewall-cmd --reload
firewall-cmd --list-all
  1. 卸载
  • 方式一:yum remove jenkins
  • 方式二:rpm -e jenkins(rpm方式安装)
  1. Jenkins功能包括:
    • 持续的软件版本发布/测试项目
    • 监控外部调用执行的工作

六、LNMP

  1. 安装nginx

    • 安装前执行下此命令sudo yum install yum-utils

    • 添加nginx安装源vim /etc/yum.repos.d/nginx.repo,添加以下内容:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    [nginx-stable]
    name=nginx stable repo
    baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
    gpgcheck=1
    enabled=1
    gpgkey=https://nginx.org/keys/nginx_signing.key

    [nginx-mainline]
    name=nginx mainline repo
    baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
    gpgcheck=1
    enabled=0
    gpgkey=https://nginx.org/keys/nginx_signing.key
    • 执行命令 sudo yum install nginx
    • 设置开机启动
    1
    2
    systemctl enable nginx
    systemctl daemon-reload
  2. 安装mysql

    • 升级软件包–Updaterpm -Uvh http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm
    • 查看5.7版本是否已经启用yum repolist all | grep mysql
    • 如果没有启用的话,我们可以修改源文件
    1
    2
    3
    4
    5
    6
    [mysql57-community]
    name=MySQL 5.7 Community Server
    baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/
    enabled=1 #安装此版本则将此值改为1,其他的版本改为0
    gpgcheck=1
    gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
    • 修改完成之后查看可用的版本yum repolist enabled | grep mysql

    • 如果看到5.7版本启用了之后就可以安装MySql了yum -y install mysql-community-server

    • 安装完成后启动mysqlservice mysqld start

    • 设置开机启动

    1
    2
    systemctl enable mysqld
    systemctl daemon-reload
    • mysql安装完成之后会在LOG文件(/var/log/mysqld.log)中生成一个root的默认密码grep 'temporary password' /var/log/mysqld.log

    • 登录mySql并修改root密码

    1
    2
    3
    mysql -uroot -p
    输入密码:aaaaaa
    mysql>ALTER USER 'root'@'localhost' IDENTIFIED BY 'bbbbbb';
    • 修改默认编码
    1
    2
    3
    4
    在/etc/my.cnf配置文件的[mysqld]下添加编码配置:
    [mysqld]
    character_set_server=utf8
    init_connect='SET NAMES utf8'
    • 重启mysql,是修改生效systemctl restart mysqld

    • 设置远程用户登录

    1
    2
    mysql> GRANT ALL PRIVILEGES ON . TO 'user'@'%' IDENTIFIED BY 'bbbbbb' WITH   GRANT OPTION;
    mysql> FLUSH PRIVILEGES;
  3. 安装php5.6

    • 安装依赖yum install autoconf
    • 更新包
    1
    2
    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
    • 安装php5.6yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64

    • 安装php-fpmyum install php56w-fpm php56w-opcache

    • 启动php-fpmsystemctl start php-fpm

    • 开机启动设置

    1
    2
    systemctl enable php-fpm
    systemctl daemon-reload
  4. 修改nginx配置文件,解析域名,转发请求等,网上一堆教程

  5. 配置好之后请求,报403错误

    • 查看nginx进程 ps -aux | grep nginx,若主进程和worker进程不一致,则修改nginx.conf
    • 关闭SELinux
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
      * 查看当前selinux的状态。
    /usr/sbin/sestatus

    * 将SELINUX=enforcing 修改为 SELINUX=disabled 状态。
    vim /etc/selinux/config
    #SELINUX=enforcing
    SELINUX=disabled

    * 重启生效
    reboot
  6. 参考一

  7. 参考二

  8. Jenkins