微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

linux服务基础之编译安装nginx

Nginx源码下载地址:

http://Nginx.org/download/Nginx-1.16.0.tar.gz

1. 下载Nginx

# wget http://Nginx.org/download/Nginx-1.16.0.tar.gz

2. 安装Nginx

解决依赖关系:

# yum install pcre-devel
<style></style>

添加运行Nginx用户和组:

# groupadd -r Nginx
# useradd -r -g Nginx Nginx

编译安装Nginx:

# tar xf Nginx-1.16.0.tar.gz 
# cd Nginx-1.16.0
# ./configure --prefix=/usr/local/Nginx --conf-path=/etc/Nginx/Nginx.conf --user=Nginx --group=Nginx --error-log-path=/var/log/Nginx/error.log --http-log-path=/var/log/Nginx/access.log --pid-path=/var/run/Nginx/Nginx.pid --lock-path=/var/lock/Nginx.lock --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_flv_module --with-http_mp4_module --http-client-body-temp-path=/var/tmp/Nginx/client --http-proxy-temp-path=/var/tmp/Nginx/proxy --http-fastcgi-temp-path=/var/tmp/Nginx/fastcgi --http-uwsgi-temp-path=/var/tmp/Nginx/uwsgi

 创建Nginx编译安装时需要的目录:

# mkdir -pv /var/tmp/Nginx/{client,proxy,fastcgi,uwsgi}
<style></style>

测试:

# /usr/local/Nginx/sbin/Nginx  //运行Nginx
# ss -tnlp  //查看80端口是否被监听
# ps aux | grep Nginx
root      37932  0.0  0.1  46896  1108 ?        Ss   18:49   0:00 Nginx: master process /usr/local/Nginx/sbin/Nginx
Nginx     37933  0.0  0.1  47336  1704 ?        S    18:49   0:00 Nginx: worker process 
# elinks http://192.168.1.103  //可以看到Nginx的欢迎页面

 

<style></style> <style></style> <style></style>

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐