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 ...
随机推荐
- [转]SqlServer索引的原理与应用
索引的概念 索引的用途:我们对数据查询及处理速度已成为衡量应用系统成败的标准,而采用索引来加快数据处理速度通常是最普遍采用的优化方法. 索引是什么:数据库中的索引类似于一本书的目录,在一本书中使用目录 ...
- 编译运行第一个Java程序——通过示例学习Java编程3
作者:CHAITANYA SINGH 来源:https://www.koofun.com//pro/kfpostsdetail?kfpostsid=13 在本教程中,我们将了解如何编写.编译和运行Ja ...
- Java编程基础-反射
一.java反射 1.反射:动态获取类的信息,以及动态调用对象的方法的功能.可以理解为动态看透类的能力. 2.主要功能:在运行时判断任意一个对象所属的类:在运行时构造任意一个类的对象:在运行时判断任意 ...
- 一张图告诉你,只会NodeJS还远远不够!
NodeJS看似小巧简单,却威力无边,一张图,秒懂!!! 可能很多人还不会安装,但至少已经会了javascript,或者至少会了jquery,那么js还可以干更多的事情!js还可以干更多的事情!js还 ...
- NSTimer 实现时钟回调方法
在开发过程中,发现时钟调用的地方比较多.所以对时钟进行了一个简单的统一封装.具体代码如下: 1.时钟回调函数的声明: #pragma mark 时钟回调处理 //时钟回调 +(NSTimer*) ls ...
- python super详解
一.super() 的入门使用 - 在类的继承中,如果重定义某个方法,该方法会覆盖父类的同名方法,但有时,我们希望能同时实现父类的功能, 这时,我们就需要调用父类的方法了,可通过使用 super 来实 ...
- 并查集+思维——X-Plosives
一.问题描述(题目链接) 有n种化合物,每种化合物由两种元素组成.当几种的化合物数量等于他们所含不同元素的数量时,就会发生爆炸.现在依次给出化合物的组成,当新的化合物与之前的化合物放在一起会发生爆炸时 ...
- 新数据的GT列表
制作新数据集时需要重新制作train_GT,test_GT 代码: dic = {} with open('/home/bnrc/all_image_GT.txt','r') as file: for ...
- Perl 使用哈希的引用
$ref = \%hash_clomnname_linevalue; $hash_of_whole_table{$table_name} = {%$ref};
- 洛谷 P1019 单词接龙 (DFS)
题目传送门 当时一看到这题,蒟蒻的我还以为是DP,结果发现标签是搜索-- 这道题的难点在于思路和预处理,真正的搜索实现起来并不难.我们可以用一个贪心的思路,开一个dic数组记录每个单词的最小重复部分, ...