CentOS   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了CentOS6.x 下 LNMP环境搭建(二、安装 Nginx)大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

CentOS6.x 下 LNMP环境搭建(准备篇) CentOS6.x 下 LNMP环境搭建(一、安装 MySQL) CentOS6.x 下 LNMP环境搭建(二、安装 Nginx) CentOS6.x 下 LNMP环境搭建(三、安装 PHP) 2.1. 安装依赖包 # rpm -qa pcre* openssl* zlib*    <------- 检查所依赖的包是否已经安装 zlib-1.2.

2.1. 安装依赖包

# rpm -qa pcre* openssl* zlib*  <------- 检查所依赖的包是否已经安装
zlib-1.2.3-29.el6.x86_64
openssl-1.0.1e-48.el6_8.1.x86_64
pcre-7.8-7.el6.x86_64
# yum -y install pcre-devel openssl-devel zlib-devel

2.2. 添加用户

# useradd www -s /sbin/nologin -M

2.3. 安装

# cd /root/src
# tar -zxvf Nginx-1.6.3.tar.gz && cd Nginx-1.6.3
# ./configure \
--prefix=/lnmp/server/Nginx-1.6.3 \
--error-log-path=/lnmp/log/Nginx/error.log \
--http-log-path=/lnmp/log/Nginx/access.log \
--user=www \
--group=www \
--with-http_realip_module \
--with-http_sub_module \
--with-http_ssl_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre
# make
# make install
# cd /lnmp/server
# ln -s /lnmp/server/Nginx-1.6.3/ Nginx
# ls -l

2.4. 启动

# /lnmp/server/Nginx/sbin/Nginx -t   <------- 检查配置文件语法
Nginx: the configuration file /lnmp/server/Nginx-1.6.3//conf/Nginx.conf Syntax is ok
Nginx: configuration file /lnmp/server/Nginx-1.6.3//conf/Nginx.conf test is successful
# /lnmp/server/Nginx/sbin/Nginx  <------- 启动
检查:
# lsof -i :80
COMMAND  PID USER  FD  TYPE DEVICE SIZE/OFF NODE NAME
Nginx  38366 root  6u IPv4 93417   0t0 TCP *:http (LISTEN)
Nginx  38367 Nginx  6u IPv4 93417   0t0 TCP *:http (LISTEN)
# netstat -tlunp|grep 80
tcp    0   0 0.0.0.0:80  0.0.0.0:*    LISTEN   38366/Nginx
# wget 127.0.0.1
# curl 127.0.0.1

2.5. 添加启动脚本,之后可以通过 service Nginx xxx 方式控制

# vim /etc/init.d/Nginx   <------- 文件内容见附件 Nginx.sh
# chmod 755 /etc/init.d/Nginx
# service Nginx
Usage: /etc/init.d/Nginx {start|stop|reload|restart|configtest}
# service Nginx configtest <------- 配置文件检查
Nginx: the configuration file /lnmp/server/Nginx/conf/Nginx.conf Syntax is ok
Nginx: configuration file /lnmp/server/Nginx/conf/Nginx.conf test is successful
# service Nginx start <------- 启动
Starting Nginx:                      [ OK ]

2.6. 设置开机自启动

# chkconfig --add Nginx
# chkconfig Nginx on
# chkconfig --list|grep Nginx
Nginx     0:off  1:off  2:on  3:on  4:on  5:on  6:off

大佬总结

以上是大佬教程为你收集整理的CentOS6.x 下 LNMP环境搭建(二、安装 Nginx)全部内容,希望文章能够帮你解决CentOS6.x 下 LNMP环境搭建(二、安装 Nginx)所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: