勇敢走出第一步尝试,建立自己的个人网站,这里提供你所需要的建站技术指导和工具,助你初步搭建自己的个人首页,并会协助你不断地完善,来体验动手建站的乐趣吧。
前期准备
Linux系统检查
1.服务器型号
dmidecode|grep "System Information" -A9|egrep "Manufacturer|Product"
dmidecode | grep -A16 "System Information$"
2. 操作系统
cat /etc/redhat-release
3.CPU
(1)统计信息:
lscpu
(2)型号:
cat /proc/cpuinfo | grep name | cut -f2 -d: | uniq -c
cat /proc/cpuinfo |grep 'model name' |uniq
(3)物理CPU数:
cat /proc/cpuinfo| grep"physical id"| sort| uniq| wc -l
(4)核数:
cat /proc/cpuinfo| grep "cpu cores"| uniq
(5)逻辑个数:
cat /proc/cpuinfo| grep "processor"| wc -l
(6)注意:以上命令无法使用,则
yum -y install util-linux
4.内存
(1)内存使用情况:
(2)硬件信息:
dmidecode -t memory
(3)使用情况:
cat /proc/meminfo
5.硬盘
lsblk
(2)硬盘和分区的详细信息:
fdisk -l
(3)挂载使用情况
df -h
6.本章操作命令简单说明
7.依赖安装(Nginx所需)
yum install gcc #安装所需编译器
yum install readline-devel #安装readline-devel 开发包
yum install zlib-devel #安装 zlib-devel 开发包
yum -y install pcre-devel openssl openssl-devel
8、Linux操作命令大全 :https://www.linuxcool.com/
Nginx部署配置
1.下载安装
(1)添加Centos的Nginx源
sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
(2)yum方式安装
sudo yum install -y nginx
(3)启动Nginx并设置开机自动运行
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
(4)访问链接
curl localhost:80
(5)浏览器访问
①查看IP
ifconfig
②IP访问
curl 192.168.1.7:80
③注意防火墙设置
查看状态
systemctl status firewalld
停用防火墙
systemctl stop firewalld
更多防火墙操作参考: https://blog.ugoodu.cn/post/36
④浏览器访问效果
2.配置修改
(1)手动修改配置
vim /etc/nginx/nginx.conf
修改以下部分内容:
操作方式
:
(2)重启nginx使配置生效
nginx -s reload
(3)浏览器访问链接
①通过https://gitee.com/ugoodu/html下载获得
②上传到/home/目录下
③上传工具获取:Mr梁Live 后台回复 “ MobaXterm ”
④工具使用参考:https://blog.ugoodu.cn/post/85
(4)拓展:nginx配置在线生成
地址:https://www.digitalocean.com/community/tools/nginx
3.Nginx其他安装方式
参考地址:https://blog.ugoodu.cn/post/32
花生壳部署配置(尝试性学习)
教程地址:https://service.oray.com/question/11630.html
1.下载地址:https://hsk.oray.com/download/
(1)Centos7:
wget https://down.oray.com/hsk/linux/phddns-5.1.0.i386.rpm
(2)备注:若是没有wget命令,查看:https://blog.ugoodu.cn/post/86
2、安装:s udo yum install phddns-5.1.0.i386.rpm
3、SN码获取
4、 浏览器访问http://b.oray.com ,输入花生壳Linux 5.0在安装时产生 SN码与默认登录密码admin 登录 。
这里按照花生壳教程若干步骤……
5、有兴趣的朋友可花6块钱购买一下http服务,简单尝试一把心酸……
阿里云服务(入门尝试)
1
、控制台:https://homenew.console.aliyun.com/home/dashboard/Operation
2、服务器购买(Centos 7)
个人网站入门学习的,在每年双11活动时候挑个套餐选购更优惠
3、购买域名
(1)入口在这:域名>注册域名
(2)挑选域名注意每年的续费问题
拓展:域名解析
1、域名解析
(1)入口:域名列表>进入域名解析列表
(2)解析设置:注意填写公网IP地址
2、修改Nginx配置,监听配置域名,通过nginx -s reload重载配置即可通过域名访问网站
拓展:Cerbot 生成 SSL证书
1、Certbot的官方网站:https://certbot.eff.org
(1)选择Centos版教程:https://certbot.eff.org/lets-encrypt/centosrhel7-nginx
(2)参考教程:https://blog.ugoodu.cn 搜索cerbot或ssl
2、安装cerbot:
#添加 EPEL 软件源扩展
sudo yum -y install epel-release
#安装 Certbot
sudo yum -y install python2-certbot-nginx
3、生成证书操作:
根据Nginx安装方式,选择证书生成模式(本文采用自动模式)
(1)自动模式(nginx默认安装模式,自动配置)
#需要填写邮箱(建议,填写:证书过期提醒)
#sudo certbot --nginx
#不需要填写邮箱(方便)
sudo certbot --nginx --register-unsafely-without-email
(2)手动模式:(nginx非默认安装,手动配置)
# sudo certbot --nginx certonly
#sudo certbot --nginx --register-unsafely-without-email certonly
(3)证书生成问题:
错误一:(找不到nginx)
Could not choose appropriate plugin: The nginx plugin is not working; there may be problems with your existing configuration.
The error was: NoInstallationError("Could not find a usable 'nginx' binary. Ensure nginx exists, the binary is executable, and your PATH is set correctly.",)
由于没有将nginx放到环境变量中,设置nginx软连接
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
ln -s /usr/local/nginx/conf/ /etc/nginx
#Cerbot手动模式
sudo certbot --nginx --register-unsafely-without-email certonly
错误二: Could not choose appropriate plugin: The nginx plugin is not working; there may be problems with your existing configuration.
The error was: PluginError('Nginx build is missing SSL module (--with-http_ssl_module).',)
通过nginx -V查看nginxconfigure arguments没有安装ssl模板,在nginx目录中重新构建
nginx -V
cd /apps/svr/nginx ./configure --with-http_ssl_module
make && make install
#再次检查
nginx -V
#Cerbot手动模式
sudo certbot --nginx --register-unsafely-without-email certonly
(4)证书生成过程中会自动识别nginx.conf中的域名配置,没有配置域名,需要手动输入
No names were found in your configuration files. Please enter in your
domain
name(s) (comma and/or space separated) (Enter 'c' to cancel):
(5)证书生成的路径存放于 /etc/letsencrypt/live/*
4、nginx配置证书(nginx.conf配置文件内容)
(1)参考配置内容:
server { listen 80; listen [::]:80; listen 443 ssl http2; listen [::]:443 ssl http2; server_name example.com; return 301 https://www.example.com$request_uri; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; }server { listen 80; listen [::]:80; server_name www.example.com; return 301 https://www.example.com$request_uri; }
server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name www.example.com; root /var/www/www.example.com; index index.html index.htm; ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem; include /etc/letsencrypt/options-ssl-nginx.conf; ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; }
(2)重载配置:nginx -s reload
5、更新证书
(1)主要命令: cerbot renew
(2)自动更新:sudo certbot renew --dry-run
(3)定时更新:每月1、11、21日零点更新
echo "0 0 1,11,21 * * root python -c 'import random; import time; time.sleep(random.random() * 3600)' && certbot renew && nginx -s reload" | sudo tee -a /etc/crontab > /dev/null
(4)更新日志查看:ls /var/log/letsencrypt/
如需转载,请在后台回复“转载”获取授权
注意:本文归作者所有,未经作者允许,不得转载