内容简介:Nginx、Apache2修改默认端口号
Ubuntu15.04 Nginx、Apache2修改默认端口号
通过Ubuntu 搭建WEB服务器,根据需求,有时候会需要修改web服务的端口号,这里我记录整理了Nginx和Apache修改默认端口号和网站目录的过程。
Nginx修改默认端口
1、修改配置文件
vi /etc/nginx/sites-enabled/default listen 81 default_server; # 修改自己需要的端口号 listen 81 default_server;
2、重载Nginx服务
/etc/init.d/nginx reload
3、修改默认网站目录
vi /etc/nginx/sites-enabled/default #root /var/www/html; root /usr/share/nginx/html; # 修改默认网站目录
4、修改默认主页文档:
修改或者替换index.html vi /usr/share/nginx/html/index.html # 修改index.html
Apache修改默认端口
1、修改配置文件
(1)修改 /etc/apache2/ports.conf 将
NameVirtualHost *:80 Listen 80 # 改为自己需要的端口 NameVirtualHost *:9000 Listen 9000
(2)有的需要修改default和httpd.conf配置文件
#查找配置文件 sudo find / -name default sudo find / -name httpd.conf
(3)重启apache
sudo /etc/init.d/apache2 restart 端口修改完毕。apache的端口修改为9000了。
2、修改默认网站目录:
/etc/apache2/sites-available/default # 将/var/www 修改位你的路径: /var/www/html/
3、修改默认主页文档:
/etc/apache2/mods-available/dir.conf # 将 index.* 替换为 xxx.*
4、最后
不过随apache2的版本不同 文件的放置位置不一样。
查看 DirectoryIndex 在apache2哪个文件里面:grep -iR DirectoryIndex /etc/apache2
# 我的Ubuntu 15.04是这样的 root@ubuntu:/etc/apache2/sites-enabled# grep -iR DirectoryIndex /etc/apache2 /etc/apache2/mods-enabled/dir.conf:DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm /etc/apache2/mods-available/dir.conf:DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm
以上所述就是小编给大家介绍的《Nginx、Apache2修改默认端口号》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 大数据常用组件默认端口号
- centos 修改ssh默认端口号
- 如何修改tomcat默认端口号8080的方法
- Ubuntu下Nginx与Apache2修改默认端口号
- SSH 协议端口号 22 背后的故事
- 10分钟理解TCP、UDP 和端口号
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
The Master Switch
Tim Wu / Knopf / 2010-11-2 / USD 27.95
In this age of an open Internet, it is easy to forget that every American information industry, beginning with the telephone, has eventually been taken captive by some ruthless monopoly or cartel. Wit......一起来看看 《The Master Switch》 这本书的介绍吧!