Apache web服务器修改登录端口和访问端口的方法

利用ubuntu搭建的Apache web服务器,必须要修改Apache2 的默认端口80,因为这个端口往往会被多数黑客攻击,很容易会被修改或封闭,所以必须选择合适的端口,进行如下的设置:

1.修改 /etc/apache2/ports.conf

  • 将 NameVirtualHost *:80和Listen 80修改为自己需要的端口,例如:

  • NameVirtualHost *:1000

  • Listen 1000

2.修改/etc/apache2/sites-available/default

  • 将第一行的 VirtualHost :80 改为自己需要的端口VirtualHost :1000

3.修改 /etc/init.d/apache2/httpd.conf 添加

  • Servername localhost
    否则重启时会报如下错误
    * Restarting web server apache2
    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
    ... waiting apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
    [ OK ]

4.重启apache

  • sudo /etc/init.d/apache2 restart
    端口修改完毕。apache的端口修改为1000了。

你可能感兴趣的:(网络安全)