加入收藏 | 设为首页 | 会员中心 | 我要投稿 淮安站长网 (https://www.0517zz.com.cn/)- 数据开发、人脸识别、智能机器人、图像处理、语音技术!
当前位置: 首页 > 服务器 > 搭建环境 > Linux > 正文

教你如何在阿里云的CentOS6上面配置Web服务器?

发布时间:2023-10-12 13:04:21 所属栏目:Linux 来源:互联网
导读:   最近买了阿里云的CentOS系统的Linux服务器,花了些时间把环境配置了一下,用来发布后端。



  jdk



  Tomcat



  Maven



  Git



  mysql5.7.17

  最近买了阿里云的CentOS系统的Linux服务器,花了些时间把环境配置了一下,用来发布后端。
 
  jdk
 
  Tomcat
 
  Maven
 
  Git
 
  mysql5.7.17
 
  CentOS环境初始化
 
  1.CentOS备份
 
  mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
 
  1
 
  2.下载新的CentOS-Base.repo
 
  wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
 
  1
 
  3.生成缓存
 
  yum makecache
 
  1
 
  阿里云Centos环境初始化
 
  http://mirrors.aliyun.com/help/centos
 
  创建新用户
 
  1. 创建用户
 
  useradd -d /usr/用户名 -m 用户名
 
  1
 
  2.设置用户密码
 
  passwd 用户名
 
  1
 
  设置新用户密码
 
  3.修改配置文件
 
  vim /etc/sudoers
 
  1
 
  找到root后添加一条新用户的信息  ALL=(ALL) ALL意思是 用户=可以以root权限执行的命令  添加完成后 wq! 强制保存退出
 
  到这里新用户的配置就结束了。
 
  用新用户登录后注意要使用 “sudo”命令
 
  创建安装包存放文件夹
 
  用mkdir命令创建用来存放安装包的文件夹
 
  mkdir developer
 
  1
 
  注意不是root用户要用sudo
 
  sudo mkdir developer
 
  1
 
  配置JDk
 
  1.检查是否安装JDk
 
  rpm -qa| grep jdk
 
  1
 
  使用这条命令检查是否安装jdk
 
  2.下载JDk
 
  官方下载地址
 
  http://www.oracle.com/technetwork/java/javase/archive-139210.html
 
  使用wget命令下载JDk
 
  3.重命名JDK
 
  mv 原文件名 新文件名 这里要用空格分开
 
  sudo mv jdk-7u80-linux-x64.rpm\?AuthParam\=1502245631_f04b3399ba732d3836923a1103166a05  jdk-7u80-linux-x64.rpm
 
  1
 
  4.赋权
 
  chmod 777 赋权对象,让所有用户都能使用JDK
 
  sudo chmod 777 apache-tomcat-7.0.79.tar.gz
 
  1
 
  5.安装JDK
 
  sudo rpm -ivh 文件
 
  sudo rpm -ivh jdk-7u80-linux-x64.rpm
 
  1
 
  6.配置环境变量
 
  sudo vim /etc/profile
 
  1
 
  编辑配置文件
 
  修改完成后wq!强制保存退出
 
  生效配置文件
 
  source /etc/profile
 
  1
 
  到这里配置JDK就结束了。
 
  7.检查JDK是否安装成功
 
  java -version
 
  1
 
  安装Tomcat
 
  1.下载Tomcat
 
  Tomcat官网
 
  http://tomcat.apache.org/
 
  选择自己要使用的版本下载tar.gz
 
  sudo wget http://mirror.bit.edu.cn/apache/tomcat/tomcat-7/v7.0.79/bin/apache-tomcat-7.0.79.tar.gz
 
  1
 
  2.解压Tomcat
 
  tar -zxvf 解压文件
 
  sudo tar -zxvf apache-tomcat-7.0.79.tar.gz
 
  1
 
  3.将解压好的Tomcat文件放到/usr/local文件夹下
 
  sudo mv apache-tomcat-7.0.79 /usr/local/
 
  1
 
  4.修改Tomcat字符集编码
 
  sudo vim /usr/local/apache-tomcat-7.0.79/conf/server.xml
 
  1
 
  在Connector 里加入:URIEncoding=”UTF-8”
 
    修改完成后wq!强制保存退出
 
  配置环境变量
 
  sudo vim /etc/profile
 
  1
 
  编辑配置文件
 
  修改完成后wq!强制保存退出
 
  生效配置文件
 
  source /etc/profile
 
  1
 
  到这里配置Tomcat就结束了。
 
  Maven配置
 
  1.下载maven
 
  sudo wget http://mirrors.tuna.tsinghua.edu.cn/apache/maven/maven-3/3.5.0/binaries/apache-maven-3.5.0-bin.tar.gz
 
  1
 
  2.解压maven
 
   sudo tar -zxvf apache-maven-3.5.0-bin.tar.gz
 
  1
 
  3.将解压好的Maven文件放到/usr/local文件夹下
 
  sudo mv  apache-maven-3.5.0 /usr/local/
 
  1
 
  4.配置环境变量
 
  sudo vim /etc/profile
 
  1
 
  编辑配置文件
 
  修改完成后wq!强制保存退出
 
  生效配置文件
 
  source /etc/profile
 
  1
 
  到这里配置Maven就结束了。
 
  5.检查Maven是否安装成功
 
  mvn -version
 
  1
 
  Git安装
 
  1.下载Git
 
  该下载链接由慕课网提供
 
  wget http://learning.happymmall.com/git/git-v2.8.0.tar.gz
 
  1
 
  2.安装Git的依赖
 
  sudo yum -y install zlib-devel openssl-devel cpio expat-devel gettext-devel curl-devel perl-ExtUtils-CBuilder perl-ExtUtils- MakeMaker
 
  3.解压Git压缩包
 
  sudo tar -zxvf git-v2.8.0.tar.gz
 
  4.安装Git
 
  进入git目录
 
  cd git-2.8.0
 
  make安装
 
  sudo make prefix=/usr/local/git all
 
  sudo make prefix=/usr/local/git install
 
  5.配置环境变量
 
  sudo vim /etc/profile
 
  修改完成后wq!强制保存退出
 
  生效配置文件
 
  source /etc/profile
 
  到这里配置Git就结束了。
 
  6.检查Git是否安装成功
 
  git --version
 
  mysql5.7.17安装
 
  1.下载mysql
 
  官方下载地址
 
  https://downloads.mysql.com/archives/community/
 
  sudo wget https://cdn.mysql.com/archives/mysql-5.7/mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar
 
  2.解压mysql压缩包
 
  sudo tar xvf mysql-5.7.17-1.el6.x86_64.rpm-bundle.tar
 
  3.安装mysql
 
  1.删除mysql-lib(系统自带的版本过低)
 
  sudo yum remove mysql-libs
 
  2.安装依赖
 
  sudo rpm -ivh mysql-community-common-5.7.17-1.el6.x86_64.rpm
 
  sudo rpm -ivh mysql-community-libs-5.7.17-1.el6.x86_64.rpm
 
  sudo rpm -ivh mysql-community-client-5.7.17-1.el6.x86_64.rpm
 
  sudo rpm -ivh mysql-community-devel-5.7.17-1.el6.x86_64.rpm
 
  sudo rpm -ivh mysql-community-server-5.7.17-1.el6.x86_64.rpm
 
  3.启动mysql  重启linux服务器
 
  sudo shutdown -r now
 
  启动数据库
 
  service mysqld start
 
  数据库初始化
 
  1.初始化数据库
 
  sudo mysql_secure_installation
 
  mysql5.7.17加强了安全系统,需要去/var/log/mysqld.log下找到初始密码
 
  vim /var/log/mysqld.log
 
  收索 A temporary password is generated for root@localhost  
 
  Securing the MySQL server deployment.
 
  Enter password for user root: <–输入找到的初始密码
 
  he existing password for the user account root has expired. Please set a new password.
 
  New password: <– 设置root用户的密码
 
  Re-enter new password: <– 再输入一次你设置的密码
 
  The 'validate_password' plugin is installed on the server.
 
  The subsequent steps will run with the existing configuration
 
  of the plugin.
 
  Using existing password for root.
 
  Estimated strength of the password: 100
 
  Change the password for root ? ((Press y|Y for Yes, any other key for No) : <-是否更改root密码
 
  New password:<– 再输入一次你设置的密码
 
  Re-enter new password: <– 再输入一次你设置的密码
 
  Estimated strength of the password: 100
 
  Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : <-确认更改root密码
 
  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? (Press y|Y for Yes, any other key for No) : <-删除匿名用户?
 
  Success.
 
  Normally, root should only be allowed to connect from
 
  'localhost'. This ensures that someone cannot guess at
 
  the root password from the network.
 
  Disallow root login remotely? (Press y|Y for Yes, any other key for No) :  <–是否禁止root远程登录,根据自己的需求选择Y/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.
 
  Remove test database and access to it? (Press y|Y for Yes, any other key for No) : <– 是否删除test数据库,直接回车
 
   - Dropping test database...
 
  Success.
 
   - Removing privileges on test database...
 
  Success.
 
  Reloading the privilege tables will ensure that all changes
 
  made so far will take effect immediately.
 
  Reload privilege tables now? (Press y|Y for Yes, any other key for No) : <– 是否重新加载权限表,直接回车
 
  Success.
 
  All done!
 
  3.登录数据库
 
  mysql -uroot -p
 
  3.创建用户
 
  CREATE USER '用户名'@'地址' IDENTIFIED BY '密码';
 
  4.创建数据库
 
  create database `数据库` default character set utf8 collate utf8_general_ci;
 
  5.赋权
 
  grant all privileges on 数据库.* to 用户名@localhost identified by '密码';
 
  6.进入数据库
 
  use 数据库
 
  7.还原表
 
  source 备份文件地址
 
  8.设置开机启动
 
  sudo chkconfig mysqld on
 
  到这里服务器的配置就结束了
 

(编辑:淮安站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章