服务器环境部署



#tomcat的启动和关闭
cd /usr/tomcat/apache-tomcat-8.0.50/bin
./shutdown.sh
./startup.sh

#mysql的启动和关闭
service mysqld start #开启
service mysqld stop #关闭
service mysqld restart #重启
mysql -uroot -pMysql@root123456

#nginx的启动和关闭
cd /usr/local/nginx/sbin
sudo ./nginx -s reload

#vsftpd的启动和关闭
service vsftpd restart

#iptables防火墙的启动和关闭
/etc/init.d/iptables restart 
------------------------------------------------------------------------------------------------------------
1.阿里云源配置: http://mirrors.aliyun.com/
①源备份
sudo 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
③生成缓存
yum makecache
yum install gcc

------------------------------------------------------------------------------------------------------------
3.JDK和Tomcat和MAVEN的安装
mkdir /usr/java/
mkdir /usr/maven/
mkdir /usr/tomcat/
wget http://download.oracle.com/otn-pub/java/jdk/8u162-b12/0da788060d494f5095bf8624735fa2f1/jdk-8u162-linux-x64.rpm?AuthParam=1522425393_3a8fb97ff27957deca2ed6b3321df7c7
mv jdk-8u162-linux-x64.rpm?AuthParam=1522425393_3a8fb97ff27957deca2ed6b3321df7c7 jdk-8u162-linux-x64.rpm
sudo rpm -ivh jdk-8u162-linux-x64.rpm

wget http://mirrors.hust.edu.cn/apache/tomcat/tomcat-8/v8.0.50/bin/apache-tomcat-8.0.50.tar.gz
wget https://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.5.3/binaries/apache-maven-3.5.3-bin.tar.gz
tar -zxvf /usr/tomcat/apache-tomcat-8.0.50.tar.gz
tar -zxvf /usr/maven/apache-maven-3.5.3-bin.tar.gz


③环境配置
sudo vim /etc/profile
export JAVA_HOME=/usr/java/jdk1.8.0_162
export MAVEN_HOME=/usr/maven/apache-maven-3.5.3
export CATALINA_HOME=/usr/tomcat/apache-tomcat-8.0.50
export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$CATALINA_HOME/bin:$MAVEN_HOME/bin:$PATH
source /etc/profile
------------------------------------------------------------------------------------------------------------
rpm -qa | grep jdk
rpm -qa | grep vsftpd
rpm -qa | grep mysql-server

sudo yum remove XXX(XXX为上一个命令的执行结果)

vsftpd安装
------------------------------------------------------------------------------------------------------------
①vsftpd安装
yum -y install vsftpd
②创建ftp用户使用的文件夹     
sudo mkdir /home/ftpfile
③添加匿名用户     
sudo useradd ftpuser -d /home/ftpfile -s /sbin/nologin
④修改ftpfile权限 
sudo chown -R ftpuser.ftpuser /home/ftpfile
⑤重设ftpuser用户的密码
sudo passwd ftpuser 
123456
⑥让ftp服务器的配置指向上传目录并且把用户

sudo vim /etc/vsftpd/vsftpd.conf
========================================
#登录欢迎信息
ftpd_banner=Welcome to blah FTP service.
pasv_min_port=61001
pasv_max_port=62000
use_localtime=YES
chroot_local_user=NO
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/chroot_list
#允许匿名用户和本地用户登陆
#anonymous_enable=NO
#anon_root=/home/ftpfile
local_enable=YES
local_root=/home/ftpfile
========================================
创建chroot_list文件输入ftpuser
sudo vim /etc/vsftpd/chroot_list 

------------------------------------------------------------------------------------------------------------




防火墙
sudo vim /etc/sysconfig/iptables
========================================
#*filter
#:INPUT ACCEPT [174:12442]
#:FORWARD ACCEPT [0:0]
#:OUTPUT ACCEPT [96:10704]
#-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT 
#-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT
#-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
#COMMIT
# Completed on Fri Jan  6 16:53:09 2017
#------------------------------------
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT 
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT

#ssh port 
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
#vsftpd
-A INPUT -p TCP --dport 61001:62000 -j ACCEPT
-A OUTPUT -p TCP --sport 61001:62000 -j ACCEPT
-A INPUT -p TCP --dport 20 -j ACCEPT
-A OUTPUT -p TCP --sport 20 -j ACCEPT
-A INPUT -p TCP --dport 21 -j ACCEPT
-A OUTPUT -p TCP --sport 21 -j ACCEPT
#mysql port
-A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT
#tomcat remote debug port
-A INPUT -p tcp -m tcp --dport 5005 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 8080 -j ACCEPT
#nginx
-A INPUT -p tcp -m tcp --dport 80 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT

========================================
重启
sudo service iptables restart

-------------------------------------------------------------------------------------------
安装Nginx
mkdir /usr/nginx/
yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel
wget http://nginx.org/download/nginx-1.13.10.tar.gz
tar -zxvf /usr/nginx/nginx-1.13.10.tar.gz
sudo ./usr/nginx/nginx-1.13.10/configure
sudo make
sudo make install
安装位置 /usr/local/nginx
cd /usr/local/nginx/sbin/
启动 sudo ./nginx
ps aux | grep nginx

配置Nginx
每个域名配置一个对应的nginx配置文件
在nginx.conf的http节点下添加 include vhost/*.conf;
cd /usr/local/nginx/conf

sudo mkdir vhost
sudo vim www.zbangmall.com.conf
sudo vim admin.zbangmall.com.conf
sudo vim weixin.zbangmall.com.conf
sudo vim download.zbangmall.com.conf
sudo vim s.zbangmall.com.conf
sudo vim m.zbangmall.com.conf
sudo vim test.zbangmall.com.conf


-------------------------------------------------------------------------------------------
mysql安装采用二进制方式免编译安装MySQL,适合各类MySQL产品系列,不需要复杂的编译设置和编译时间等待,
    直接解压下载的软件包,初始化即可完成MySQL的安装和启动.
1.准备工作
MySQL依赖于libaio 库
yum search libaio
yum install libaio
wget https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz
tar -zxvf mysql-5.7.19-linux-glibc2.12-x86_64.tar.gz

2.安装MySQL
rpm -qa|grep mysql
wget https://cdn.mysql.com//Downloads/MySQL-5.7/mysql-5.7.21-1.el6.x86_64.rpm-bundle.tar
tar -xvf mysql-5.7.18-1.el6.x86_64.rpm-bundle.tar
 #解压
rpm -ivh mysql-community-common-5.7.21-1.el6.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.21-1.el6.x86_64.rpm
rpm -ivh mysql-community-client-5.7.21-1.el6.x86_64.rpm
yum install perl #安装server时需要的依赖包
yum install numactl #安装server时需要的依赖包
yum install libaio #安装时需要的依赖包
rpm -ivh mysql-community-server-5.7.21-1.el6.x86_64.rpm

netstat -tlunp #查看服务所需端口
grep 'temporary password' /var/log/mysqld.log #查看日志,找初始密码
cat /etc/issue #查看系统版本
getconf LONG_BIT #查看系统位数

mysql -uroot -pMysql@root123456
alter user 'root'@'localhost' identified by 'Mysql@root123456'; #设置root的密码为Mysql@root123456
use mysql;
update user set user.Host='%' where user.User='root';
flush privileges;
exit;
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT #配置端口3306
/etc/rc.d/init.d/iptables save #保存配置


在/etc/my.cnf文件的末尾添加如下内容修改编码信息--------------
lower_case_table_names = 1 
character_set_server=utf8
init_connect='SET NAMES utf8'
default-time_zone = '+8:00'
max_connections=5000
----------------------------------------------------------------------
设置随系统启动
chkconfig --list mysqld
sudo chkconfig mysqld on

-------------------------------------------------------------------------------------------

 

posted @ 2018-04-02 00:23  srckeeper  阅读(332)  评论(0编辑  收藏  举报