版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_42167759/article/details/85108028
静态Web服务器的主要功能有NGX_HTTP_CORE_MODULE模块(HTTP框架的主哟奥成员)实现,当然,一个完整的静态Web服务器还有许多功能由其他的HTTP模块实现。
1》Web服务器的地址: 192.168.1.210
2》Web服务器端设置nginx的conf文件内容:
[root@localhost conf]# cat nginx.conf | grep -v '#'
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 8080;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
3》启动nginx服务器(找到nginx的二进制文件):
[root@localhost conf]# /usr/local/nginx/sbin/nginx
查找方式:# whereis nginx (会显示 nginx的安装路径)
4》查看是否启动成功:
[root@localhost conf]# ps -aux | grep nginx
root 34848 0.0 0.0 20748 1404 ? Ss 19:46 0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody 35739 0.0 0.0 23284 1768 ? S 20:52 0:00 nginx: worker process
root 35749 0.0 0.0 112720 984 pts/1 S+ 20:54 0:00 grep --color=auto nginx
5》客户端测试地址: 192.168.1.93
打浏览器地址栏输入: http://192.168.1.210:8080/
注意: 这里一定要加conf文件中监听的端口,否则http默认监听80端口。
6》显示的页面内容:
[root@localhost sbin]# cat ../html/index.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>