centos 服务器配置
服务器上搭建Apache +MySQL+PHP +JDK +Tomcat环境,用的是Linux Centos7.0系统。以下为安装过程记录。
安装防火墙
Centos7.0系统默认用firewall防火墙,先要停止firewall,然后安装iptables防火墙。注意在Centos7.0版本下,/etc/init.d/iptables restart 这样的命令是无效的,应该用systemctl命令。
先关闭firewall
[root@VM_45_237_centos ~]# systemctl stop firewalld.service
禁止firewall开机启动
[root@VM_45_237_centos ~]# systemctl disable firewalld.service
查看防火墙状态
[root@VM_45_237_centos ~]# firewall-cmd -state
结果显示:notrunning
安装iptables
[root@VM_45_237_centos ~]# yum install -y iptables
安装iptables_services
[root@VM_45_237_centos ~]# yum install iptables-services
配置防火墙
[root@VM_45_237_centos ~]# vi /etc/sysconfig/iptables
允许80端口和3306通过防火墙
[root@VM_45_237_centos ~]# -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
[root@VM_45_237_centos ~]# -A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
设置iptables开机启动
[root@VM_45_237_centos ~]# systemctl enable iptables.service
开启防火墙
[root@VM_45_237_centos ~]# systemctl start iptables.service
查看状态
[root@VM_45_237_centos ~]# systemctl status iptables.service
结果显示:Actice:active(exited)
(高亮显示)
安装Apache
安装Apache
[root@VM_45_237_centos ~]# yum -y install httpd
用Web浏览器从客户端PC访问服务器,显示默认欢迎页面“Testing123..”
将Apache设置为开机启动
[root@VM_45_237_centos ~]# systemctl enable httpd.service
查看httpd的开机启动状态列表
[root@VM_45_237_centos ~]# systemctl list-unit-files
安装MySQL
Centos自带的repo不会自动更新每个软件的最新版本,所以无法用yum安装MySQL的高级版本(来源:>http://www.cnblogs.com/XBlack/p/5178758.html)
先安装带有可用的MySQL5系列社区版资源的rpm包
[root@VM_45_237_centos ~]# rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
查看当前可用的MySQL安装资源
[root@VM_45_237_centos ~]# yum repolist enabled|grep “mysql.*-community.*”
安装mysql
[root@VM_45_237_centos ~]# yum -y install mysql-community-server
MySQL的几个重要目录:
- 主配置文件:
/etc/my.cnf
- 数据库文件:
/var/lib/mysql
- 日志文件:
/var/log
(my.cnf配置参考:>http://blog.csdn.net/l1028386804/article/details/50635169)
以下是我的my.cnf文件主要配置:
#
[client]
port = 3306
socket = /var/lib/mysql/mysql.cock
character-set-server = utf8
[mysqld]
port = 3306
socket = /var/lib/mysql/mysql.sock
character-set-server=utf8
basedir = /var/lib/mysql
datadir = /var/lib/mysqldb
pid_file = /var/run/mysqld/mysql.pid
server_id = 1
table_open_cache = 4096
max_connection = 300
max_connection_error = 100
max_allowed_packet = 128M
log_error = /var/log/mysqld.log
general_log = ON
general_log_file = /var/lib/mysql/log/mysql.log
innodb_buffer_pool_size = 128M
expire_logs_days = 30
join_buffer_size = 128M
sort_buffer_size = 2M
read_rnd_buffer_size = 2M
sql_mode = NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
[mysqldump]
quick
max_allowed_packet = 32M
[mysql]
no-auto-rehash
[myisamchk]
key_buffer = 16M
sort_buffer_size = 16M
read_buffer = 8M
write_buffer = 8M
[mysqld_safe]
open_files_limit = 8192
#
将MySQL加入开机启动
[root@VM_45_237_centos ~]# systemctl enable mysqld
启动MySQL
[root@VM_45_237_centos ~]# systemctl start mysqld
(重置密码,参考:>http://www.cnblogs.com/XBlack/p/5178758.html)
[root@VM_45_237_centos ~]# mysql_secure_installtion
安装PHP
安装PHP (参考:>http://www.jb51.net/article/97434.htm)
[root@VM_45_237_centos ~]# yum -y install php php-mbstring php-pear
打开PHP配置文件
[root@VM_45_237_centos ~]# vi /etc/php.ini
line 878 删除分号,设置时区
date.timezone = “Asia/Shanghai”
重启httpd
[root@VM_45_237_centos ~]# systemctl restart httpd
创建一个PHP测试页面
[root@VM_45_237_centos ~]# vi /var/www/html/index.php
<html>
<body>
<div style="width: 100%; font-size: 40px; font-weight: bold; text-align: center;">
<?php
print Date("Y/m/d");
?>
</div>
</body>
</html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
显示当前日期:
安装JDK
安装JDK(参考:>http://www.linuxidc.com/Linux/2016-09/134941.htm)
查看yum库中的jdk版本
[root@VM_45_237_centos ~]# yum search java|grep jdk
- 1
电脑上装的是1.7.0版本,所以选择安装1.7.0版本
[root@VM_45_237_centos ~]# yum install java-1.7.0-openjdk
- 1
设置变量环境
[root@VM_45_237_centos java]# vi /etc/profile
- 1
在打开的profile文件中添加如下内容:
#
#set java environment
JAVA_HOME=/usr/java/jdk1.7.0_79
JRE_HOME=/usr/java/jdk1.7.0_79/jre
CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
export JAVA_HOME JRE_HOME CLASS_PATH PATH
#
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
让修改立即生效
[root@VM_45_237_centos ~]# . /etc/profile
- 1
检查java当前版本
[root@VM_45_237_centos ~]# java -version javac
- 1
安装Tomcat
安装Tomcat
# [root@VM_45_237_centos ~]# wget http://apache.opencas.org/tomcat/tomcat-7/v7.0.73/bin/apache-tomcat-7.0.73.tar.gz
- 1
创建一个downloads目录,把压缩文件放里面
[root@VM_45_237_centos ~]# mkdir /usr/local/downloads
[root@VM_45_237_centos ~]# mv apache-tomcat-7.0.73.tar.gz /usr/local/downloads
- 1
- 2
- 3
解压缩到/usr/local下面
[root@VM_45_237_centos ~]# tar -C /usr/local/downloads -zxvf /usr/local/downloads/apache-tomcat-7.0.73.tar.gz
- 1
启动Tomcat
[root@VM_45_237_centos ~]# /usr/local/apache-tomcat-7.0.73/bin/startup.sh
- 1
结果显示:Tomcat started.
创建完成后
WinSCP的使用,文件上传的,我们可以自己搭建SVN环境,也可以直接使用腾讯官方推荐的WinSCP工具,这个腾讯官方有教程的,使用的可以查看教程,我们选择SCP,输入腾讯云host,Linux系统选择22端口,然后输入用户名和密码就可以,直接登录
登录成功之后,我们在/var/www/html文件夹里,直接从我们的电脑拉文件
当然,你想自己创建php文件也是可以的
进入/var/www/html文件夹之后
vim test.php
然后按键盘的I键,会出现Insert操作提示的
输入php代码
<?php
echo "Hello";
然后按ESC键退出,输入:wq,保存退出,这是VI编辑器的简单使用
然后在浏览器访问,输入腾讯云的IP
可以看见输出Hello!说明我们环境搭建成功了
需要注意的是,我们要去腾讯云服务器的配置安全组这里配置一下
勾选默认安全组放通全部端口,因为这些系统才允许我们访问服务器
centos 服务器配置的更多相关文章
- CentOS服务器配置发送邮件服务
CentOS服务器配置发送邮件服务 lsb_release -a 查看linux系统版本 在CentOS6以上版本自带mailx版本12.4 rpm -qa | grep mailx 查看系统自带的m ...
- 【转载】CentOS服务器配置VPN详解
转载来自: https://bbs.aliyun.com/read/162297.html http://www.wanghailin.cn/centos-7-vpn/ 操作系统:CentOS 6.3 ...
- centos 服务器配置(二) 之ftp配置
Centos配置vsftpd服务器 1.通过yum来安装vsftpd [root@localhost ~]# yum -y install vsftpd 加-y是因为出现提示默认直接按Y.这里yum安 ...
- Linux(Centos)服务器配置node项目
以阿里云服务器,CentOS系统为例 上一节已经提到怎么安装nodejs,以下是以vue项目为例 步骤: (1)首先安装vue脚手架@vue/cli, 官网参考 vue-cli3.x [root@lu ...
- 简单记录CentOS服务器配置JDK+Tomcat+MySQL
项目需要部署到一台CentOS的服务器之上,之前这台服务器上面已经安装了一个Nginx和MySQL,跑的是PHP环境,有一个项目正在运行.而我们最新的项目是用Java写的,服务器是用的Tomcat,所 ...
- centos 服务器配置(三) 之定时任务
有些liunx系统已经自带定时任务crontab,但是有的新装系统还未安装定时任务,这个时候就需要我们手动对其进行安装. 安装crontab: yum install crontabs 说明: /sb ...
- centos 服务器配置(一) 之端口占用
1.查找被占用的端口 netstat -tln netstat -tln | grep 8060 netstat -tln 查看端口使用情况,而netstat -tln | grep 8060则是只查 ...
- CentOS服务器配置SSH免密码登录
由于工作需要,经常要登录到多台服务器远程操作,每次都是ssh user@host:port 再输入密码,时间长了,难免觉得乏味-- 故而从度娘那里扒来了一些让SSH免密码登录的办法,其实这也是使用Gi ...
- centos 服务器配置注意项
Mysql 出现Table‘xxx’is read only问题 Mysql数据库在由Mssql数据库导入数据文件后出现“ERROR 1036 (HY000): Table 'xxxx' is rea ...
随机推荐
- struts2的@Result annotation 如何添加params,并且在页面取值
http://www.bubuko.com/infodetail-2492575.html .............................................. 标签:lai ...
- JAVA常用知识总结(十一)——数据库(一)
项目中用到的不常见sql语法 1:空值不在前的排序 select a.* from WZX_SCZY A order by SCZY_START_TIME desc nulls last (不加nul ...
- NodeJs前端构建工具 ——————之Grunt篇
为何使用grunt? 如何搭建grunt? 开始第一个grunt项目 基础()合并js文件 开始第一个grunt项目 基础()压缩js 开始第一个grunt项目 基础()代码规范检测 开始第一个gru ...
- python学习之序列化
序列化:不同编程语言之间传递对象需要序列化成标准格式,有XML /JSON,json格式化为字符串,UTF-8编码,速度快,切实标准格式.JSON 和 Python内置的数据类型对应如下: JSON ...
- axios delete 请求
axios delete 请求 在传递一个参数的时候,直接把参数放在请求连接后面,用'/' 连接就可以了 this.axios.post(this.APIURL+'/'+ID) //http://ww ...
- 下面给出了四种设计模式的作用: 外观(F
下面给出了四种设计模式的作用: 外观(Fa?ade :为子系统中的一组功能调用提供一个一致的接口,这个接口使得这一子系统更加容易使用: 装饰(Decorate):当不能采用生成子类的方法进行扩充时,动 ...
- LN : Eden Polymorphic And OOP Design Pattern Abstract Factory
Appreciation to our TA, +7, who designed this task. Client.cpp #include <iostream> #include &l ...
- ES6中新增的字符串方法
实例方法:includes(), startsWith(), endsWith() 传统上,JavaScript 只有indexOf方法,可以用来确定一个字符串是否包含在另一个字符串中.ES6 又提供 ...
- Sencha Touch和jQuery Mobile的比较
第一组-行销和平台支持 Sencha Touch和jQuery Mobile都以HTML5框架著称.jQuery Mobile谦虚的说自己只是内建于所有流行的移动设备平台,而Sencha Touch则 ...
- POJ 2449 Remmarguts' Date
Time Limit: 4000MS Memory Limit: 65536K Total Submissions: 30725 Accepted: 8389 Description &quo ...