CENTOS7阿里云LAMP环境搭建

FTP

yum -y install vsftpd   #安装vsftpd服务
systemctl enable vsftpd.service #设置vsftpd服务自启动
vsftpd -v   #查看vsftpd服务版本
#然后用root账户登录ftp,下载/etc/vsftpd/vsftpd.conf,修改以下部分
anonymous_enable=NO #设置不允许匿名访问
local_enable=YES    #设置本地用户可以访问
chroot_list_enable=YES  #使用户不能离开主目录
chroot_list_file=/etc/vsftpd/chroot_list

修改主机名
hostnamectl set-hostname 新主机名

防火墙
CENTOS7默认是firewalld,改为iptables

systemctl stop firewalld.service    #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
yum install iptables    #安装iptables
yum install iptables-services   #安装iptables-services
#修改/etc/sysconfig/iptables,配置防火墙

-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT #SSH
-A INPUT -p tcp -m state --state NEW -m tcp --dport 21 -j ACCEPT #FTP   
-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT #HTTP
-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT #MySQL
-A INPUT -p tcp -m state --state NEW -m tcp --dport 443 -j ACCEPT #HTTPS

一篇不错的iptables配置教程

LAMP
安装Apache,PHP,MySQL,PHP连接MySQL库组件
yum -y install httpd php ysql mysql-server php-mysql

创建一个新用户

useradd username    #创建一个自己的用户
passwd username     #设定username这个用户的密码
username ALL=(ALL)  ALL #在root ALL=(ALL) ALL下面加入,表示把username加入sudoers组
mkdir conf  #在家目录创建conf文件夹
ln -s /etc/httpd httpd  #新建Apache软连接

mariadb配置
linux改了。。。默认是mariadb了,那就这样吧,配置还是照改

port=3306   #端口号
thread_concurrency = 2 #并发线程数,建议CPU核数乘2,因为是单核CPU,所以双线程
init_connect='SET collation_connection = utf8_general_ci' 
init_connect='SET NAMES utf8' 
character-set-server=utf8 #默认编码
collation-server=utf8_general_ci #默认排序方式
skip-character-set-client-handshake

[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

此外,还要用mysql -u root -p进入mariadb运行
GRANT ALL PRIVILEGES ON . TO ‘root’@’%’IDENTIFIED BY ‘123456’ WITH GRANT OPTION;(123456为登录密码)
flush privileges;
使mariadb可以被远程访问,这样就可以用navicat来访问了

启动与自启动

systemctl start iptables.service
systemctl start httpd.service
systemctl start vsftpd.service
systemctl start mariadb.service
systemctl enable iptables.service
systemctl enable httpd.service
systemctl enable vsftpd.service
systemctl enable mariadb.service
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值