Centos6.7 軟件安裝配置

CentOS安裝

    經常使用設置

        更新yum倉庫

         1.備份
          cd /etc/yum.repos.d
          cp CentOS-Base.repo CentOS-Base.repo.bak                   
          2.下載yum源
          3.替換yum源
          mv CentOS6-Base-163.repo CentOS-Base.repo
          4.清空yum下載的組件緩存
          yum clean all
          5.建立yum源緩存
          yum -y makecache
          6.更新全部yum安裝的軟件
         yum -y update                              

        安裝經常使用軟件包

               yum -y groupinstall " Development Tools "
                   

        支持中文界面

              查看當前系統使用的語言(環境變量 $LANG)
                    echo $LANG
                   
              查看系統支持的語言包
                    locale -a
                   
               看看是否支持     zh_CN.utf8,若是不支持,請安裝中文語言包:
                   yum -y groupinstall chinese-support                    
               修改語言環境變量爲中文
                    vim /etc/sysconfig/i18n                                        
                        
              更新 /etc/sysconfg/i18n 配置文件
                   source  /etc/sysconfg/i18n
              從新啓動便可看到中文界面
                   reboot
              

        配置防火牆

              使用 find 命令查找 iptables 文件的位置
                    find /etc/ -type f -name ipt*               
                   
              編輯 /etc/sysconfig/iptables 文件,開啓幾個經常使用的端口
                    vim  /etc/sysconfig/iptables
                    // WEB
                         80, 8080
                    // 數據庫                                       
                         3306, 1521
                    // 其餘 Sonatype Nexus, CI Jenkins
                         8801, 8802               
                                       
              
              從新啓動防火牆服務
                    service iptables restart
                   
              檢查防火牆狀態
                   service iptables status
                   

          關閉防火牆
              關閉服務
                    service iptables stop
                   
              關閉開機啓動
                    chkconfig iptables off                                        
                   

        固定IP設置        

              查看IP配置文件位置
                    find /etc/ -type f -name ifcfg*                                            
                        
              編輯IP配置文件
                   編輯以前進行備份,上面的全部編輯都建議先作好備份
            cd /etc/sysconfig/network-scripts/
           cp ifcfg-eth0 ifcfg-eth0.bak
       編輯                    
            vim /etc/sysconfig/network-scripts/ifcfg-eth0     
                     
         解釋字段意思
          DEVICE=「eth0」   網卡別名  
            BOOTPROTO="static"     獲取IP地址的方式 static/dhcp                                
                        BROADCAST="192.168.1.255"     廣播地址
                         DNS1="192.168.1.1"    域名解析地址
                        GATEWAY="192.168.1.1"   網關地址
                        IPADDR="192.168.1.100" 網卡IP地址
                        NETMASK=「255.255.255.0」   子網掩碼
                        HWADDR="00:0C:29:A4:D8:35"   網卡物理地址,自帶的                                         
              
         重啓IP服務
              service iptables restart
              
         

    軟件安裝

        中文輸入法

              yum -y install "@Chinese Support"                                  
              
              重啓電腦, 使用Ctrl+空格就可以切換輸入法
                   reboot               

        Vsftpd    文件服務器    

              查看是否已經安裝了vsftpd
                   rpm -qa |grep vsftpd
                   
              查看是否有vsftpd安裝包
                    yum info vsftpd
                   
    
              安裝vsftpd
                   yum -y install vsftpd     
              爲vsftpd添加日誌文件
          touch / var / log / vsftpd . log
              添加ftp用戶
                    adduser -d /var/ftp/www -g ftp -s /sbin/nologin ftpadmin
              設置密碼
                   passwd ftpadmin
              
              
                        
              配置vsftpd
                   參考: http://blog.csdn.net/uxiaolang/article/details/41357201
                   
                   
                   

                     

        Java平臺

              查看是否已經安裝過JDK軟件
                    rpm -qa |grep jdk
              安裝Oracle-JDK7
                   建立安裝目錄
                    mkdir -p /opt/java
                   將安裝包解壓到安裝目錄
                    tar -zxf jdk-7u79-linux-x64.gz -C /opt/java
                   配置JAVA的環境變量
                    vim /etc/profile.d/java.sh
                         JAVA_HOME=/opt/java/jdk1.7.0_79
CLASSPATH=.:$JAVA_HOME/lib
PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH PATH


              從新編譯環境變量配置文件     
                    source /etc/profile
              驗證是否安裝成功
                   java -version
                   

        MySQL

              檢查是否已經安裝 mysql 相關包
                    rpm -qa |grep mysql
                   
              卸載已安裝的mysql相關包
                   yum -y remove  mysql-libs-5.1.73-5.el6_6.x86_64
                    
              
              
              安裝MySQL
                   解壓MySQL安裝包到指定的目錄
                         tar -xf MySQL-5.6.27-1.el6.x86_64.rpm-bundle.tar -C MySQL
                   進入到MySQL目錄下
                        cd MySQL
                        
                        這裏用到的軟件包:
                             服務器
                              MySQL-server-5.6.27-1.el6.x86_64.rpm
                             客戶端
                              MySQL-client-5.6.27-1.el6.x86_64.rpm
                             共享庫(爲其餘程序調用MySQL提供lib)
                              MySQL-shared-5.6.27-1.el6.x86_64.rpm
                             兼容舊版本的MySQL-libs,上面咱們卸載了 mysql-libs-5.1.73-5.el6_6.x86_64
                             若是系統還有其餘軟件依賴於  mysql-libs-5.1.73-5.el6_6.x86_64 這個庫,
                             那麼就須要安裝  MySQL-shared-compat-5.6.27-1.el6.x86_64.rpm來提供舊版本的功能了
                              MySQL-shared-compat-5.6.27-1.el6.x86_64.rpm
                   
                    安裝MySQL-server
                        rpm -ivh  MySQL-server-5.6.27-1.el6.x86_64.rpm
                        
                                  
                        
                                                                          
                        
                        能夠看到mysql服務已經建立,root用戶的一個隨機面產生在 /root/.mysql_secret 文件裏面
                        

                   安裝 MySQL-client
                         rpm -ivh  MySQL-client-5.6.27-1.el6.x86_64.rpm
                        

                    安裝 MySQL- shared
                         rpm -ivh  MySQL-shared-5.6.27-1.el6.x86_64.rpm
                        
                   
                    安裝 MySQL- shared- compat
                         rpm -ivh  MySQL-shared-compat-5.6.27-1.el6.x86_64.rpm
                                                 
         
              安裝記錄
                    [root@localhost MySQL]# rpm -ivh MySQL-server-5.6.27-1.el6.x86_64.rpm
warning: MySQL-server-5.6.27-1.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Preparing...                ########################################### [100%]
   1:MySQL-server           ########################################### [100%]
warning: user mysql does not exist - using root
warning: group mysql does not exist - using root
2015-12-08 16:27:38 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-12-08 16:27:38 0 [Note] /usr/sbin/mysqld (mysqld 5.6.27) starting as process 5365 ...
2015-12-08 16:27:38 5365 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-12-08 16:27:38 5365 [Note] InnoDB: The InnoDB memory heap is disabled
2015-12-08 16:27:38 5365 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-12-08 16:27:38 5365 [Note] InnoDB: Memory barrier is not used
2015-12-08 16:27:38 5365 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-12-08 16:27:38 5365 [Note] InnoDB: Using Linux native AIO
2015-12-08 16:27:38 5365 [Note] InnoDB: Using CPU crc32 instructions
2015-12-08 16:27:38 5365 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-12-08 16:27:38 5365 [Note] InnoDB: Completed initialization of buffer pool
2015-12-08 16:27:38 5365 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-12-08 16:27:38 5365 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-12-08 16:27:38 5365 [Note] InnoDB: Database physically writes the file full: wait...
2015-12-08 16:27:38 5365 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-12-08 16:27:38 5365 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-12-08 16:27:38 5365 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-12-08 16:27:38 5365 [Warning] InnoDB: New log files created, LSN=45781
2015-12-08 16:27:38 5365 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-12-08 16:27:38 5365 [Note] InnoDB: Doublewrite buffer created
2015-12-08 16:27:38 5365 [Note] InnoDB: 128 rollback segment(s) are active.
2015-12-08 16:27:38 5365 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-12-08 16:27:38 5365 [Note] InnoDB: Foreign key constraint system tables created
2015-12-08 16:27:38 5365 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-12-08 16:27:38 5365 [Note] InnoDB: Tablespace and datafile system tables created.
2015-12-08 16:27:38 5365 [Note] InnoDB: Waiting for purge to start
2015-12-08 16:27:38 5365 [Note] InnoDB: 5.6.27 started; log sequence number 0
A random root password has been set. You will find it in '/root/.mysql_secret'.
2015-12-08 16:27:38 5365 [Note] Binlog end
2015-12-08 16:27:38 5365 [Note] InnoDB: FTS optimize thread exiting.
2015-12-08 16:27:38 5365 [Note] InnoDB: Starting shutdown...
2015-12-08 16:27:40 5365 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2015-12-08 16:27:40 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-12-08 16:27:40 0 [Note] /usr/sbin/mysqld (mysqld 5.6.27) starting as process 5387 ...
2015-12-08 16:27:40 5387 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-12-08 16:27:40 5387 [Note] InnoDB: The InnoDB memory heap is disabled
2015-12-08 16:27:40 5387 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-12-08 16:27:40 5387 [Note] InnoDB: Memory barrier is not used
2015-12-08 16:27:40 5387 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-12-08 16:27:40 5387 [Note] InnoDB: Using Linux native AIO
2015-12-08 16:27:40 5387 [Note] InnoDB: Using CPU crc32 instructions
2015-12-08 16:27:40 5387 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-12-08 16:27:40 5387 [Note] InnoDB: Completed initialization of buffer pool
2015-12-08 16:27:40 5387 [Note] InnoDB: Highest supported file format is Barracuda.
2015-12-08 16:27:40 5387 [Note] InnoDB: 128 rollback segment(s) are active.
2015-12-08 16:27:40 5387 [Note] InnoDB: Waiting for purge to start
2015-12-08 16:27:40 5387 [Note] InnoDB: 5.6.27 started; log sequence number 1625977
2015-12-08 16:27:40 5387 [Note] Binlog end
2015-12-08 16:27:40 5387 [Note] InnoDB: FTS optimize thread exiting.
2015-12-08 16:27:40 5387 [Note] InnoDB: Starting shutdown...
2015-12-08 16:27:42 5387 [Note] InnoDB: Shutdown completed; log sequence number 1625987




A RANDOM PASSWORD HAS BEEN SET FOR THE MySQL root USER !
You will find that password in '/root/.mysql_secret'.

You must change that password on your first connect,
no other statement but 'SET PASSWORD' will be accepted.
See the manual for the semantics of the 'password expired' flag.

Also, the account for the anonymous user has been removed.

In addition, you can run:

  /usr/bin/mysql_secure_installation

which will also give you the option of removing the test database.
This is strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at http://bugs.mysql.com/

The latest information about MySQL is available on the web at

  http://www.mysql.com

Support MySQL by buying support/licenses at http://shop.mysql.com

New default config file was created as /usr/my.cnf and
will be used by default by the server when you start it.
You may edit this file to change server settings
         

              獲取root用戶的臨時密碼
                    less /root/.mysql_secret
                   
              啓動MySQL服務
                   service mysql start                                        
              使用mysql用戶進行安全配置
                   
[root@localhost MySQL]# /usr/bin/mysql_secure_installation --user=mysql

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.
# 修改root用戶的密碼
Change the root password? [Y/n] Y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

# 刪除匿名用戶
Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

# 是否容許root用戶遠程登陸
Disallow root login remotely? [Y/n] n
 ... skipping.

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

# 是否刪除test數據庫
Remove test database and access to it? [Y/n] n
 ... skipping.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

# 是否從新加載權限表
Reload privilege tables now? [Y/n] Y
 ... Success!




All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Cleaning up...
    
    MySQL 權限設置
         建立用戶
               create user 'user'@'address' identified by 'testpassword'     
          授予權限
              grant privileges on [db].[table] to 'user'@'address' identified by 'password' [with grant option]
         收回權限
              revoke  privileges on [db].[table] from'user'@'address'
         參考資料
         若是出現不被容許訪問,那就看看mysql庫的user表中,登陸的user是否已經被容許遠程登陸
         
         
         host:容許遠程登陸的主機地址
              % 表示全部
              localhost.* 表示域名,在hosts文件IP映射
         user:用戶名
         password:加密後的密碼

         配置文件位置: /usr/my.conf
              配置內容
                    [mysqld]
lower_case_table_names=1
character_set_client = utf8
character_set_server = utf8

grant all privileges on *.* to mysql@'%' identified by 'admin' with grant option;
grant all privileges on *.* to wcp2@'%' identified by "wcp123456" with grant option;
grant all privileges on wcp2.* to wcp2@'%' identified by 'wcp123456';
                        

        Git、Gitlab    版本管理

              查看是否已經安裝了Git
                   rpm -qa | grep git
                   
              卸載老版本Git
                   yum -y remove git
                   
              安裝新版本Git
                   
                   依賴安裝
               yum -y install zlib-devel curl-devel openssl-devel perl cpio expat-devel gettext-devel openssl zlib  autoconf tk perl-ExtUtils-MakeMaker
                             

         下載最新版本Git
               https://github.com/git/git/releases
                              https://github.com/git/git/archive/v2.6.4.tar.gz
                             wget  https://github.com/git/git/archive/v2.6.4.tar.gz
                     
                             
            
                   編譯安裝
                        解壓
                        

              配置
                   進入源碼目錄
                    cd git-2.6.4

                   使用 autoconf 工具生成配置文件
                        
                   查看配置選項
                   ./configure --help
                   
                   配置軟件的安裝路徑
                   ./configure  --prefix=/opt/git
                   
                   編譯、安裝
                   make
                   make install
                  
                   檢查安裝是否正確
                        git --version
                             若是出現如下錯誤
                              bash: /usr/bin/git: 沒有那個文件或目錄
                                       緣由:沒有配置git的PATH路徑
                                       解決:
                                             vim /etc/profile.d/git.sh
                                            寫入:
                                                  GIT_HOME=/opt/git
PATH=$PATH:$GIT_HOME/bin
export PATH
                               從新加載系統環境變量
                                        source /etc/profile
                             再次檢查
                                  git --version
                                  

         Git倉庫管理
              git管理員
                   adduser git
                   
              祕鑰管理
                   切換到git用戶,跳轉到用戶根目錄
                        su git
                        cd ~
                   到git用戶目錄建立.ssh目錄
                    在.ssh目錄下建立 authorized_keys 文件
                        mkdir -p .ssh/ authorized_keys                    
                   向 authorized_keys文件中添加ssh公鑰
                        
              建立裸倉庫
                   
         
         若是在訪問的時候出現如下錯誤:
              

         可能的解決方案:
         修改 .ssh 目錄權限
              chmod 700 .ssh
              
         修改 .ssh/ authorized_keys 權限
              chmod 600 .ssh/ authorized_keys
              
              
         修改倉庫全部者,和訪問權限
              chown -R git:git repo/
              chmod 700 repo/
              
                   
                   參考: http://h2appy.blog.51cto.com/609721/1112797
         
    
              GitLab     下載、 安裝、配置
                   下載地址: https://packages.gitlab.com/gitlab/gitlab-ce
                   
                   根據本身的Linux型號選擇
              
                   GitLab 安裝
                        
                         確認已經安裝了 openssh, postfix, cronie
                        rpm -qa | grep openssh
                         rpm -qa | grep postfix
                         rpm -qa | grep cronie
                        若是沒有安裝執行下列命令安裝
                        yum -y  install openssh postfix cronie   
                        
                        開啓必要的服務
                             service postfix start
                             chkconfig postfix on
                             lokkit -s http -s ssh
                        
                        安裝Gitlab
                             
                   
              配置GitLab
              

              
              
              啓動GitLab
                    gitlab-ctl reconfigure
                   
                   


              初始用戶名/密碼:root / 5iveL!fe



         Subversion 安裝
              1. 卸載系統自帶的Subversion
                   查看是否安裝了Subversion     rpm -qa |grep subversion
                   我這裏已經安裝了最新的1.8版本,若是沒安裝過,顯示的是 subversion- 1.6.11-15.el6_7
                   
                   
                   卸載自帶的Subversion     yum -y remove subversion
                   
              2. 添加Subversion倉庫
                   在目錄  /etc/yum.repos.d 下添加 wandisco-svn.repo 倉庫,內容以下:
                         [WandiscoSVN]
name=Wandisco SVN Repo
baseurl=http://opensource.wandisco.com/centos/$releasever/svn-1.8/RPMS/$basearch/
enabled=1
gpgcheck=0
                                       
                   這裏指定的是最新的1.8版本,若是須要安裝1.9版本,把1.8改爲1.9便可
                   
              3. 安裝Subversion
                   yum -y install subversion  mod_dav_svn
                   查看是否安裝成功
                   svn --version
                   
                                            
              4. 與Apache整合
                   到目錄  /etc/httpd/conf.d 下配置 subversion.conf,內容以下:
                         # WANdisco Subversion Configuration
# For more information on HTTPD configuration options for Subversion please see:
# http://svnbook.red-bean.com/nightly/en/svn.serverconfig.httpd.html
# Please remember that when using webdav HTTPD needs read and write access your repositories.

# Needed to do Subversion Apache server.
LoadModule dav_svn_module     modules/mod_dav_svn.so
# Only needed if you decide to do "per-directory" access control.
LoadModule authz_svn_module   modules/mod_authz_svn.so

<Location /svn>
        DAV svn
        # SVNPath /var/www/svn/repos
SVNListParentPath on
        SVNParentPath /var/www/svn/repos
        AuthType Basic
        AuthName "Subversion repos"
        # AuthUserFile /etc/svn-auth-conf
        AuthUserFile /etc/httpd/svnconf/svn-auth-conf
        # AuthzSVNAccessFile /etc/svn-acl-conf
        AuthzSVNAccessFile /etc/httpd/svnconf/svn-acl-conf
        Require valid-user
</Location>
                   
                   
                    到目錄 /var/www/ 目錄下建立svn倉庫
                    cd /var/www/
                   mkdir -p svn/repos
                   cd svn/repos
                    svnadmin create codes
                    chown -R apache.apache codes
      
              
    到目錄  /etc/httpd/ 目錄下配置Subversion認證(auth)和訪問控制列表(access control  list)
    cd  /etc/httpd/
     mkdir svnconf
    cd svnconf

    建立Subversion用戶
    htpasswd -cbm svn-auth-conf username password
    若是不存在 svn-auth-conf 文件須要使用 htpasswd -c 參數來建立用戶
    若是存在去掉 -c 參數了,否則每次都會建立新的文件
    
    訪問控制配置
    vim svn-acl-conf
[groups]
admin = admin
develop = zhangguangyong,zhangguangxi,lufen

[/]
@admin = rw
* = r

[repo1:/]
@develop = rw

[repo2:/]
zhangguangyong = rw
zhangguangxi = r
    
   
    
    從新啓動 httpd 服務
    service httpd restart
    瀏覽器訪問
    

        Sonatype Nexus    項目倉庫

              下載 Nexus
                    http://www.sonatype.org/nexus/archived/#step2top
               解壓到安裝目錄
                   
              
              配置環境變量
                   
                    cat /etc/profile.d/nexus.sh 
                         RUN_AS_USER=root
                         NEXUS_HOME=/opt/nexus/nexus-2.11.4-01
                         PATH=$PATH:$NEXUS_HOME/bin
                         export PATH NEXUS_HOME
                    source /etc/profile
                                  
              啓動Nexus
                     nexus start                                                                       
                    http://192.168.1.100:8081/nexus
                   
                   
    
    

    

         

         





相關文章
相關標籤/搜索