Aliyun-CentOS7.3 Init
一、概述
查看系统版本
$ cat /etc/redhat-release
$ uname -a
修改主机名
$ vi /etc/hostname
$ reboot
安装必要lib
yum -y install gcc gcc-c++ make zlib zlib-devel readline-devel pcre pcre-devel openssl openssl-devel tcl perl
二、安装Openresty
$ wget http://www.zlib.net/zlib-1.2.11.tar.gz
$ tar xvf zlib-1.2.11.tar.gz
$ wget https://openresty.org/download/openresty-1.11.2.3.tar.gz
$ tar xvf openresty-1.11.2.3.tar.gz
$ cd /usr/local/openresty-1.11.2.3/bundle/
$ cd /bundle/LuaJIT-2.1-20170405/
$ make clean && make && make install
$ ln -sf luajit-2.1.0-beta2 /usr/local/bin/luajit
$ wget https://github.com/alibaba/nginx-http-concat/archive/master.zip -O nginx-http-concat.zip
$ unzip nginx-http-concat
$ mv nginx-http-concat-master nginx-http-concat
$ wget https://github.com/FRiCKLE/ngx_cache_purge/archive/2.3.tar.gz -O ngx_cache_purge-2.3.tar.gz
$ tar xvf ngx_cache_purge-2.3.tar.gz
$ wget https://github.com/yaoweibin/nginx_upstream_check_module/archive/v0.3.0.tar.gz -O nginx_upstream_check_module-0.3.0.tar.gz
$ tar xvf nginx_upstream_check_module-0.3.0.tar.gz
$ ./configure --prefix=/usr/local/openresty
--with-pcre
--with-zlib=/usr/local/src/zlib-1.2.11
--with-http_gzip_static_module
--with-http_realip_module
--with-http_stub_status_module
--with-http_iconv_module
--add-module=./bundle/nginx-http-concat
--add-module=./bundle/ngx_cache_purge-2.3
--add-module=./bundle/nginx_upstream_check_module-0.3.0/
$ gmake && gmake install
三、安装iptables防火墙
#关闭firewall:
$ systemctl stop firewalld.service #停止firewall
$ systemctl disable firewalld.service #禁止firewall开机启动
#安装iptables防火墙
$ yum install -y iptables-services #安装
$ vi /etc/sysconfig/iptables #编辑防火墙配置文件,开启80,3306端口
# sample configuration for iptables service
# you can edit this manually or use system-config-firewall
# please do not ask us to add additional ports/services to this default configuration
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
$ systemctl restart iptables.service #最后重启防火墙使配置生效
$ systemctl enable iptables.service #设置防火墙开机启动
$ systemctl status iptables #查看防火墙状态
四、安装Golang
$ wget -c http://golangtc.com/static/go/go1.8.linux-amd64.tar.gz
$ tar zxvf go1.8.linux-amd64.tar.gz -C /usr/local
$ vi /etc/profile
export GOROOT=/usr/local/go
export GOBIN=$GOROOT/bin
export PATH=$PATH:$GOBIN
$ source /etc/profile
$ go version
五、安装NodeJS
wget https://nodejs.org/dist/v6.10.3/node-v6.10.3-linux-x64.tar.gz
tar zxvf node-v6.10.3-linux-x64.tar.gz -C /usr/local
$vi /etc/profile
export NODE_HOME=/usr/local/node-v6.10.3-linux-x64
export PATH=$PATH:$NODE_HOME/bin
export NODE_PATH=$NODE_HOME/lib/node_modules
$source /etc/profile
$node -v
六、安装JDK
$ wget https://files.eveoh.nl/jdk-7u80-linux-x64.tar.gz
$ mkdir /usr/java
$ tar zxvf jdk-7u80-linux-x64.tar.gz -C /usr/java
$ vi /etc/profile
export JAVA_HOME=/usr/java/jdk1.7.0_80
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
$ source /etc/profile
$ java -version
七、安装Tomcat
$ wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-7/v7.0.78/bin/apache-tomcat-7.0.78.tar.gz
$ tar xvf apache-tomcat-7.0.78.tar.gz -C /data/production/
$ cd /data/production/
$ mv apache-tomcat-7.0.78 tomcat-myproj
$ rm -rf webapps/docs webapps/examples webapps/host-manager webapps/manager weapps/ROOT/*
八、安装Python
#默认系统已安装2.7.5,无需再安装或更新
$ python
Python 2.7.5 (default, Nov 6 2016, 00:28:07)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>>
九、安装Shadowsocks
$ wget --no-check-certificate -O shadowsocks-libev.sh https://raw.githubusercontent.com/teddysun/shadowsocks_install/master/shadowsocks-libev.sh
$ chmod +x shadowsocks-libev.sh
$ ./shadowsocks-libev.sh 2>&1 | tee shadowsocks-libev.log
$ /etc/init.d/shadowsocks status
$ vi /etc/sysconfig/iptables #开启8989端口
十、安装MySQL
$ wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm #下载MySQL源安装包
$ yum -y localinstall mysql57-community-release-el7-8.noarch.rpm #安装mysql源
$ yum repolist enabled | grep "mysql.*-community.*" #检查MySQL源是否安装成功
$ yum -y install mysql-community-server #安装MySQL
$ systemctl start mysqld #启动MySQL
$ systemctl status mysqld #查看启动状态
$ systemctl enable mysqld #配置开机启动
$ systemctl daemon-reload #配置开机启动
$ vi /etc/my.conf
validate_password = off #根据需要禁用密码策略
$ grep 'temporary password' /var/log/mysqld.log #查看初始密码
$ mysql -uroot -p
#重新设置密码
set password for 'root'@'localhost'=password('123456');
#授权远程操作
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION;
FLUSH PRIVILEGES;
reference: http://blog.csdn.net/xyang81/article/details/51759200
十一、安装Docker
$ yum install docker-io –y
$ systemctl start docker
$ docker info
$ docker pull registry.cn-hangzhou.aliyuncs.com/lxepoo/apache-php5
$ docker images
$ docker run -d -p 8081:80 --name apache e121d5f99e1e
$ curl http://127.0.0.1:8081
reference : https://help.aliyun.com/document_detail/51853.html
十二、安装其他
安装Anaconda
$ wget https://repo.continuum.io/archive/Anaconda2-4.4.0-Linux-x86_64.sh
$ bash Anaconda2-4.4.0-Linux-x86_64.sh
$ source ~/.bashrc
$ python #验证
#生成notebook登陆密码
from notebook.auth import passwd
passwd()
#生成notebook配置文件
$ jupyter notebook --generate-config --allow-root
vi ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.notebook_dir = u'/data/workspace/pyproj/notebooks'
c.NotebookApp.ip='0.0.0.0'
c.NotebookApp.port =8888
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'sha:11111111111111111111111' #使用之前生成的登陆密码
#启动notebook
#jupyter notebook --no-browser --port 8888 --ip=0.0.0.0 --allow-root
$ nohup jupyter notebook --allow-root