Nginx以及修改配置文件
安装nginx
# 安装nginxsudo apt-get install nginx# 查看安装的版本sudo nginx -v
打开nginx配置文件
# nginx和它的相关模块的运行由它的配置文件决定.# nignx配置文件的默认名称是nginx.conf# 其配置文件路径/usr/local/nginx/conf, /etc/nginx, 或者/usr/local/etc/nginx.# nginx会查找到这个目录下的文件 /etc/nginx/nginx.confsudo vim /etc/nginx/nginx.conf
在/etc/nginx/nginx.conf中的http的选项下添加server
...http {...server {access_log /var/log/nginx/access.log; # 访问日志路径error_log /var/log/nginx/error.log; # 错误日志路径listen 9090; # 指定端口号index index.html; # 指定主页,这样可以通过端口号直接访问主页root /var/www/html/; # 目录下需要有index.html, 否则会报错 nginx 403 forbiddencharset utf-8; # 指定utf8编码,避免中文乱码}server {...# 这里是第二个server的配置...}...}...
配置后重启Nginx
# reloading the configuration filesudo nginx -s reload
通过浏览器访问在线文档
浏览器打开: http://192.168.200.153:9090/index.html
其中ip为nginx服务器所在服务的ip,9090为我们在nginx中配置的端口号,
