linux(6.8版本最小化安装)安装nginx实战

1.安装pcre:

查看是否安装过pcre:

[[email protected] ~]# rpm -qa pcrepcre-devel

pcre-7.8-6.el6.x86_64

若没有则执行安装命令:[[email protected] ~]# yum install pcre-devel -y

[[email protected] ~]# rpm -qa pcrepcre-devel

pcre-7.8-7.el6.x86_64

pcre-devel-7.8-7.el6.x86_64

2.安装安全软件包openssl:

[[email protected] ~]# yum installopenssl-devel -y

[[email protected] ~]# rpm -qa opensslopenssl-devel

openssl-devel-1.0.1e-48.el6_8.1.x86_64

openssl-1.0.1e-48.el6_8.1.x86_64

3.安装nginx:

[[email protected] ~]# mkdir -p/home/oldboy/tools

[[email protected] ~]# cd /home/oldboy/tools

[[email protected] tools]# wget -qhttp://nginx.org/download/nginx-1.6.3.tar.gz

[[email protected] tools]# ls nginx-1.6.3.tar.gz

nginx-1.6.3.tar.gz

[[email protected] tools]# ls nginx-1.6.3.tar.gz -lk

-rw-r--r-- 1 root root 787 4月   8 2015 nginx-1.6.3.tar.gz

解压并切换到nginx目录:

[[email protected] tools]# tar zxfnginx-1.6.3.tar.gz

[[email protected] tools]# cd nginx-1.6.3

查看总共文件个数:

[[email protected] nginx-1.6.3]# tree|wc-l

404

编译并安装(--prefix 编译目录)

[[email protected]]# ./configure --prefix=/application/nginx-1.6.3 --user=nginx--group=nginx --with-http_ssl_module --with-http_stub_status_module

[[email protected] nginx-1.6.3]#make&& make install

添加用户:

[[email protected] nginx-1.6.3]# useradd nginx -s /sbin/nologin -M

[[email protected] nginx-1.6.3]# id nginx

uid=502(nginx) gid=502(nginx) 组=502(nginx)

[[email protected] tools]# ll /application/nginx-1.6.3/ -ld

drwxr-xr-x 6 root root 4096 7月  17 19:15/application/nginx-1.6.3/

创建软连接:

[[email protected] tools]# ln -s/application/nginx-1.6.3/ /application/nginx

[[email protected] tools]# ls -l/application/

总用量 8

lrwxrwxrwx 1 root root   25 7月  17 19:20 nginx ->/application/nginx-1.6.3/

drwxr-xr-x 6 root root 4096 7月  17 19:15 nginx-1.6.3

启动nginx服务:

[[email protected] ~]# ps -ef|grep nginx|grep -v grep

root    10949     1  0 19:26 ?        00:00:00 nginx: master process/application/nginx/sbin/nginx

nginx   10950 10949  0 19:26 ?        00:00:00 nginx: worker process

[[email protected] ~]# ss -lntup|grep nginx

tcp   LISTEN     0      128                    *:80                    *:*     users:(("nginx",10949,6),("nginx",10950,6))

本地测试是否部署成功:

[[email protected] ~]# curl 127.0.0.1

<!DOCTYPE html>

<html>

<head>

<title>Welcome tonginx!</title>

<style>

body {

width: 35em;

margin: 0 auto;

font-family: Tahoma, Verdana, Arial, sans-serif;

}

</style>

</head>

<body>

<h1>Welcome to nginx!</h1>

<p>If you see this page, the nginxweb server is successfully installed and

working. Further configuration isrequired.</p>

<p>For online documentation andsupport please refer to

<ahref="http://nginx.org/">nginx.org</a>.<br/>

Commercial support is available at

<ahref="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for usingnginx.</em></p>

</body>

</html>

查看软件安装的编译参数:

[[email protected] ~]#/application/nginx/sbin/nginx -V

nginx version: nginx/1.6.3

built by gcc 4.4.7 20120313 (Red Hat4.4.7-11) (GCC)

TLS SNI support enabled

configure arguments:--prefix=/application/nginx-1.6.3 --user=nginx --group=nginx--with-http_ssl_module --with-http_stub_status_module

切换到安装目录并查看:

[[email protected] nginx]# ls -l|grep -vtemp

总用量 36

drwxr-xr-x 2 root  root 4096 7月  17 19:15 conf

drwxr-xr-x 2 root  root 4096 7月  17 19:15 html

drwxr-xr-x 2 root  root 4096 7月  17 19:26 logs

drwxr-xr-x 2 root  root 4096 7月  17 19:15 sbin

查看nginx核心配置文件:

[[email protected] html]# cd ..

[[email protected] nginx]# cd conf/

[[email protected] conf]# ls -lnginx.conf

-rw-r--r-- 1 root root 2656 7月  17 19:15 nginx.conf

最小化配置基于域名的nginx的配置文件:

[[email protected] conf]# egrep -v"#|^$" nginx.conf.default

worker_processes  1;

events {

worker_connections  1024;

}

http {

include       mime.types;

default_type application/octet-stream;

sendfile        on;

keepalive_timeout  65;

server {

listen       80;

server_name  localhost;

location / {

root   html;

index  index.html index.htm;

}

error_page   500 502 503 504  /50x.html;

location = /50x.html {

root   html;

}

}

}

[[email protected] conf]# egrep -v"#|^$" nginx.conf.default >nginx.conf

编辑nginx.conf文件:

[[email protected] conf]# vim nginx.conf

location = /50x.html {

error_page   500 502 503 504  /50x.html;

location = /50x.html {

root   html;

}

root   html/www   server {

listen       80;

server_name  www.hongya.org;

location / {

root   html/www;

index  index.html index.htm;

}

root   html/www;

erver {

listen       80;

server_name  www.hongya.org;

location / {

root   html/www;

index  index.html index.htm;

}

server {

listen       80;

server_name  www.hongya.org;

location / {

root   html/www;

index  index.html index.htm;

}

}

erver {

listen       80;

server_name  www.hongya.org;

location / {

root   html/www;

index  index.html index.htm;

}

worker_processes  1;

events {

worker_connections  1024;

}

http {

include       mime.types;

default_type application/octet-stream;

sendfile        on;

keepalive_timeout  65;

server {

listen       80;

server_name  www.hongya.org;

location / {

root   html/www;

index  index.html index.htm;

}

}

server {

listen       80;

server_name  bbs.hongya.org;

location / {

root   html/bbs;

index  index.html index.htm;

}

}

}

"nginx.conf" 32L, 566C 已写入

创建目录及html页面:

[[email protected] conf]# mkdir../html/{www,bbs}

[[email protected] conf]# ls -l ../html/

总用量 16

-rw-r--r-- 1 root root  537 7月  17 19:15 50x.html

drwxr-xr-x 2 root root 4096 7月  17 21:31 bbs

-rw-r--r-- 1 root root  628 7月  17 19:48 index.html

drwxr-xr-x 2 root root 4096 7月  17 21:31 www

[[email protected] conf]#

[[email protected] conf]# echo"www.hongya.org" >../html/www/index.html

[[email protected] conf]# echo"bbs.hongya.org" >../html/bbs/index.html

[[email protected] conf]# cat../html/{www,bbs}/index.html

www.hongya.org

bbs.hongya.org

检查配置是否有误:

[[email protected] conf]#/application/nginx/sbin/nginx -t

nginx: the configuration file/application/nginx-1.6.3/conf/nginx.conf syntax is ok

nginx: configuration file/application/nginx-1.6.3/conf/nginx.conf test is successful

重启nginx服务:

[[email protected] conf]#/application/nginx/sbin/nginx -s reload

配置host文件,测试:

[[email protected] conf]# vim /etc/hosts

127.0.0.1  localhost localhost.localdomain localhost4 localhost4.localdomain4

::1        localhost localhost.localdomain localhost6 localhost6.localdomain6

192.168.10.132 www.hongya.org

192.168.10.132 bbs.hongya.org

~

"/etc/hosts" 5L, 221C 已写入

基于端口的nginx配置:

时间: 2024-08-24 01:00:36

linux(6.8版本最小化安装)安装nginx实战的相关文章

最小化方式安装FreeBSD服务器图文教程

现在网上找到一个镜像 网址我就不提供了............... 1.在BIOS中设定以光盘启动,插入FreeBSD光盘,启动服务器,出现以下画面后直接回车确定(或等待自动默认启动):                      2.选择所在国家,如以下画面,用向上方向键选择China(中国),然后回车:                       3.选择键盘布局,我们一般用USA ISO键盘布局(即美国标准键盘布局),直接回车: 4.当出现下面的画面的时候,我们选择"标准的引导式安装&qu

【Linux】CentOS6.X最小化安装后配置

1.centos6.5最小化安装后启动网卡2.ifconfig查询IP进行SSH链接3.更新系统源并且升级系统4.系统时间更新和设定定时任5.修改ip地址.网关.主机名.DNS6.关闭selinux,清空iptables7.创建普通用户并进行sudo授权管理8.修改SSH端口号和屏蔽root账号远程登陆9.锁定关键文件系统(禁止非授权用户获得权限)10.精简开机自启动服务11.调整系统文件描述符大小12.设置系统字符集13.清理登陆的时候显示的系统及内核版本14.内核参数优化15.定时清理/va

CentOS 6.0最小化编译安装Nginx+MySQL+PHP+Zend

http://www.osyunwei.com/archives/235.html 引言: 操作系统:CentOS 6.0 32位         下载地址:http://mirrors.163.com/centos/6.0/isos/i386/CentOS-6.0-i386-bin-DVD.iso         安装方式:采用最小化安装,在安装系统的时候选择Minimal(CentOS 6.0默认就是Minimal安装模式,不含有任何可选安装包)         最小化安装完成之后,系统占用

mysql裁剪—最小化编译安装

软件环境 虚拟机: VMware® Workstation-11 Linux: Centos 7.2 MySQL Database: MySQL5.7.7rc (一)卸载原有MySQL或者Mariadb安装程序 1.CentOs7版本默认情况下安装了mariadb-libs,必须先卸载才可以继续安装MySql. a)  查找以前是否安装mariadb-libs # rpm -qa | grep -i mariadb-libs b)卸载已经安装的mariadb-libs # yum remove

【深入学习linux】CentOS 7 最小化安装后程序必须安装的组件

centos平台编译环境使用如下指令 安装make: yum -y install gcc automake autoconf libtool make 安装g++: yum install gcc gcc-c++ Nginx安装参考https://blog.csdn.net/jiangxiaobo666/article/details/90404020 原文地址:https://www.cnblogs.com/jiangxiaobo/p/11734294.html

Linux,Unix各种版本的操作系统在线安装软件命令

摘自:http://blog.csdn.net/zjg555543/article/details/8278266 linux和unix,各个版本的操作系统都有自己的软件安装方式,最方便的莫过于在线安装软件,本文就是收集了各个版本在线安装的命令. 1.Solaris 10: pkgutil -i 2.FreeBSD: 进入/usr/ports/devel/*/  执行make,make install  就会自动下载安装依赖文件. *是对应的软件包. 3.Ubuntu: apt-get 4.re

CentOS 6.5最小化编译安装mysql 5.5.35

1.关闭防火墙: [[email protected] ~]# service iptables stop iptables: Setting chains to policy ACCEPT: filter          [  OK  ] iptables: Flushing firewall rules:                         [  OK  ] iptables: Unloading modules:                               [

CentOS 6.5最小化编译安装mysql 5.5.35配置多实例

1.关闭防火墙 [[email protected] ~]# service iptables stop iptables: Setting chains to policy ACCEPT: filter          [  OK  ] iptables: Flushing firewall rules:                         [  OK  ] iptables: Unloading modules:                               [ 

Dockerfile基于最小化选择性安装服务的2种方法

方法1mkdir sscd ss/touch Dockerfile //名字必须是这个cp /etc/yum.repos.d/dvd.repo .vim 1.sh#!/bin/bashEnvironmentFile=/etc/sysconfig/sshd/usr/sbin/sshd -D &EnvironmentFile=/etc/sysconfig/httpd/usr/sbin/httpd -DFOREGROUNDchmod 755 1.shvim Dockerfile FROM centos