腾讯云Linux云服务器搭建网站
騰訊云Linux云服務(wù)器搭建網(wǎng)站
基本準(zhǔn)備及操作
這里的安裝過(guò)程使用系統(tǒng)自帶的yum工具進(jìn)行安裝
- 安裝jdk和java運(yùn)行環(huán)境
- 安裝mysql
- 安裝tomcat
- 安裝httpd服務(wù)
- 部署web項(xiàng)目到服務(wù)器
- 實(shí)現(xiàn)從服務(wù)器tomcat上下載文件
1.安裝jdk
使用如下指令可以安裝1.8版本的jdk yum -y install java-1.8.0-openjdk*2.安裝mysql
使用如下指令安裝mysql服務(wù)端 yum -y install mysql-servermysql安裝后會(huì)為root賬戶隨機(jī)生成一個(gè)臨時(shí)的密碼,需要通過(guò)以下指令去查看:
grep 'temporary password' /var/log/mysqld.logmysql修改密碼的方式:使用root賬戶和臨時(shí)密碼登錄后,使用以下指令修改
update user set password=password("新密碼") where user='root';網(wǎng)上查了一下?lián)f(shuō)5.7 版本password 字段改成authentication_string password函數(shù)還是原來(lái)的password函數(shù)
mysql> update user set authentication_string=password(‘123’) where user=‘root’;
跳過(guò)密碼驗(yàn)證:
vim /etc/my.cnf
加入skip-grant-tables
添加用戶
GRANT USAGE ON . TO ‘username’@‘localhost’ IDENTIFIED BY ‘password’ WITH GRANT OPTION;
同時(shí)還需要開(kāi)放mysql的ip訪問(wèn)權(quán)限:
mysql> use mysql; Database changed mysql> select host,user,password from user;//查看ip權(quán)限 //設(shè)置允許所有ip訪問(wèn) update user set host='%' where host = 'localhost'; flush privileges;//刷新 exit;配置特定ip的root權(quán)限:
GRANT ALL PRIVILEGES ON *.* TO ' root '@'xxx.xxx.xxx.xxx'update user set password='填入你加密后的密碼' where host='xxx.xxx.xxx.xxx';//添加密碼3.安裝tomcat
使用如下指令安裝tomcat yum -y install tomcat安裝tomcat后需要將tomcat服務(wù)開(kāi)啟:
systemctl start tomcattomcat常用指令:
查看tomcat的狀態(tài):systemctl status tomcat
啟動(dòng)tomcat::systemctl start tomcat
停止tomcat:systemctl stop tomcat
重啟tomcat:systemctl restart tomcat
4.安裝httpd
使用如下指令安裝httpd服務(wù) yum -y install httpd如果失敗則嘗試下面的指令:
yum --disableexcludes=all install -y httpd安裝后也需要將httpd服務(wù)開(kāi)啟:
service httpd starthttpd常用指令:
httpd -version #檢查是否安裝
yum install httpd #安裝http服務(wù)
service httpd start #啟動(dòng)http服務(wù)
service httpd status #檢查http服務(wù)狀態(tài))
service httpd restart #重啟http服務(wù)
更換http默認(rèn)頁(yè)面的方法:
進(jìn)入/var/www/html 目錄下,更改index.jsp頁(yè)面的內(nèi)容
并且通過(guò)http協(xié)議可以訪問(wèn)到的頁(yè)面也都被存放在該目錄下,例如在該目錄下放入login.jsp就可以通過(guò)http://hostnumber/login.jsp可以訪問(wèn)到。
查看指定端口號(hào)的開(kāi)放情況:
netstat -an | grep 端口號(hào)5.部署web項(xiàng)目到服務(wù)器
先將web項(xiàng)目打成war包,然后放置到tomcat的webapps目錄下
同時(shí)在tomcat的server.xml修改添加內(nèi)容:
這樣就配置了web項(xiàng)目的入口
之后再重啟tomcat
6.實(shí)現(xiàn)從服務(wù)器tomcat上下載文件
進(jìn)入tomcat的conf目錄下
在web.xml文件中該更改如下配置
將上面listings屬性的 value值 從false改為 ture
并在server.xml配置下載路徑入口:
在訪問(wèn)的host標(biāo)簽種加入:
例如加入以下入口:
<Context docBase="/usr/share/tomcat/webapps/Download" path="download" />那么當(dāng)請(qǐng)求:主機(jī)ip/域名:8080/download/文件名
就會(huì)從服務(wù)器上的/usr/share/tomcat/webapps/Download目錄下下載對(duì)應(yīng)的文件
7.使用iptables替換firewall防火墻
- 在iptables中添加開(kāi)放8080端口
修改/etc/sysconfig/iptables文件,增加如下一行:
參考博文:
https://www.cnblogs.com/yoyoketang/p/10186513.html
https://www.cnblogs.com/webttt/p/10290429.html
總結(jié)
以上是生活随笔為你收集整理的腾讯云Linux云服务器搭建网站的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: centos 7-aarch64如何替换
- 下一篇: 如何在Windows 10上设置默认Li