linux 服务器部署 lnamp 一nginx安装

来源:互联网 发布:iphone7没有4g网络 编辑:程序博客网 时间:2024/06/05 19:12

nginx安装

一、yum安装

使用yum安装:http://nginx.org/en/linux_packages.html To set up the yum repository for RHEL/CentOS, create the file named/etc/yum.repos.d/nginx.repo with the following contents: [nginx] name=nginx repo baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/ gpgcheck=0 enabled=1 Replace “OS” with “rhel” or “centos”, depending on the distribution used, and “OSRELEASE” with “6” or “7”, for 6.x or 7.x versions, respectively. yum install –y nginx

二、编译安装

1.下载nginx   wget http://nginx.org/download/nginx-1.12.1.tar.gz

解压  tar xzvf nginx-1.12.1.tar.gz

2.下载   wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz

解压   tar xvzf pcre-8.40.tar.gz

3.执行configure,配置编译文件   ./configure --prefix=/lnamp/nginx --with-pcre=/opt/src/pcre-8.40 --user=nginx --group=nginx

make

报错缺少zlib压缩库  yum install zlib zlib-devel

报错c++编译   yum install gcc-c++

make成功后执行 make install

4.我编译时制定的用户是nginx,用户组是nginx,所以

先添加用户组

groupadd nginx

再添加用户

useradd -g nginx nginx

-g是指定用户组是nginx,

5.运行

a.验证配置文件是否正确./nginx/sbin/nginx -t,正确后会打印

nginx: the configuration file /lnamp/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /lnamp/nginx/conf/nginx.conf test is successful

或者再启动命令时加上./nginx/sbin/nginx -t -c "配置文件路径"

b.重启服务

./nginx/sbin/nginx -s reload


//查找nginx当前进程

ps -ef|grep nginx

原创粉丝点击