網站首頁 編程語言 正文
安裝網址
http://nginx.org/en/download.html
安裝依賴包
yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
下載Nginx并解壓安裝包
//下載tar包之前,前提安裝wget
yum install wget
//創建文件
mkdir -p/usr/local/nginx
//下載安裝包 安裝包可以根據自己的需求修改,上面提到的安裝網址,選擇合適的路徑添加
wget http://nginx.org/download/nginx-1.18.0.tar.gz
//解壓文件夾
tar -xvf nginx-1.18.0.tar.gz
安裝
//執行命令
./configure --prefix=/usr/local/nginx
//執行make命令
make
//執行make install命令
make install
查看安裝版本號
/cd sbin
./nginx -v
檢查配置文件正確性
./nginx -v
啟動Nginx服務
./nginx
停止Nginx服務
./nginx -s stop
啟動完成后查看Nginx進程
ps -ef | grep nginx
[root@localhost sbin]# ps -ef | grep nginx
root 7004 1 0 12:30 ? 00:00:00 nginx: master process ./nginx
nobody 7005 7004 0 12:30 ? 00:00:00 nginx: worker process
root 7014 1297 0 12:31 pts/0 00:00:00 grep --color=auto nginx
確認ip地址
[root@localhost html]# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 00:0c:29:8b:5d:72 brd ff:ff:ff:ff:ff:ff
inet 192.168.179.130/24 brd 192.168.179.255 scope global noprefixroute dynamic ens33
valid_lft 1439sec preferred_lft 1439sec
inet6 fe80::17be:75e1:b84:e7af/64 scope link noprefixroute
valid_lft forever preferred_lft forever
關閉防火墻
防火墻不關閉,無法顯示登錄的頁面,需要先關閉防火墻
systemctl stop firewalld
剛確認的ip地址輸入到游覽器
http://192.168.179.130/
[root@localhost html]# systemctl stop firewalld
[root@localhost html]# cat index.html
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a >nginx.org</a>.<br/>
Commercial support is available at
<a >nginx.com</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
nginx配置文件修改
vim /usr/local/nginx/conf/nginx.conf
修改后重啟
[root@localhost conf]# nginx -s reload
補充:
每次從nginx路徑下在啟動文件比較麻煩,直接在路徑下直接啟動。
方法如下:
nginx的配置路徑修改
[root@localhost /]# vim /etc/profile
[root@localhost /]# source /etc/profile
重新加載配置文件
[root@localhost /]#./nginx -s reload
原文鏈接:https://blog.csdn.net/weixin_45428910/article/details/127033407
相關推薦
- 2022-08-25 pycharm中keras導入報錯無法自動補全cannot?find?reference分析_pyt
- 2022-08-15 利用calc函數實現簡單的自適應
- 2022-09-04 Linux?sed工具的使用及工作原理_linux shell
- 2023-01-11 Selenium中的option使用示例_python
- 2022-10-25 pytorch模型轉onnx模型的方法詳解_python
- 2022-10-25 在PyCharm中使用FMEObjects的操作步驟_python
- 2022-02-15 多標簽界面:動態組件 & 異步組件
- 2022-07-25 Python文件操作和數據格式詳解(簡單簡潔)_python
- 最近更新
-
- window11 系統安裝 yarn
- 超詳細win安裝深度學習環境2025年最新版(
- Linux 中運行的top命令 怎么退出?
- MySQL 中decimal 的用法? 存儲小
- get 、set 、toString 方法的使
- @Resource和 @Autowired注解
- Java基礎操作-- 運算符,流程控制 Flo
- 1. Int 和Integer 的區別,Jav
- spring @retryable不生效的一種
- Spring Security之認證信息的處理
- Spring Security之認證過濾器
- Spring Security概述快速入門
- Spring Security之配置體系
- 【SpringBoot】SpringCache
- Spring Security之基于方法配置權
- redisson分布式鎖中waittime的設
- maven:解決release錯誤:Artif
- restTemplate使用總結
- Spring Security之安全異常處理
- MybatisPlus優雅實現加密?
- Spring ioc容器與Bean的生命周期。
- 【探索SpringCloud】服務發現-Nac
- Spring Security之基于HttpR
- Redis 底層數據結構-簡單動態字符串(SD
- arthas操作spring被代理目標對象命令
- Spring中的單例模式應用詳解
- 聊聊消息隊列,發送消息的4種方式
- bootspring第三方資源配置管理
- GIT同步修改后的遠程分支