圆月山庄资源网 Design By www.vgjia.com
利用CentOS6搭建简易的web服务
提示: 其中没有涉及到MySQl、MongoDB的安装和使用,包括docker容器等,使用nginx反向代理静态服务
centOS服务器
可以选用国外或者国内的服务器,这里只展示centOS系统配置,本人实在window系统下完成下列操作
选购一台合适的云服务器,系统为centOS
在window系统下安装xshell和xftp, 保证可以系统访问centOS系统
使用xshell连接上云服务器,使用超级管理员root登录
登录完成之后安装nginx
下面是需要下载的文件:
- 首先安装
wget # yum install wget
- nginx以来与gcc的编译环境
# yum install gcc-c++
- nginx的http模块需要使用pcre来解析正则表达式
# yum -y install pcre pcre-devel
- 依赖的解压包
# yum -y install zlib zlib-devel
- 下载nginx压缩包
# wget -c https://nginx.org/download/nginx-1.10.3.tar.gz
解压与安装:
- 解压nginx
# tar -zxvf nginx-1.10.3.tar.gz
- 进入nginx目录
#cd nginx-1.10.3
- 对nginx的源码进行编译
# ./configure
- 开始编译
# make
- 继续编译
# make install
- 查看nginx安装的目录
# whereis nginx
它会告诉你nginx在哪,nginx的命令在/usr/local/nginx/sbin目录下
nginx命令:
nginx命令开启# ./nginx
停止# ./nginx -s stop
# ./nginx -s quit
重启# ./nginx -s reload
开启nginx # ./nginx
必须在nginx的安装目录下的sbi文件开启,当然也可全局配置
查看是否开启nginx # ps aux|grep nginx
nginx配置
以下是nginx配置的部分参考
# http server server { listen 80; server_name www.didiheng.com; #charset koi8-r; #access_log logs/host.access.log main; access_log off; #缓存日志关闭 server_tokens off; tcp_nopush on; tcp_nodelay on; gzip on; #gzip开启 gzip_comp_level 6; #gzip比率 gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; proxy_connect_timeout 5; #缓存链接 proxy_read_timeout 60; proxy_send_timeout 5; proxy_buffer_size 16k; proxy_buffers 4 64k; proxy_busy_buffers_size 128k; proxy_temp_file_write_size 128k; location / { root /www; #此处绝对地址 index index.html index.htm; try_files $uri $uri/ /index.html; //使用客户端路由需配置 rewrite ^(.*)$ https://$host$1 permanent; /强制定向https } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } #https server server { listen 443 ssl; server_name www.didiheng.com; ssl_certificate server.crt; ssl_certificate_key server.key; ssl_session_cache shared:SSL:1m; ssl_session_timeout 5m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; access_log off; server_tokens off; tcp_nopush on; tcp_nodelay on; expires epoch; gzip on; gzip_comp_level 6; gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png; proxy_connect_timeout 5; proxy_read_timeout 60; proxy_send_timeout 5; proxy_buffer_size 16k; proxy_buffers 4 64k; proxy_busy_buffers_size 128k; proxy_temp_file_write_size 128k; location / { root /www; index index.html index.htm; try_files $uri $uri/ /index.html; } } }
在以上配置中我直接将https开启了,若没有相关的ssl配置,请将https服务注释 使用 # 即可
修改之后重启nginx
# ./nginx -s reload
使用serverIP或域名访问 访问
github原址
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
圆月山庄资源网 Design By www.vgjia.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
圆月山庄资源网 Design By www.vgjia.com
暂无评论...
更新日志
2024年07月08日
2024年07月08日
- 孙露《不让我的眼泪陪我过夜》HQCDII 限量版 [WAV+CUE][517M]
- dnf巴卡尔武器怎么融合
- 魔兽世界wlk最强职业是什么 wlk最吃香最强职业推荐
- dnf巴卡尼单人和多人区别
- 群星《大热唱片DSD》APE+CUE
- 草蜢2012《软硬草蜢》3CD[WAV+CUE整轨]
- 雨林唱片发烧大碟-陈果《明知故犯HQCD》[WAV+CUE]
- 群星.2024-狐妖小红娘月红篇电视剧原声带【恒星引力】【FLAC分轨】
- 许美静.1998-好美静【上华】【WAV+CUE】
- 谭咏麟.1996-独一无二【宝丽金】【WAV+CUE】
- dnf平民怎么弄宠物
- dnf弓箭手职业
- dnf强化基础精通适合哪些职业
- V.A中国管弦乐纪念名盘《乡之音》FLAC
- [雨果]赵鹏《赵鹏·LPCD45》LPCD45[WAV+CUE]