centos 云服务器 配置php环境变量,云服务器(Centos)上配置Apache环境

1、清除系统垃圾

yum clean all

2、执行系统更新

yum -y update

3、安装apache

yum -y install httpd

4、设置Apache的开机自启

systemctl enable httpd.service

5、创建开机启动,将server启动起来

systemctl start httpd.service

6、配置虚拟主机(一般情况下,我们对于Apache的使用都是通过不同的虚拟主机来配置的,并不会在一个服务器上只部署一个网站)

(创建目录)mkdir -p /var/www/yourname.com/public_html

(设置目录权限)chown -R apache:apache /var/www/yourname.com/public_html

chmod -R 755 /var/www

(创建首页文件)nano /var/www/yourname.com/public_html/index.html

(文件index.html内容如下,可自行修改)

Rayue's Blog

Welcome to my world! Come in please!

(修改Apache的配置文件)mkdir /etc/httpd/sites-available

mkdir /etc/httpd/sites-enabled

nano /etc/httpd/conf/httpd.conf

(在文件httpd.conf最后加上一行)IncludeOptional sites-enabled/*.conf

(创建配置文件yourname.com.conf,内容如下)nano /etc/httpd/sites-available/yourname.com.conf

ServerName yourname.com

DocumentRoot /var/www/yourname.com/public_html

ErrorLog /var/www/yourname.com/error.log

CustomLog /var/www/yourname.com/requests.log combined

(创建软连接)ln -s /etc/httpd/sites-available/yourname.com.conf /etc/httpd/sites-enabled/yourname.com.conf

7、重启Apache

apachectrl restart

8、打开浏览器,输入yourname.com(你的域名)进行访问

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值