服务器上搭建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

http://IP/test.php

可以看见输出Hello!说明我们环境搭建成功了

需要注意的是,我们要去腾讯云服务器的配置安全组这里配置一下

勾选默认安全组放通全部端口,因为这些系统才允许我们访问服务器

centos 服务器配置的更多相关文章

  1. CentOS服务器配置发送邮件服务

    CentOS服务器配置发送邮件服务 lsb_release -a 查看linux系统版本 在CentOS6以上版本自带mailx版本12.4 rpm -qa | grep mailx 查看系统自带的m ...

  2. 【转载】CentOS服务器配置VPN详解

    转载来自: https://bbs.aliyun.com/read/162297.html http://www.wanghailin.cn/centos-7-vpn/ 操作系统:CentOS 6.3 ...

  3. centos 服务器配置(二) 之ftp配置

    Centos配置vsftpd服务器 1.通过yum来安装vsftpd [root@localhost ~]# yum -y install vsftpd 加-y是因为出现提示默认直接按Y.这里yum安 ...

  4. Linux(Centos)服务器配置node项目

    以阿里云服务器,CentOS系统为例 上一节已经提到怎么安装nodejs,以下是以vue项目为例 步骤: (1)首先安装vue脚手架@vue/cli, 官网参考 vue-cli3.x [root@lu ...

  5. 简单记录CentOS服务器配置JDK+Tomcat+MySQL

    项目需要部署到一台CentOS的服务器之上,之前这台服务器上面已经安装了一个Nginx和MySQL,跑的是PHP环境,有一个项目正在运行.而我们最新的项目是用Java写的,服务器是用的Tomcat,所 ...

  6. centos 服务器配置(三) 之定时任务

    有些liunx系统已经自带定时任务crontab,但是有的新装系统还未安装定时任务,这个时候就需要我们手动对其进行安装. 安装crontab: yum install crontabs 说明: /sb ...

  7. centos 服务器配置(一) 之端口占用

    1.查找被占用的端口 netstat -tln netstat -tln | grep 8060 netstat -tln 查看端口使用情况,而netstat -tln | grep 8060则是只查 ...

  8. CentOS服务器配置SSH免密码登录

    由于工作需要,经常要登录到多台服务器远程操作,每次都是ssh user@host:port 再输入密码,时间长了,难免觉得乏味-- 故而从度娘那里扒来了一些让SSH免密码登录的办法,其实这也是使用Gi ...

  9. centos 服务器配置注意项

    Mysql 出现Table‘xxx’is read only问题 Mysql数据库在由Mssql数据库导入数据文件后出现“ERROR 1036 (HY000): Table 'xxxx' is rea ...

随机推荐

  1. requests发送HTTPS请求(处理SSL证书验证)

    1.SSL是什么,为什么发送HTTPS请求时需要证书验证? 1.1 SSL:安全套接字层.是为了解决HTTP协议是明文,避免传输的数据被窃取,篡改,劫持等. 1.2 TSL:Transport Lay ...

  2. 通用全局CSS样式

    PC全局样式 *{padding:0;margin:0;} div,dl,dt,dd,form,h1,h2,h3,h4,h5,h6,img,ol,ul,li,table,th,td,p,span,a{ ...

  3. 小程序 显示Toobar

    要实现的效果 在 下面app.json  中加下列代码   "tabBar": { "color": "#7A7E83", "se ...

  4. arcgis【0基础 】【1】 中如何添加MXD

    1,第一种方法 MapControl  直接添加 if (!axMapControl1.CheckMxFile(FileName)) { MessageBox.Show("文件不合法&quo ...

  5. C++面试中的singleton类

    引子 “请写一个Singleton.”面试官微笑着和我说. “这可真简单.”我心里想着,并在白板上写下了下面的Singleton实现: 1 class Singleton 2 { 3 public: ...

  6. ubuntu用户注销后登录xmodmap无法自动运行

    2015-12-17 21:34:50 还是无法解屏后 自动运行xmodmap ,继续谷歌找到一方法,选装gnome-tweak-tool sudo apt-get install gnome-twe ...

  7. Linux OpenGL 实践篇-12-procedural-texturing

    程序式纹理 简单的来说程序式纹理就是用数学公式描述物体表面的纹路 .而实现这个过程的着色器我们称之为程序纹理着色器,通常在这类着色器中我们能使用的输入信息也就是顶点坐标和纹理坐标. 程序式纹理的优点 ...

  8. eclipse 的project explorer问题,这个怎样把localFileSystem去掉,

    这个非常简单 把勾去掉就可以了

  9. Gersgorin 圆盘

    将学习到什么 好多.   Gersgorin 圆盘定理   对任何 \(A \in M_n\),我们总可以记 \(A=D+B\),其中 \(D=\mathrm{diag}(a_{11},\cdots, ...

  10. OmniFocus

    褪墨・时间管理 “把所有事情都从你的脑袋里弄出来.在事情出现就做好相关行动的一系列决定,而不是在事情爆发的时候.以合适的类别组织好你的项目的各种提醒以及下一步行动.保持你的系统更新和完整,及时进行回顾 ...