GVKun编程网logo

CentOS6.5使用yum命令方便快捷安装Nginx(yum 安装 nginx)

24

如果您对CentOS6.5使用yum命令方便快捷安装Nginx和yum安装nginx感兴趣,那么这篇文章一定是您不可错过的。我们将详细讲解CentOS6.5使用yum命令方便快捷安装Nginx的各种细

如果您对CentOS6.5使用yum命令方便快捷安装Nginxyum 安装 nginx感兴趣,那么这篇文章一定是您不可错过的。我们将详细讲解CentOS6.5使用yum命令方便快捷安装Nginx的各种细节,并对yum 安装 nginx进行深入的分析,此外还有关于CentOS 6.4使用yum安装nginx + php + mysql、CentOS 7 使用yum 安装nginx、Centos 7下安装nginx,使用yum install nginx,提示没有可用的软件包、CentOS 7,使用yum安装Nginx的实用技巧。

本文目录一览:

CentOS6.5使用yum命令方便快捷安装Nginx(yum 安装 nginx)

CentOS6.5使用yum命令方便快捷安装Nginx(yum 安装 nginx)

https://my.oschina.net/ramboo/blog/223408



当然,首先要求是可以联网的CentOS系统,因为yum安装需要互联网连接。

1.为了追加 Nginx 的 yum 仓库,需要创建一个文件 /etc/yum.repos.d/Nginx.repo,并将下面的内容复制进去:

[Nginx]
name=Nginxrepo
baseurl=http://Nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1

2.编辑并保存/etc/yum.repos.d/Nginx.repo文件后,在命令行下执行

[root@localhost~]#yumlist|grepNginx
Nginx.i3861.4.7-1.el6.ngx@Nginx
Nginx-debug.i3861.4.7-1.el6.ngxNginx

会发现就是最新的稳定版

于是直接执行

yum-yinstallNginx

安装即可

3.这种安装和从源代码编译Nginx的安装,文件所处的位置不一样,安装完执行下面的命令

[root@localhost~]#find/-name*Nginx*
/etc/Nginx/Nginx.conf
[root@localhost~]#whereisNginx
Nginx:/usr/sbin/Nginx/etc/Nginx/usr/share/Nginx

你会发现主要文件安装到了/etc/Nginx下

接下来是启动Nginx服务,可以执行

[root@localhost~]#serviceNginxstart
正在启动Nginx[确定]

接着查看Nginx的进程

[root@localhost~]#netstat-lntp|grepNginx
tcp000.0.0.0:800.0.0.0:*LISTEN7910/Nginx

[root@localhost~]#ps-ef|grepNginx
root79101023:43?00:00:00Nginx:masterprocess/usr/sbin/Nginx-c
/etc/Nginx/Nginx.conf
Nginx79127910023:43?00:00:00Nginx:workerprocess
root79422459023:52pts/100:00:00grepNginx

缺省是一个master,一个slave,可以在配置Nginx.conf文件里调整

4.设置开机自动启动
在centos6.5下测试了一下,不用设置

chkconfigNginxon

可以自行开机自动启动

CentOS 6.4使用yum安装nginx + php + mysql

CentOS 6.4使用yum安装nginx + php + mysql

源码安装Nginx可能会困难重重啊,所以推荐个简单的yum安装方式
添加新源
[root@localhost ~]# wget http://www.atomicorp.com/installers/atomic
[root@localhost ~]# sh ./atomic
Atomic Archive installer,version 2.0.9

BY INSTALLING THIS SOFTWARE AND BY USING ANY AND ALL SOFTWARE
PROVIDED BY ATOMICORP LIMITED YOU ACKNowLEDGE AND AGREE:

THIS SOFTWARE AND ALL SOFTWARE PROVIDED IN THIS REPOSITORY IS
PROVIDED BY ATOMICORP LIMITED AS IS,IS UNSUPPORTED AND ANY
EXPRESS OR IMPLIED WARRANTIES,INCLUDING,BUT NOT LIMITED TO,THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND fitness FOR A PARTIculaR
PURPOSE ARE disCLaimED. IN NO EVENT SHALL ATOMICORP LIMITED,THE
copYRIGHT OWNER OR ANY CONTRIBUTOR TO ANY AND ALL SOFTWARE PROVIDED
BY OR PUBLISHED IN THIS REPOSITORY BE LIABLE FOR ANY DIRECT,
INDIRECT,INCIDENTAL,SPECIAL,EXEMPLARY,OR CONSEQUENTIAL damAGES
(INCLUDING,PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE,DATA,OR PROFITS; OR BUSInesS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,WHETHER IN CONTRACT,
STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH damAGE.

Do you agree to these terms? (yes/no) [Default: yes] yes
Configuring the [atomic] yum archive for this system

Installing the Atomic GPG key: OK
Downloading atomic-release-1.0-16.el6.art.noarch.rpm: OK



The Atomic Rocket Turtle archive has Now been installed and configured for your system
The following channels are available:
atomic - [ACTIVATED] - contains the stable tree of ART packages
atomic-testing - [disABLED] - contains the testing tree of ART packages
atomic-bleeding - [disABLED] - contains the development tree of ART packages


[root@localhost ~]# yum check-update
[root@localhost ~]# yum -y install Nginx MysqL-server PHP-fpm PHP-cli PHP-pdo PHP-MysqL PHP-mcrypt PHP-mbstring PHP-gd PHP-tidy PHP-xml PHP-xmlrpc PHP-pear PHP-pecl-memcache PHP-eaccelerator

添加Nginx 默认主页index.PHP
[root@localhost ~]#vim /etc/Nginx/conf.d/default.conf

location / {
root /usr/share/Nginx/html;
index index.html index.htm index.PHP;
}

配置Nginx支持PHP
[root@localhost ~]#vim /etc/Nginx/conf.d/default.conf

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.PHP$ {
root /usr/share/Nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.PHP;
fastcgi_param SCRIPT_FILENAME /$document_root$fastcgi_script_name;
include fastcgi_params;
}
配置PHP-fpm
[root@localhost ~]# vim /etc/PHP-fpm.d/www.conf

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set,the default user's group
; will be used.
; RPM: apache Choosed to be able to access some dir as httpd
user = Nginx
; RPM: Keep a group allowed to write in log dir.
group = Nginx

启动MysqL
[root@localhost ~]# service MysqLd start
初始化 MysqL 数据库: Installing MysqL system tables...
130324 14:00:01 [Note] libgovernor.so not found
OK
Filling help tables...
130324 14:00:13 [Note] libgovernor.so not found
OK

To start MysqLd at boot time you have to copy
support-files/MysqL.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MysqL root USER !
To do so,start the server,then issue the following commands:

/usr/bin/MysqLadmin -u root password 'new-password'
/usr/bin/MysqLadmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:
/usr/bin/MysqL_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MysqL daemon with:
cd /usr ; /usr/bin/MysqLd_safe &

You can test the MysqL daemon with MysqL-test-run.pl
cd /usr/MysqL-test ; perl MysqL-test-run.pl

Please report any problems with the /usr/bin/MysqLbug script!

[确定]
正在启动 MysqLd: [确定]
[root@localhost ~]# service Nginx start
正在启动 Nginx: [确定]
[root@localhost ~]# /etc/rc.d/init.d/PHP-fpm start
正在启动 PHP-fpm: [确定]

在浏览器中输入http://ip/index.PHP

CentOS 7 使用yum 安装nginx

CentOS 7 使用yum 安装nginx

CentOS 7 使用yum 安装nginx

一、为Centos设置yum存储库

1.在/etc/yum.repos.d/目录下创建nginx.repo

touch nginx.repo

2.编辑nginx.repo

vim nginx.repo

内容如下:
	[nginx]
	name=nginx repo
	baseurl=http://nginx.org/packages/centos/7/$basearch/
	gpgcheck=0
	enabled=1
说明:baseurl中的7,代表CentOS 7.x版本

二、安装nginx

1.执行安装命令

yum install -y nginx

2.安装之后,查看nginx的默认安装目录

whereis nginx

三、启动、停止和重新加载配置

1.启动nginx

nginx

2.停止nginx

nginx -s stop(快速关机)或者 nginx -s quit(优雅的关机)

3.重新加载配置

nginx -s reload

4.重新打开日志文件

nginx -s reopen

四、查询正在运行的nginx进程列表

1.使用ps命令

ps -ax | grep nginx

Centos 7下安装nginx,使用yum install nginx,提示没有可用的软件包

Centos 7下安装nginx,使用yum install nginx,提示没有可用的软件包

 

  Centos 7下安装Nginx,使用yum install Nginx,提示没有可用的软件包。

复制代码

18 (flaskApi) [root@67 flaskDemo]# yum -y install Nginx
19 已加载插件:fastestmirror, langpacks
20 Loading mirror speeds from cached hostfile
21  * base: mirrors.aliyun.com
22  * extras: mirrors.aliyun.com
23  * updates: mirrors.aliyun.com
24 没有可用软件包 Nginx。
25 错误:无须任何处理

复制代码

   原因是Nginx位于第三方的yum源里面,而不在centos官方yum源里面

  

  很多软件包在yum里面没有的,解决的方法,就是使用epel源,也就是安装epel-release软件包。EPEL (Extra Packages for Enterprise Linux)是基于Fedora的一个项目,为“红帽系”的操作系统提供额外的软件包,适用于RHEL、CentOS等系统。可以在下面的网址上找到对应的系统版本,架构的软件包

  

  解决办法,安装epel

sudo yum install epel-release

  更新(更新时间稍微长一些,耐心等待)

yum update

  重新试一下:

yum install -y Nginx

  安装成功: 

复制代码

已安装:
  Nginx.x86_64 1:1.12.2-3.el7                                                             

作为依赖被安装:
  Nginx-all-modules.noarch 1:1.12.2-3.el7                                                 
  Nginx-filesystem.noarch 1:1.12.2-3.el7                                                  
  Nginx-mod-http-geoip.x86_64 1:1.12.2-3.el7                                              
  Nginx-mod-http-image-filter.x86_64 1:1.12.2-3.el7                                       
  Nginx-mod-http-perl.x86_64 1:1.12.2-3.el7                                               
  Nginx-mod-http-xslt-filter.x86_64 1:1.12.2-3.el7                                        
  Nginx-mod-mail.x86_64 1:1.12.2-3.el7                                                    
  Nginx-mod-stream.x86_64 1:1.12.2-3.el7                                                  

完毕!

复制代码

CentOS 7,使用yum安装Nginx

CentOS 7,使用yum安装Nginx

https://www.centos.bz/2018/01/centos-7%EF%BC%8C%E4%BD%BF%E7%94%A8yum%E5%AE%89%E8%A3%85nginx/
文章目录
[隐藏]
安装Nginx源
安装Nginx
Nginx默认目录
常用命令
当使用以下命令安装Nginx时,发现无法安装成功

yum install -y Nginx
需要做一点处理。

安装Nginx源
执行以下命令:

rpm -ivh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
安装该rpm后,我们就能在/etc/yum.repos.d/ 目录中看到一个名为Nginx.repo 的文件。

安装Nginx
安装完Nginx源后,就可以正式安装Nginx了。

yum install -y Nginx
Nginx默认目录
输入命令:

whereis Nginx
即可看到类似于如下的内容:

Nginx: /usr/sbin/Nginx /usr/lib64/Nginx /etc/Nginx /usr/share/Nginx
以下是Nginx的默认路径:

(1) Nginx配置路径:/etc/Nginx/

(2) PID目录:/var/run/Nginx.pid

(3) 错误日志:/var/log/Nginx/error.log

(4) 访问日志:/var/log/Nginx/access.log

(5) 默认站点目录:/usr/share/Nginx/html

事实上,只需知道Nginx配置路径,其他路径均可在/etc/Nginx/Nginx.conf 以及/etc/Nginx/conf.d/default.conf 中查询到。

常用命令

(1) 启动:

Nginx

(2) 测试Nginx配置是否正确:

Nginx -t

(3) 优雅重启:

Nginx -s reload

(4) 查看Nginx的进程号:

ps -ef |grep Nginx
(5)Nginx服务停止

Nginx -s stop
kill -9 pid
当然,Nginx也可以编译源码安装,步骤相对要繁琐一些,总的来说,还是比较简单的,本文不作赘述

今天关于CentOS6.5使用yum命令方便快捷安装Nginxyum 安装 nginx的介绍到此结束,谢谢您的阅读,有关CentOS 6.4使用yum安装nginx + php + mysql、CentOS 7 使用yum 安装nginx、Centos 7下安装nginx,使用yum install nginx,提示没有可用的软件包、CentOS 7,使用yum安装Nginx等更多相关知识的信息可以在本站进行查询。

本文标签: