首次接触ngnix http,这里主要介绍不是编译,而是应用的时候遇到的问题;
1. 下载源码 nginx-1.9.1.tar.gz (选择自己喜欢的版本)
http://nginx.org/download/
2. 编译参考,有很多文章介绍了:
http://www.2cto.com/os/201406/310462.html
http://www.linuxidc.com/Linux/2013-09/89768.htm
http://jingyan.baidu.com/article/2fb0ba404f814e00f2ec5f9e.html
3.编译之后运行 ;
/sbin/ngnix ;
4.简单修改配置文件:
conf/nginx.conf
server {
listen 8060; // 端口号
server_name localhost; 本机IP
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html; //存放文件的目录
index index.html index.htm;
}
5.网页访问 :(这里说明遇到的问题,一定要加端口号)
查看本机IP 比如 192.168.1.24
http://192.168.1.24:8060/
提示 下面内容证明访问成功;
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.
6.怎么访问文件 :
比如我在html 的目录下放video.mp4
访问的时候直接 输入: http://192.168.1.24:8060/video.mp4 即可 ;
就可以直接访问网页播放视频
如果建立子目录的话,在html下建立audio ,防止文件即可;
http://10.94.43.52:8060/audio/xpg.mp3;
以上仅供参考,个人学习使用;