Nginx安装(linux)记录一下

本文介绍了Nginx的安装与启动步骤。首先需从官网下载最新版Nginx,设置configure时若yum源无法使用可重新指定。安装前置软件后在安装目录执行configure,无异常后执行安装命令。安装完成且配置文件无误即可启动,配置方法可网上查找。

1.下载最新版的nginx

http://nginx.org/

f637c0b9d9d52e91cbb7cf50dca31b68c28.jpg

2.设置configure

[root@BmccEoms188 nginx-1.15.2]# ./configure --sbin-path=/eoms/nginx --conf-path=/eoms/nginx/conf/nginx.conf --pid-path=/eoms/nginx/sbin/nginx.pid --with-http_ssl_module
-bash: ./configure: Permission denied
You have mail in /var/spool/mail/root
[root@BmccEoms188 nginx-1.15.2]# cd ../
[root@BmccEoms188 server]# chmod -R 755 nginx-1.15.2/
[root@BmccEoms188 server]# cd nginx-1.15.2/
[root@BmccEoms188 nginx-1.15.2]# ./configure --sbin-path=/eoms/nginx --prefix=/eoms/nginx --conf-path=/eoms/nginx/conf/nginx.conf --pid-path=/eoms/nginx/sbin/nginx.pid --with-http_ssl_module --http-client-body-temp-path=/eoms/nginx/temp/client_body_temp --http-proxy-temp-path=/eoms/nginx/temp/proxy_temp --http-fastcgi-temp-path=/eoms/nginx/temp/fastcgi_temp
checking for OS
 + Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found
[root@BmccEoms188 nginx-1.15.2]# yum -y install gcc
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Setting up Install Process
No package gcc available.
Error: Nothing to do
[root@BmccEoms188 nginx-1.15.2]# ls /etc/yum.repos.d/
rhel-source.repo
You have mail in /var/spool/mail/root
[root@BmccEoms188 nginx-1.15.2]# vim /etc/yum.repos.d/rhel-source.repo 
You have mail in /var/spool/mail/root
[root@BmccEoms188 nginx-1.15.2]# cd /etc/yum.repos.d/
[root@BmccEoms188 yum.repos.d]# vim RHEL.repo
[root@BmccEoms188 yum.repos.d]# yum -y install gcc
Loaded plugins: product-id, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.


File contains no section headers.
file: file://///etc/yum.repos.d/RHEL.repo, line: 1
'me=rhel6\n'
[root@BmccEoms188 yum.repos.d]# vim RHEL.repo
You have mail in /var/spool/mail/root
[root@BmccEoms188 yum.repos.d]# yum -y install gcc

提示yum源无法使用,可以重新指定下yum源

RHEL.repo配置如下,根据自己情况修改yum源:

#############################
[rhel6]
name=rhel6
baseurl=ftp://10.4.65.104/pub/rhel6
enabled=1
gpgcheck=0
##############################

安装前置软件主要是以下几个:

yum -y install gcc
yum -y install gcc-c++
yum install make
yum -y install pcre-devel
yum install -y zlib-devel
yum -y install openssl openssl-devel

插件装完后继续在nginx安装目录执行configure,注意后面的path是nginx的安装后目录和配置目录,根据自己情况修改

./configure --sbin-path=/eoms/nginx --prefix=/eoms/nginx --conf-path=/eoms/nginx/conf/nginx.conf --pid-path=/eoms/nginx/sbin/nginx.pid --with-http_ssl_module --http-client-body-temp-path=/eoms/nginx/temp/client_body_temp --http-proxy-temp-path=/eoms/nginx/temp/proxy_temp --http-fastcgi-temp-path=/eoms/nginx/temp/fastcgi_temp --with-http_stub_status_module --with-http_ssl_module --with-http_realip_module

3.没异常后执行安装命令

make && make install

装完没提示[error]这样的就算好了,可以切换到安装好的目录/eoms/nginx使用命令检查下

[root@BmccEoms188 nginx]# ./nginx -t
nginx: the configuration file /eoms/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /eoms/nginx/conf/nginx.conf test is successful

4.配置文件没问题就可以直接启动了

[root@BmccEoms188 nginx]# ./nginx -c /eoms/nginx/conf/nginx.conf
[root@BmccEoms188 nginx]# ps -ef|grep nginx
root      91858      1  0 11:30 ?        00:00:00 nginx: master process ./nginx -c /eoms/nginx/conf/nginx.conf
root      91859  91858  0 11:30 ?        00:00:00 nginx: worker process                 
root      91866  81906  0 11:30 pts/0    00:00:00 grep nginx

如何配置可以网上找一些参考,就不在这写了

转载于:https://my.oschina.net/GeminiLiu/blog/1933880

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值