前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >centos6新系统初始化脚本

centos6新系统初始化脚本

作者头像
老高的技术博客
发布2022-12-28 08:36:59
5100
发布2022-12-28 08:36:59
举报
文章被收录于专栏:老高的技术博客

最近装机次数有点多,本来想写到这里的centos6 优化脚本与安全脚本,结果一想还是新开一个帖子吧。

centos源设置可以参考Centos源设置,老高推荐安装阿里源。

新机子先运行上面的脚本,再运行这个脚本

初始化脚本

代码语言:javascript
复制
yum update -y

yum groupinstall "development tools" -y
yum install zlib-devel bzip2-devel pcre-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel -y
yum install crontabs ntpdate vim python-devel zsh -y


chkconfig sendmail off
chsh -s /bin/zsh

yum install python-setuptools -y
easy_install pip
pip install virtualenv
curl -L https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh | sh

ntpdate us.pool.ntp.org

rm -f /etc/localtime
cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

以下是一些免编译的rpm包,也就是由其他人编译好的软件包,用于迅速搭建服务器环境,如果你希望更高程度的自定义,请自行编译。


vpsmate

代码语言:javascript
复制
wget http://www.vpsmate.org/tools/install.py
python install.py

nginx

代码语言:javascript
复制
# http://nginx.org/packages/centos/
# http://nginx.org/packages/centos/6/x86_64/
vi /etc/yum.repos.d/nginx.repo

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/x86_64/
gpgcheck=0
enabled=1

yum update
yum install nginx

nodejs

代码语言:javascript
复制
https://github.com/creationix/nvm

or

wget http://nodejs.org/dist/node-latest.tar.gz
tar zxf node-latest.tar.gz
cd node-latest
./configure
make && make install

mariaDB

代码语言:javascript
复制
vi /etc/yum.repos.d/MariaDB.repo

# 下面的内容可以由 https://downloads.mariadb.org/mariadb/repositories/ 得到

# MariaDB 5.5 CentOS repository list - created 2015-04-27 05:46 UTC
# http://mariadb.org/mariadb/repositories/
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5/centos6-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

yum update -y
yum install MariaDB-client MariaDB-server MariaDB-devel -y
# 集群工具
yum install MariaDB-Galera-server MariaDB-client galera -y
service mysql start
mysql_secure_installation

Mysql

代码语言:javascript
复制
cd /tmp
wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
yum localinstall mysql-community-release-el6-5.noarch.rpm
yum update -y

yum repolist enabled | grep "mysql.*-community.*"
yum install mysql-community-server

ll /usr/bin |grep mysql

mysql_secure_installation

php

代码语言:javascript
复制
# CentOS/RHEL 7.x:

rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

#CentOS/RHEL 6.x:

rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm


# 安装php

yum install php56w php56w-opcache php56w-fpm php56w-mysqlnd php56w-pdo php56w-mssql php56w-pgsql php56w-mcrypt php56w-imap php56w-gd php56w-xml php56w-tidy php56w-soap php56w-pecl-xdebug php56w-pear php56w-pecl-memcache

# 运行php-fpm

service php-fpm restart

php与nginx

此段配置不好容易发生404

代码语言:javascript
复制
server {
    listen       80;
    # server_name  localhost;
    server_name xxxxx;

    #charset koi8-r;
    access_log  /var/log/nginx/log/host.access.log  main;


    root   /var/www/html;
    index  index.php index.html index.htm;

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~ \.php$ {
        include        fastcgi_params;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
    }
}

gcc

在centos上升级gcc费力费时,直接用编译好的gcc是条捷径!

在此我们借助Red Hat Developer Toolset x

下面的脚本分4.7 & 4.8

代码语言:javascript
复制
# Tru Huynh of centos.org has built the redhat developer toolset 1.1, for centos and it contains gcc 4.7.2

cd /etc/yum.repos.d
wget http://people.centos.org/tru/devtools-1.1/devtools-1.1.repo 
yum --enablerepo=testing-1.1-devtools-6 install devtoolset-1.1-gcc devtoolset-1.1-gcc-c++

# This will install it most likely into /opt/centos/devtoolset-1.1/root/usr/bin/

# Then you can tell your compile process to use the gcc 4.7 instead of 4.4 with the CC variable

export CC=/opt/centos/devtoolset-1.1/root/usr/bin/gcc  
export CPP=/opt/centos/devtoolset-1.1/root/usr/bin/cpp
export CXX=/opt/centos/devtoolset-1.1/root/usr/bin/c++

4.8

Known issues:

  • unsigned packages -CentOS-6 devtoolset-2 needs devtoolset-2-ide which contains the whole Eclipse stack, but does not build yet
  • CentOS-6 all the maven related file are not built either
代码语言:javascript
复制
wget http://people.centos.org/tru/devtools-2/devtools-2.repo -O /etc/yum.repos.d/devtools-2.repo
yum install devtoolset-2-gcc devtoolset-2-binutils
yum install devtoolset-2-gcc-gfortran

Rerference:

http://dev.mysql.com/doc/mysql-repo-excerpt/5.6/en/linux-installation-yum-repo.html

http://superuser.com/questions/381160/how-to-install-gcc-4-7-x-4-8-x-on-centos

https://webtatic.com/packages/php56/

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2015-04-27,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 初始化脚本
  • vpsmate
  • nginx
  • nodejs
  • mariaDB
  • Mysql
  • php
  • php与nginx
  • gcc
相关产品与服务
云数据库 MariaDB
腾讯云数据库 MariaDB(TencentDB for MariaDB) 让您轻松在云端部署、使用 MariaDB 数据库。MariaDB 是在 MySQL 版权被 Oracle 收购后,由 MySQL 创始人 Monty 创立,其版权授予了“MariaDB基金会(非营利性组织)”以保证 MariaDB 永远开源,良好的开源策略,是企业级应用的最优选择,主流开源社区系统/软件的数据库系统,均已默认配置 MariaDB。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档