CentOS7 Apache的安装配置 CentOS7 Apache的安装配置 centos7重启apache、nginx、mysql、php-fpm命令

apache
启动
systemctl start httpd
停止
systemctl stop httpd
重启
systemctl restart httpd


mysql
启动
systemctl start mysqld
停止
systemctl stop mysqld
重启
systemctl restart mysqld


php-fpm
启动
systemctl start php-fpm
停止
systemctl stop php-fpm
重启
systemctl restart php-fpm


nginx
启动
systemctl start nginx
停止
systemctl stop nginx
重启
systemctl restart nginx

  前些天安装了Nginx,为了好玩我就又安装Apache,Apache的安装还算顺利。在此做一下学习记录和经验分享。


一、安装httpd  

1、先查看一下系统有没有已经安装了httpd的,如果啥都没查到,那就是没安装呗。如果有#rpm -e 查到的rpm报名,进行删除即可。

1
#rpm -qa | grep httpd

2、我这里就直接使用yum安装了(会自动安装依赖包),为了简单方便。

1
yum -y install httpd

3、httpd -v 查看安装版本,安装成功之后,查找配置文件位置,对httpd进行配置

1
#find / -name "httpd . conf"

 4、当然,最好将原有配置文件备份一份如:

1
#cp  /etc/httpd/conf/httpd . conf   /etc/httpd/conf/httpd . conf . origin

二、配置Apache文件

1、特别是要注意这个配置,这是Apache 2.4的一个新的默认值,拒绝所有的请求!

<Directory />
  AllowOverride none
    Require all denied
</Directory>  

把none改为ALL, centos里用的是vi或vim进行编辑,在指令模式下输入/要查询的内容,enter,可以进行内容的查找,然后对其进行修改。(vim查找教程:http://jingyan.baidu.com/article/219f4bf793a0c2de442d38f1.html)

2、配置WEB站点

如我的网站页面文件为默认的

Listen 8080
<VirtualHost *:8080>
  DocumentRoot "/var/www/html"
  ServerName localhost:8080
  <Directory "/var/www/html">
    AllowOverride All
    Options FollowSymLinks Includes ExecCGI
    Require all granted
  </Directory>
</VirtualHost>

3、添加防火墙端口

我这使用的是centos7默认的firewall防火墙,添加8080端口。

1
#firewall-cmd --permanent --zone= public  --add-port= 8080 - 8081 /tcp  --永久添加端口<br>#fire-cmd --permanent --zone= public  --list-ports  --查看开启端
#systemctl restart firewalld.service  //修改配置后需要重启服务使其生效

当然,如果你使用的云服务器,那么还需要在控制台添加端口支持(我在mysql的安装和配置中有谈到这个问题)

4、测试

在自己window的浏览器上输入192.168.x.x:8080/index.html即可解析出在服务器路径中html文件了。

apache
启动
systemctl start httpd
停止
systemctl stop httpd
重启
systemctl restart httpd


mysql
启动
systemctl start mysqld
停止
systemctl stop mysqld
重启
systemctl restart mysqld


php-fpm
启动
systemctl start php-fpm
停止
systemctl stop php-fpm
重启
systemctl restart php-fpm


nginx
启动
systemctl start nginx
停止
systemctl stop nginx
重启
systemctl restart nginx

猜你喜欢

转载自www.cnblogs.com/cly0205/p/10445097.html