Linux的Apache搭建和测试

安装apache

yum install httpd
systemctl start httpd
systemctl status httpd

创建第一个网站

vim /var/www/html/index.html
#编写一个简易网站
chmod 644 /var/www/html/index.html
chown apache:apache /var/www/html/index.html
#本机访问虚拟机ip查看

创建第二个网站

mkdir -p /var/www/study/html /var/www/study/log
vim /var/www/study/html/index.html
#编写一个简易网站
sudo chown apache:apache /var/www/study/html /var/www/study/log
sudo chmod 755 /var/www/study
vim /etc/httpd/conf.d/study.conf
<VirtualHost *:80>
ServerName study.com
DocumentRoot /var/www/study/html
ErrorLog /var/www/study/log/error.log
CustomLog /var/www/study/log/access.log combined
</VirtualHost>
vim /etc/hosts
127.0.0.1 study.com
systemctl restart httpd