建立个人网站

1. 服务器和域名

云服务器用的是阿里云的t5,系统是 Ubuntu 18

域名也是在阿里云租的,完成备案.

2. 搭建web服务

我这里使用的时 Apache

1. 安装  

apt install apache2 -y

2. 检查服务是否启动  

systemctl status apache2

Apache的常用操作命令

/etc/init.d/apache2 start       //启动Apache服务
/etc/init.d/apache2 stop       //停止Apache服务
/etc/init.d/apache2 restart    //重启Apache服务

3.服务器已经启动,现在就可以输入主机的IP或者服务器公网IP访问(域名访问稍后),此时访问到的是Apache默认的页面。

 

4.修改Apache的网站根目录和默认网页。

修改根目录

在 /etc/apache2/sites-available/000-default.conf 文件的

修改000-default.conf中的配置

ServerAdmin webmaster@localhost
DocumentRoot /var/www/html    //这是网站根目录

修改默认网页

在 /etc/apcahce2/mods-available/dir.conf  下面是默认的,表明在访问到下面的文件

<IfModule mod_dir.c>
    DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm 
</IfModule>

在里面添加一个目录 /test 同时在 /var/www/html 目录下建立一个 /test 目录

    <IfModule mod_dir.c>
        DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm /test
    </IfModule>

在里面新建一个名为 index.html 的文件,在访问时 IP/test 就能访问到 该目录。

5. 域名解析

 在阿里云,控制台的域名管理页面,配置域名与IP绑定。

此时还不能通过域名访问网站,还需要进行ICP备案,提交各种资料等待完成即可。

via

Ubuntu 18.04下使用Apache搭建一个web服务器

 创建自己的个人网站(一)

猜你喜欢

转载自www.cnblogs.com/protogenoi/p/11100198.html
今日推荐