lnmp服务一nginx部署

本文详细介绍了在CentOS 6.5系统上从源码编译安装Nginx的过程,并配置了基本的虚拟主机设置。包括系统版本确认、所需软件包下载、安装依赖库、编译安装步骤、配置文件调整、语法检查及启动Nginx等关键环节。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、安装准备

1.系统版本信息

[root@lnmp ~]# cat /etc/redhat-release
CentOS release 6.5 (Final)
[root@lnmp ~]# uname -a
Linux lnmp 2.6.32-431.el6.x86_64 #1 SMP Fri Nov 22 03:15:09 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

2.软件包下载

百度网盘连接下载安装包:点击

[root@lnmp ~]# ll *.gz
-rw-r–r--. 1 root root 4984397 Aug 4 03:16 libiconv-1.14.tar.gz
-rw-r–r--. 1 root root 186722932 Aug 5 22:10 mysql-5.5.32-linux2.6-x86_64.tar.gz
-rw-r–r--. 1 root root 804164 Aug 5 01:01 nginx-1.6.2.tar.gz
-rw-r–r--. 1 root root 15008639 Aug 4 00:29 php-5.3.27.tar.gz

3.安装nginx所需的依赖于函数库

[root@lnmp ~]# yum install openssl openssl-devel -y
[root@lnmp ~]# yum install pcre pcre-devel -y
[root@lnmp ~]# yum install gcc -y

二、编译安装nginx

1.解压安装包

[root@lnmp ~]# tar xf nginx-1.6.2.tar.gz
[root@lnmp ~]# cd nginx-1.6.2

2.创建nginx用户

[root@lnmp nginx-1.6.2]# useradd nginx -M -s /sbin/nologin

3.编译nginx

[root@lnmp nginx-1.6.2]# ./configure --user=nginx --group=nginx --prefix=/usr/local/nginx-1.6.2 --with-http_stub_status_module --with-http_ssl_module
[root@lnmp nginx-1.6.2]# make && make install

4.创建目录及软连接管理

[root@lnmp nginx-1.6.2]# mkdir /application
[root@lnmp nginx-1.6.2]# ln -s /usr/local/nginx-1.6.2/ /application/nginx

5.配置环境变量

[root@lnmp nginx-1.6.2]# cp /application/nginx/sbin/* /usr/local/sbin/

三、配置虚拟主机

1.修改配置文件

[root@lnmp nginx-1.6.2]# cd /application/nginx/conf/
[root@lnmp conf]# egrep -v “^$|#” nginx.conf.default > nginx.conf
[root@lnmp conf]# cat -n nginx.conf
1 worker_processes 1;
2 events {
3 worker_connections 1024;
4 }
5 http {
6 include mime.types;
7 default_type application/octet-stream;
8 sendfile on;
9 keepalive_timeout 65;
10 server {
11 listen 80;
12 server_name www.liang.com;
13 location / {
14 root html/www;
15 index index.html index.htm;
16 }
17 }
18 }
[root@lnmp conf]# mkdir …/html/www
[root@lnmp conf]# echo “https://blog.youkuaiyun.com/liang_operations/” > …/html/www/index.html

2.检查语法

[root@lnmp conf]# nginx -t
nginx: the configuration file /usr/local/nginx-1.6.2/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx-1.6.2/conf/nginx.conf test is successful

3.启动nginx

[root@lnmp conf]# nginx

4.关闭防火墙,se

[root@lnmp conf]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
[root@lnmp conf]# setenforce 0

5.物理机hosts解析

这里写图片描述

6.网页访问

这里写图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值