云服务器

如何在云服务器上部署web应用

2020-05-27 09:47:44 157

上手学Web的同学通常会用本地进行测试,那假如当我们做完之后,怎么挂载到互联网上让其他人也能够使用我们的web应用呢?

 

这是就要使用现在比较多的云服务器,简单易用又实惠,例如我在睿江云购买ubuntu系统的云服务器,接下来就介绍一下如何在云服务器上构建自己的web服务。

1、我们需要更新apt系统软件的源地址,确保我们能获取到apache2的正确安装;

    sudo apt update

 

 

2、安装Apache2服务

     sudo  apt  install  apache2

 

3、配置Apache2(这步其实不做也可以,里面已经配置好了)

    vim etc/apache2/apache2.conf

 

配置文件位置(默认)

    # Include generic snippets of statements
    IncludeOptional conf-enabled/*.conf
    # Include the virtual host configurations:
    IncludeOptional sites-enabled/*.conf

 

配置项目路径(默认)

    DocumentRoot /var/www/html

 

 

配置域名:

    ServerName  localhost:80

 

禁止目录遍历(不禁止的话,若外部访问到文件目录的地址时,apache2会把整个目录的内容全部例举出来,安全起见都是禁止掉的)

    <Directory "D:/Apache/blog.phpha.com">
      Options Indexes FollowSymLinks  # 修改为: Options  FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>

 

4、启动/重启/停止

Start Apache2 Server /启动apache服务

    # /etc/init.d/apache2 start
    or
    $ sudo /etc/init.d/apache2 start

Task: Restart Apache 2 Server /重启apache服务
# /etc/init.d/apache2 restart
or
$ sudo /etc/init.d/apache2 restart
Task: Stop Apache 2 Server /停止apache服务
# /etc/init.d/apache2 stop</code></pre>

 

5、到这里我们就基本安装好了apache2;这样我们就可以将我们的之前做好的web服务放置到apache2的根目录/var/www/html里面,例如我们放了 index.html;那么我们就可以用云主机的公网ip + 端口号80 :...:80/index 进行访问。

睿江云官网链接:www.eflycloud.com

上一篇: 无

微信关注

获取更多技术咨询