centos7 安装 apache + mysql + php

一、配置防火墙,开启80端口、3306端口
CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙。
1、关闭firewall:
#停止firewall服务
systemctl stop firewalld.service
#禁止firewall开机启动
systemctl disable firewalld.service


2、安装iptables防火墙
#安装
yum install iptables-services
#编辑防火墙配置文件
vi /etc/sysconfig/iptables


# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
:wq! #保存退出

#最后重启防火墙使配置生效
systemctl restart iptables.service
#设置防火墙开机启动
systemctl enable iptables.service


二、关闭SELINUX
#修改配置文件
vi /etc/selinux/config

#SELINUX=enforcing #注释掉
#SELINUXTYPE=targeted #注释掉
SELINUX=disabled #增加
:wq! #保存退出
#使配置立即生效
setenforce 0

三.安装apache

yum install httpd

可能会用到的:
systemctl start httpd.service #启动apache
systemctl stop httpd.service #停止apache
systemctl restart httpd.service #重启apache
systemctl enable httpd.service #设置apache开机启动

restart一下,然后:
输入localhost
出现之后代表已经安装上去了。


四.安装mysql

方法参考我mysql分类下的第一篇博文
http://blog.itpub.net/29773961/viewspace-1248176/
方法大致相同
在cent7中可以用:

CentOS 7的yum源中貌似没有正常安装mysql时的mysql-sever文件,需要去官网上下载

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh mysql-community-release-el7-5.noarch.rpm
# yum install mysql-community-server
成功安装之后重启mysql服务

# service mysqld restart
初次安装mysql是root账户是没有密码的
设置密码的方法

# mysql -uroot
mysql> set password for ‘root’@‘localhost’ = password('mypasswd');
mysql> exit
搞定!

如果需要安装mariadb,只需通过yum就可。


五.安装php

yum install php
安装PHP组件,使PHP支持mysql
yum install php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
重启对应服务
systemctl restart mysqld.service
systemctl restart httpd.service

六 、创建ftp:
一、先看Linux系统是否安装有vsftp软件(vs是very secure的意思)
[root@localhost /]# rpm -qa | grep vsftpd
vsftpd-3.0.2-9.el7.x86_64
如果没有安装,则需要安装
[root@localhost /]# yum install vsftpd

二、执行vsftpd
[root@localhost /]# service vsftpd start
Redirecting to /bin/systemctl start  vsftpd.service

三、FileZilla作为客户端,访问Linux服务器
以下是客户端软件FileZilla的Mac版本截图,Mac作为客户端,Linux作为服务器,IP地址是192.168.0.107,SSH协议传输,端口22。
用户名和密码为Linux的普通用户。
连接,ok。

猜你喜欢

转载自jasonshieh.iteye.com/blog/2278218