检查是否安装
rpm -qa httpd
安装
sudo yum install httpd
启动
sudo systemctl start httpd.service
永久开启80端口
sudo firewall-cmd --permanent --zone=public --add-port=80/tcp
重启 防火墙
sudo systemctl restart firewalld.service
设置服务开机启动
sudo systemctl enable httpd.service
相关操作
状态:systemctl status httpd.service
启动:systemctl start httpd.service
停止:systemctl stop httpd.service
重启:systemctl restart httpd.service
开机 自启动:systemctl enable httpd.service
取消 开机 自启动:sudo systemctl disable httpd.service
创建虚拟机
- 创建虚拟主机相关目录
网站目录:mkdir /var/www/html/magento2ce
日志目录:sudo mkdir /var/log/httpd/magento2ce
虚拟主机配置目录:sudo mkdir /etc/httpd/vhost-conf.d
- 创建虚拟主机配置文件
sudo touch /etc/httpd/vhost-conf.d/magento2ce.conf
配置虚拟机
vim /etc/httpd/vhost-conf.d/magento2ce.conf
添加以下内容# 监听所有IP的80端口 <VirtualHost *:80> # 管理员的邮件地址 ServerAdmin apache@qq.com # 设置虚拟机域名 ServerName magento2ce.com # 虚拟机网站根目录 DocumentRoot /var/www/html/magento2ce # 错误日志 ErrorLog /var/log/httpd/magento2ce/error_log # 访问日志 CustomLog /var/log/httpd/magento2ce/access_log common </VirtualHost> <Directory /var/www/html/magento2ce> Options -Indexes +Includes +FollowSymLinks +MultiViews AllowOverride All #允许所有请求 Require all granted </Directory>
- 自动加载虚拟机配置文件
sudo sh -c ' echo "Include vhost-conf.d/*.conf" >> /etc/httpd/conf/httpd.conf'
- 重启Apache
sudo systemctl restart httpd.service
- 创建虚拟主机相关目录
- 开启rewrite重写引擎
开启重写
sudo sh -c ' echo "LoadModule rewrite_module modules/mod_rewrite.so" >> /etc/httpd/conf/httpd.conf'
重启Apache
sudo systemctl restart httpd.service
CentOS7 安装 Apache
最新推荐文章于 2022-08-19 14:45:23 发布