当前位置:首页 » 编程软件 » centos重新编译安装

centos重新编译安装

发布时间: 2023-03-03 23:49:25

㈠ centos7怎么编译安装nginx

安装环境为:最小化安装的centos7,关闭seliunx。
最小化安装centos:
关闭selinux
sed –i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config

开始安装nginx1.7.8
创建群组
groupadd www
创建一个用户,不允许登陆和不创主目录
useradd -s /sbin/nologin -g www -M www
#下载最新版nginx
wget -C http://nginx.org/download/nginx-1.7.8.tar.gz
tar zxvf nginx-1.7.8.tar.gz
#编译基本能运行的nginx
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
make install

如果有错误提示:
./configure: error: C compiler cc is not found
解决方法:
yum install gcc gcc-c++

如果有错误提示:
./configure: error: the HTTP rewrite mole requires the PCRE library.
You can either disable the mole by using –without-http_rewrite_mole
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.
解决方法:
yum install pcre-devel

如果有错误提示:
./configure: error: SSL moles require the OpenSSL library.
You can either do not enable the moles, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using –with-openssl=<path> option.
解决方法:
yum install openssl-devel

以上错误提示依次解决后:再一次的运行
./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_mole --with-http_ssl_mole --with-http_gzip_static_mole
make
meke install

编译参数解释:
#指定运行权限的用户
--user=www
#指定运行的权限用户组
--group=www
#指定安装路径
--prefix=/usr/local/nginx
#支持nginx状态查询
--with-http_stub_status_mole
#开启ssl支持
--with-http_ssl_mole
#开启GZIP功能
--with-http_gzip_static_mole

因此要顺利的通过nginx编译安装必须安装的依赖关系有:
yum install gc gcc gcc-c++ pcre-devel zlib-devel openssl-devel

2、在 centos7 中为nginx的启动、重启、重载配置添加脚本
nginx直接启动的方法:
/usr/local/nginx/sbin/nginx

但是不是很方便,因此使用下面的脚本来控制nginx的启动关闭重载更加合理一些。
编辑文件:vim /usr/lib/systemd/system/nginx.service 添加下面的脚本,注意路径 !
[Unit]
Description=nginx - high performance web server
Documentation=http://nginx.org/en/docs/
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=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

systemctl的一些使用方法:
systemctl is-enabled servicename.service #查询服务是否开机启动
systemctl enable xxx.service #开机运行服务
systemctl disable xxx.service #取消开机运行
systemctl start xxx.service #启动服务
systemctl stop xxx.service #停止服务
systemctl restart xxx.service #重启服务
systemctl reload xxx.service #重新加载服务配置文件
systemctl status xxx.service #查询服务运行状态
systemctl --failed #显示启动失败的服务

因此,添加上面脚本后,centos7 中操作nginx的方法有
systemctl is-enabled nginx.service #查询nginx是否开机启动
systemctl enable nginx.service #开机运行nginx
systemctl disable nginx.service #取消开机运行nginx
systemctl start nginx.service #启动nginx
systemctl stop nginx.service #停止nginx
systemctl restart nginx.service #重启nginx
systemctl reload nginx.service #重新加载nginx配置文件
systemctl status nginx.service #查询nginx运行状态
systemctl --failed #显示启动失败的服务

㈡ 如何在centos下安装编译器

安装步骤如下:

1.启动Linux系统,并且以root的身份登陆
2.在VMware虚拟机的菜单中,点击:VM->install VMware Tools
3.这时候虚拟机的光驱会自动加载VWware安装目录下的linux.iso镜像,Linux系统也会自动挂载VMware Tools的虚拟光驱,并显示在桌面

4.进入VMware Tools的虚拟光驱里,把VMwareTools-8.1.4-227600.tar.gz解压到/tmp目录。

5.进入 /tmp,进入vmware-tools-distrib目录,执行vmware-install.pl文件(./vmware-install.pl)
6.接下来的配置中,遇到[yes]、[no]、[yes/no]的一般都是输入yes后按回车键,具体看信息说明,遇到其他的直接按回车键即可,最后选择合适的屏幕分辨率。

7.安装成功后,在VMware虚拟机的菜单中,点击:VM->Settings->Options->Shared Folders->ADD,选择Window下用来与Linux系统共享的文件夹,并在上面的复选框中选择Always Enabled即可

8.在Linux系统中,进入/mnt/hgfs目录下,就会发现上步骤中设置共享的Linux文件夹。

热点内容
java返回this 发布:2025-10-20 08:28:16 浏览:743
制作脚本网站 发布:2025-10-20 08:17:34 浏览:1007
python中的init方法 发布:2025-10-20 08:17:33 浏览:713
图案密码什么意思 发布:2025-10-20 08:16:56 浏览:875
怎么清理微信视频缓存 发布:2025-10-20 08:12:37 浏览:774
c语言编译器怎么看执行过程 发布:2025-10-20 08:00:32 浏览:1122
邮箱如何填写发信服务器 发布:2025-10-20 07:45:27 浏览:347
shell脚本入门案例 发布:2025-10-20 07:44:45 浏览:225
怎么上传照片浏览上传 发布:2025-10-20 07:44:03 浏览:911
python股票数据获取 发布:2025-10-20 07:39:44 浏览:871