CentOS gcc/gcc-c++/Apache/Nginx离线安装

gcc和gcc-c++

虚拟机挂载iso后

列出所有已安装的软件包

yum list installed

安装gcc

yum -y install gcc
yum -y install gcc_c++ 

移除gcc

yum -y remove gcc
yum -y remove gcc_c++ 

Apache

安装Apache服务

yum -y install httpd httpd-devel gcc gcc-c++ libstdc++-devel autoconf automake libtool

在这里插入图片描述
开启Apache服务,加入启动项

systemctl start  httpd.service
systemctl enable httpd.service

在这里插入图片描述

防火墙允许Apache服务

systemctl restart firewalld.service
firewall-cmd --add-service=http --permanent
#开放80端口
#firewall-cmd --zone=public --add-port=80/tcp --permanent
systemctl restart firewalld.service

在这里插入图片描述
输入
127.0.0.1
或者
局域网内ip(ifconfig: 192.168.x.x)
在这里插入图片描述
注意: Apache的服务,安装的时候是httpd;
firewall-cmd --add-service=http --permanent 需要加入参数permanent,永久的意思才不会重启失效。

Nginx

b站链接
CentOS+Nginx搭建1
CentOS+Nginx搭建2

如果第1、2、3步已经存在,跳过直接运行第4步。

  1. 安装make
yum -y install gcc automake autoconf libtool make
yum install gcc gcc-c++
  1. 安装pcre
cd /usr/local/src
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
tar -zxvf pcre-8.39.tar.gz
cd pcre-8.39
./configure
make && make install
  1. 安装zlib
cd /usr/local/src
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure
make && make install
  1. 安装openssl
cd /usr/local/src
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
tar -zxvf openssl-1.0.1t.tar.gz
  1. 安装nginx
#实际需要的依赖包
yum install -y zlib*

cd /usr/local/src
wget http://nginx.org/download/nginx-1.1.10.tar.gz
tar -zxvf nginx-1.1.10.tar.gz
cd nginx-1.1.10
./configure
make && make install

nginx启动命令:
ifconfig ip地址验证nginx是否打开成功

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

注:
端口和防火墙开闭:

firewall-cmd --zone=public --add-port=80/tcp --permanent #开放80端口

netstat -ntlp
kill xxxx

systemctl restart firewalld.service
systemctl stop firewalld.service#停止防火墙
systemctl start firewalld.service#启动防火墙
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz
-bash: wget: 未找到命令
#安装openssl时报错了
yum -y install #wget安装一下即可
  1. http转https

一定需要SSL证书,可以映射到域名(ip和域名映射在一起)

  • 访问ip地址映射到 /usr/local/nginx/html/index.html
  • 用xftp上传ssl签名文件, 创建文件夹/etc/nginx/key/ 存放两证书文件crt+key
  • 修改文件 /usr/local/nginx/conf/nginx.conf,server -> ssl_certificate,添加两证书文件crt+key映射信息。

映射(ln:link)两个文件夹地址同一个链接:

ln -s /usr/local/lib/libpcre.so.1 /lib
systemctl restart firewalld.service
systemctl stop firewalld.service#停止防火墙
systemctl start firewalld.service#启动防火墙
发布了17 篇原创文章 · 获赞 0 · 访问量 224

猜你喜欢

转载自blog.csdn.net/neheqi/article/details/105295940