您现在的位置是:群英 > 服务器 > 系统运维
如何在阿里云的CentOS6上面配置Web服务器?
Admin发表于 2023-07-07 11:26:34283 次浏览
这篇文章主要给大家介绍“如何在阿里云的CentOS6上面配置Web服务器?”的相关知识,下文通过实际案例向大家展示操作过程,内容简单清晰,易于学习,有这方面学习需要的朋友可以参考,希望这篇“如何在阿里云的CentOS6上面配置Web服务器?”文章能对大家有所帮助。

最近买了阿里云的CentOS系统的Linux服务器,花了些时间把环境配置了一下,用来发布后端。

  1. jdk
  2. Tomcat
  3. Maven
  4. Git
  5. 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

到这里服务器的配置就结束了


以上就是关于如何在阿里云的CentOS6上面配置Web服务器?的介绍啦,需要的朋友可以参考上述内容,希望对大家有帮助,想要了解更多,欢迎关注群英网络,小编将为大家输出更多高质量的实用文章!

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。

相关信息推荐
2023-09-23 11:18:56 
摘要:CentOS6.4部署DNS服务器的记录
2021-12-28 18:56:42 
摘要:随着云计算的快速发展,不少人都了解了云计算的概念,那么究竟云计算的发展会给我们带来哪些好处呢?今天小编就和大家一起来探讨一下关于云计算的好处,感兴趣的朋友跟随小编一起往下看吧。
2023-09-23 11:23:58 
摘要:阿里云专有网络Nginx 安装与配置实现外网访问
群英网络助力开启安全的云计算之旅
立即注册,领取新人大礼包
  • 联系我们
  • 24小时售后:4006784567
  • 24小时TEL :0668-2555666
  • 售前咨询TEL:400-678-4567

  • 官方微信

    官方微信
Copyright  ©  QY  Network  Company  Ltd. All  Rights  Reserved. 2003-2019  群英网络  版权所有   茂名市群英网络有限公司
增值电信经营许可证 : B1.B2-20140078   粤ICP备09006778号
免费拨打  400-678-4567
免费拨打  400-678-4567 免费拨打 400-678-4567 或 0668-2555555
微信公众号
返回顶部
返回顶部 返回顶部