我们在这次学习时使用mini版操作系统镜像,安装速度快,也去除了我们用不到的软件。
在自定义硬件中,我们可以再次配置虚拟机的内存、cpu等硬件属性:
内存:建议8G以上
CPU:4核以上主流即可
出现此界面后敲“回车”进入安装程序
虽然默认会自动帮我们格式化磁盘,但也需要点击确认一下。
点击左上角完成即可
安装过程中我们可以设置密码
当出现 重启 按钮时,说明系统已经安装完成
重启后的样子
至此,我们在VMware中对CentOS的基本安装已经完成。
vi /etc/sysconfig/network-scripts/ifcfg-ens33
systemctl restart network
查看本地ip:
之前的网络配置是使用dhcp方式分配ip地址,这种方式会在系统每次联网的时候分配一个ip给我们用,也就是说有可能系统下次启动的时候ip会变,这样非常不方便我们管理。
网段和网关可以通过以下方式查看:
配置静态ip首先需要打开网卡配置文件
- vi /etc/sysconfig/network-scripts/ifcfg-ens33
-
- TYPE=Ethernet
- PROXY_METHOD=none
- BROWSER_ONLY=no
- BOOTPROTO=static
- DEFROUTE=yes
- IPV4_FAILURE_FATAL=no
- IPV6INIT=yes
- IPV6_AUTOCONF=yes
- IPV6_DEFROUTE=yes
- IPV6_FAILURE_FATAL=no
- IPV6_ADDR_GEN_MODE=stable-privacy
- NAME=ens33
- UUID=d768f819-cfc1-4a6d-8bf5-cd7359a86c75
- DEVICE=ens33
- ONBOOT=yes
- # IP地址 (根据自己的环境修改)
- IPADDR=192.168.8.101
- # 子网掩码
- NETMASK=255.255.255.0
- # 网关(根据自己的环境修改)
- GATEWAY=192.168.8.2
- #DNS
- DNS1=223.5.5.5
-
完整配置截图如下:
环境不同,ip地址可能不同,所以需要安装自己的ip网段和网关地址进行配置。
systemctl restart network
查看ip地址,发现ip地址已经变成固定ip 192.168.8.101:
•vmware中网关是否正确
•直接ping ip是否能通(物理连接排查)
•卸载重装
- #阿里
- 223.5.5.5
- 223.6.6.6
- #腾讯
- 119.29.29.29
- 182.254.118.118
- #百度
- 180.76.76.76
- #114 DNS
- 114.114.114.114
- 114.114.115.115
- #谷歌
- 8.8.8.8
- 8.8.4.4
-
CentOS 7.0默认使用的是firewall作为防火墙
查看防火墙状态
- firewall-cmd --state
-
停止firewall
- systemctl stop firewalld.service
-
禁止firewall开机启动
- systemctl disable firewalld.service
-
放行端口
- firewall-cmd --zone=public --add-port=80/tcp --permanent
-
重启防火墙
- firewall-cmd --reload
-
参考:https://www.bt.cn/bbs/thread-19376-1-1.html
安装命令:
- yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
-
安装成功的截图如下:
一定要保管好链接和用户名、密码。
- 外网面板地址: http://183.208.21.74:8888/f5ec0b77
- 内网面板地址: http://192.168.8.101:8888/f5ec0b77
- username: 5ano3drc
- password: cd9e6a03
-
安装好进行访问:
面板卸载:
- /etc/init.d/bt stop && chkconfig --del bt && rm -f /etc/init.d/bt && rm -rf /www/server/panel
-
版本区别
常用版本分为四大阵营
http://nginx.org/
https://www.nginx.com
http://openresty.org/cn/
http://tengine.taobao.org
Nginx的安装可以选择源码编译的方式也可以使用宝塔面板安装,本文采用的是源码编译安装。
- tar zxvf nginx-1.21.6.tar.gz
- cd nginx-1.21.6
- ./configure --prefix=/usr/local/nginx # --prefix=/usr/local/nginx 指安装路径是/usr/local/nginx,如果前面安装了宝塔Linux面板,这一步应该不会出现环境问题。
-
- make
- make install
-
提示:
- checking for OS
- + Linux 3.10.0-693.el7.x86_64 x86_64
- checking for C compiler ... not found
- ./configure: error: C compiler cc is not found
-
安装gcc
- yum install -y gcc
-
提示:
- /configure: error: the HTTP rewrite module requires the PCRE library.
- You can either disable the module by using --without-http_rewrite_module
- option, or install the PCRE library into the system, or build the PCRE library
- statically from the source with nginx by using --with-pcre=<path> option.
-
安装perl库
- yum install -y pcre pcre-devel
-
提示:
- ./configure: error: the HTTP gzip module requires the zlib library.
- You can either disable the module by using --without-http_gzip_module
- option, or install the zlib library into the system, or build the zlib library
- statically from the source with nginx by using --with-zlib=<path> option.
-
安装zlib库:
- yum install -y zlib zlib-devel
-
接下来执行
- make
- make install
-
启动nginx
进入安装好的目录 /usr/local/nginx/sbin
- ./nginx # 启动
- ./nginx -s stop #快速停止
- ./nginx -s quit #优雅关闭,在退出前完成已经接受的连接请求
- ./nginx -s reload #重新加载配置
-
安装成功的截图如下:
在如下位置创建服务脚本nginx.service
- vi /usr/lib/systemd/system/nginx.service
-
服务脚本内容如下(注意路径要对应,这里的路径是/usr/local/nginx/sbin):
- [Unit]
- Description=nginx - web server
- After=network.target remote-fs.target nss-lookup.target
-
- [Service]
- Type=forking
- PIDFile=/usr/local/nginx/logs/nginx.pid
- ExecStartPre=/usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
- ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
- ExecReload=/usr/local/nginx/sbin/nginx -s reload
- ExecStop=/usr/local/nginx/sbin/nginx -s stop
- ExecQuit=/usr/local/nginx/sbin/nginx -s quit
- PrivateTmp=true
-
- [Install]
- WantedBy=multi-user.target
-
重新加载系统服务
- systemctl daemon-reload
-
启动服务
- systemctl start nginx.service
-
开机启动
- systemctl enable nginx.service
-
测试,访问http://192.168.8.101/:
宝塔面板安装的版本不是nginx的开源版本,作为学习,建议使用源码编译安装,熟练了再使用宝塔版的nginx。