Linux - Nginx安装
2023-09-27 14:24:30 时间
1.复制解压。
[root@localhost ~]# mv /opt/nginx-1.13.8.tar.gz /usr/local/src
[root@localhost ~]# cd /usr/local/src
[root@localhost src]# tar -zxvf nginx-1.13.8.tar.gz
2.编译安装
[root@localhost src]# cd nginx-1.13.8
[root@localhost nginx-1.13.8]# ./configure --prefix=/usr/local/nginx
如果没有安装pcre、pcre-devel、openssl、zlib都安装一下。
提示
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using system zlib library
[root@localhost nginx-1.13.8]# ./configure --prefix=/usr/local/nginx --with-openssl=/usr/local/openssl
调整,增加openssl位置绑定。
3.安装
make && make install
4.检测是否安装成功
ps -ef |grep nginx
ps 查看进程。
-e 显示所有进程。
-f 全格式。
[root@localhost sbin]# ./nginx
[root@localhost sbin]# ps -ef |grep nginx
root 9334 1 0 18:38 ? 00:00:00 nginx: master process ./nginx
nobody 9335 9334 0 18:38 ? 00:00:00 nginx: worker process
root 9341 4092 0 18:38 pts/1 00:00:00 grep nginx
5.配置环境变量
[root@localhost sbin]# vim /etc/profile
PATH=$PATH:/usr/local/nginx/sbin
export PATH
[root@localhost sbin]# source /etc/profile
这个时候就可以在任何地方操作nginx了。
[root@localhost local]# nginx -s stop
[root@localhost local]# ps -ef |grep nginx
root 9370 4092 0 18:46 pts/1 00:00:00 grep nginx
6.nginx关闭
[root@localhost local]# nginx -s stop
其他的方式
kill -quit 主进程号
kill -term 主进程号
pkill -9 nginx
7.配置service脚本
[root@localhost nginx]# vim nginx
#! /bin/bash
# chkconfig: - 85 15
# description: nginx is a World Wide Web server. It is used to serve
case "$1" in
start)
/usr/local/nginx/sbin/nginx
;;
stop)
/usr/bin/killall -s QUIT nginx
;;
restart)
$0 stop
$0 start
;;
reload)
/usr/bin/killall -s HUP nginx
;;
*)
echo "Usage:$0 {start|stop|restart|reload}"
exit 1
esac
exit 0
[root@localhost nginx]# cp /usr/local/nginx/nginx /etc/init.d
[root@localhost nginx]# chmod a+x /etc/init.d/nginx
[root@localhost nginx]# chkconfig --add nginx
[root@localhost nginx]# chkconfig --level 2345 nginx on
[root@localhost nginx]# service nginx stop
[root@localhost nginx]# ps -ef |grep nginx
root 9532 4092 0 19:23 pts/1 00:00:00 grep nginx
相关文章
- centos linux安装telnet 过程及问题(源于内部tomcat网站,外部无法访问)
- linux同一台机器安装两台nginx
- linux REDHAT6.4下安装ArcGIS Server 10.1
- Linux 下安装Python报错:zlib not available
- Linux 下 Nginx + JDK + Tomcat + MySQL 安装指南
- linux下Nginx+tomcat整合的安装与配置
- 使用socket BPF/Linux内核工程导论——网络:Filter(LSF、BPF、eBPF)
- Oracle 9i 9.2.0.4 linux i386 安装:闲来尝试:各种问题、及解决
- CentOS7 linux下yum安装redis以及使用
- 图解linux安装tomcat(附常用命令)
- Linux(centos7)安装nginx并配置代理
- Redis介绍以及安装(Linux与windows)
- Linux网络编程wait()和waitpid()的讲解
- linux云服务器如何安装nginx?
- Linux安装nginx并设置https(openssl
- zabbix_agentd客户端安装与配置(Linux操作系统)
- Linux下安装maven-及常用命令
- 【NodeJs】Linux安装NodeJs并配合Nginx实现反向代理
- linux下svn服务器安装配置与启动