初始化
备份:mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
配置JDK
1、官网下载JDK:
2、解压:
tar zxvf jdk-8u161-linux-x64.tar.gz
3、安装:
mkdir /usr/java
mv jdk1.8.0_161 /usr/java
4、配置环境变量:
sudo vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_161
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
export LC_ALL=en_US.UTF-8
5、生效配置的环境变量:
source /etc/profile
6、验证
java -version
安装tomcat
1、下载
wget http://learning.happymmall.com/tomcat/apache-tomcat-7.0.73.tar.gz
2、解压
sudo tar -zxvf apache-tomcat-7.0.73.tar.gz
3、配置环境变量
sudo vim /etc/profile
export CATALINA_HOME=/developer/apache-tomcat-7.0.73
export CATALINA_HOME=/developer/apache-tomcat-7.0.73
export CATALINA_BASE=/developer/apache-tomcat-7.0.73
export TOMCAT_HOME=/developer/apache-tomcat-7.0.73
export PATH=$PATH:$CATALINA_HOME/bin:$CATALINA_BASE/bin:$TOMCAT_HOME/bin
4、生效配置文件
source /etc/profile
安装maven
1、安装
sudo wget http://learning.happymmall.com/maven/apache-maven-3.0.5-bin.tar.gz
2、解压
sudo tar -zxvf apache-maven-3.0.5-bin.tar.gz
3、配置环境变量
sudo vim /etc/profile
export MAVEN_HOME=/developer/apache-maven-3.0.5
PATH=$PATH:$MAVEN_HOME/bin
4、生效配置文件
source /etc/profile
安装vsftpd
1、下载安装
sudo yum -y install vsftpd
2、新建一个ftp用户,只给ftp文件夹权限
sudo useradd ftpuser -d /product/ftpfile -s /sbin/nologin
sudo chown -R ftpuser.ftpuser ./ftpfile/
3、重置ftpuser密码
sudo passwd ftpuser
4、放置ftpuser用户
cd /etc/vsftpd/
sudo vim chroot_list
5、修改安全策略
sudo setsebool -P ftp_home_dir 1
6、备份vsftp.conf
sudo mv vsftpd.conf vsftpd.conf.bak
sudo wget http://learning.happymmall.com/vsftpdconfig/vsftpd.conf
7、启动vsftp
service vsftpd start
安装Nginx
1、下载安装
sudo wget http://learning.happymmall.com/nginx/linux-nginx-1.10.2.tar.gz
2、nginx安装依赖
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
3、解压Nginx
sudo tar -zxvf nginx/linux-nginx-1.10.2.tar.gz
4、安装
sudo ./configure
sudo make
sudo make install
5、优化->把所有NGINX后加的文件放到vhost目录下 (编辑主文件):
sudo vim nginx.conf
include vhost/*.conf;
6、出现错误:nginx: [error] invalid PID number "" in "/usr/local/nginx/logs/nginx.pid"
解决:
./nginx -c /usr/local/nginx/conf/nginx.conf
./nginx -s reload
安装mysql
### 默认安装5.1版本,安装5.7以上请参照:
http://blog.csdn.net/dark_guo/article/details/73277806#t2
1、安装:
sudo yum -y install mysql-server
mysql_install_db
2、编辑mysql配置文件(修改字符集)
sudo vim /etc/my.cnf
[client]
default-character-set=utf8 #增加这一行,指定
socket=/var/run/mysqld/mysqld.sock
[mysqld]
character_set_server=utf8 #增加这一行,指定字符集
pid-file=/var/run/mysqld/mysqld.pid
3、开机自动启动
sudo chkconfig mysqld on
sudo chkconfig --list mysqld
4、重启mysql
sudo service mysqld restart
5、登录mysql
mysql -u root -p
select user,host,password from mysql.user;
6、修改root密码
set password for root@localhost = password('root');
7、增加一个用户:mmall
insert into mysql.user(user,host,password) values ("mmall","localhost",password("mmall"));
8、创建一个database
create database `mmall` default character set utf8 COLLATE utf8_general_ci;
show databases;
9、赋予mmall用户 mmall database
flush privileges; --刷新
grant all privileges on mmall.* to mmall@localhost identified by 'mmall';
10、进入database:
use mmall;
11、查看表:
show tables;
12、执行SQL文件:
source /developer/mmall.sql
安装git
1、安装
cd /usr/src
wget https://www.kernel.org/pub/software/scm/git/git-2.8.3.tar.gz
2、安装依赖
sudo yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils- MakeMaker
3、解压安装
tar -zxvf git-2.8.3.tar.gz
cd git-2.8.3
./configure prefix=/usr/local/git/
make && make install
出现错误:
make[1]: *** [perl.mak] Error 2
make: *** [perl/perl.mak] Error 2
解决:
yum install perl-ExtUtils-MakeMaker package
service httpd restart
make && make install
或者:
yum -y install perl-devel perl-CPAN
yum install tcl build-essential tk gettext
yum install -y curl curl-devel
4、配置环境变量
sudo vim /etc/profile
export GIT_HOME=/usr/local/git
PATH=$PATH:$GIT_HOME/bin
source /etc/profile
5、配置git
git config --global user.name "xxx"
git config --global user.email "xxxx@qq.com"
git config --global core.autocrlf false
git config --global core.quotepath off
git config --global gui.encoding utf-8
ssh-keygen -t rsa -C "xxx@qq.com"
eval `ssh-agent`
6 、查看公钥:
cat ~/.ssh/id_rsa.pub
配置防火墙:
1、初始化防火墙
cd /etc/sysconfig/
sudo iptables -P OUTPUT ACCEPT
sudo service iptables save
sudo mv iptables iptables.bak
sudo wget http://learning.happymmall.com/env/iptables
2、重启防火墙:
sudo service iptables restart