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 ...
随机推荐
- ORA-00972_标识符过长
执行SQL查询报:"ORA-00972:标识符过长"错误. 执行SQL: SELECT T.F_FTBS, T.F_TZMC "X组/XXXX/XXXX名称", ...
- ctypes to load library in c/c++
cdll.LoadLibrary(...) restype (default is c_int) argtypes (what's the default? c_int?) customized da ...
- 关于gc日志中Desired Survivor的疑问和对象晋升老年代的小结
问题背景 (下面的所有内容都是根据书上的Serial/Serial Old收集器下的情况) 在<深入理解JVM>一书中的——3.6.3长期存活的对象将进入老年代的介绍中, 一个例子的jvm ...
- TreeView显示数据
1.添加默认节点 private void Form1_Load(object sender, EventArgs e) { TreeNode tn = new TreeNode("默认节点 ...
- Kettle-Spoon入门示例
Spoon 是Kettle的设计调试工具 [Demo文档下载] https://files.cnblogs.com/files/shexunyu/Kettle-Spoon-Demo%E5%B8%AE% ...
- Solr6+IKAnalyzer分词环境搭建
环境要求 Zookeeper版本:zookeeper-3.4.8 JDK版本: jdk1.8. Solr版本:solr-6.4.1 Tomcat版本:tomcat8 ZK地址:127.0.0.1:21 ...
- 简单的UDP程序
接受端: package com.dcz.udp; import java.io.IOException; import java.net.DatagramPacket; import java.ne ...
- Apache is running a threaded MPM, but your PHP module is not compiled to be threadsafe. you need to recompile php. pre-configuration failed
手动配置想要组合版本的wamp环境时,在服务器上直接下载的几个安装包怎么都组合安装不成功,纠结很久,终于找到原因.配置apache支持php后apache一直无法成功启动.后来发现php是nts的版本 ...
- 作用域插槽 向父组件传递 <template slot-scope="{ row, index }" slot="dateNo">
作用域插槽 向父组件传递 <template slot-scope="{ row, index }" slot="dateNo"> slotTes ...
- django 2.0 + pycharm2017 出现的问题
在创建完成app之后,在models文件里创建两个类:BlogType , Blog, 创建超级用户,注册admin,在登陆admin之后发现,发现 BlogType , Blog,并没有导入到adm ...