ubuntu 编译安装 nginx
时间: 2023-08-27 10:11:27 浏览: 114
安装nginx有两种方式,一种是使用apt安装,另一种是编译安装。
使用apt安装nginx的步骤如下:
1. 更新apt软件包列表和依赖关系:<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* *2* *3* [Ubuntu 编译安装Nginx](https://blog.csdn.net/weixin_52341477/article/details/126036695)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}} ] [.reference_item]
[ .reference_list ]
相关问题
Ubuntu编译安装Nginx
1. 下载Nginx源码包
在官网上下载最新的Nginx源码包,下载地址为:http://nginx.org/en/download.html
2. 安装编译工具
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install zlib1g-dev
sudo apt-get install libssl-dev
3. 解压源码包
tar -zxvf nginx-1.18.0.tar.gz
cd nginx-1.18.0
4. 编译
./configure
make
sudo make install
5. 配置Nginx
sudo mkdir /usr/local/nginx/conf/vhosts
sudo nano /usr/local/nginx/conf/nginx.conf
在http模块内添加以下内容
include vhosts/*.conf;
sudo nano /usr/local/nginx/conf/vhosts/default.conf
添加以下内容:
server {
listen 80;
server_name localhost;
root /usr/local/nginx/html;
index index.html index.htm;
}
6. 启动Nginx
sudo /usr/local/nginx/sbin/nginx
7. 测试Nginx
在浏览器中输入http://localhost,如果能看到Nginx的欢迎页面,则表示安装成功。
ubuntu编译安装nginx
以下是在Ubuntu系统上编译安装Nginx的步骤:
1. 安装依赖库:
```shell
sudo apt-get update
sudo apt-get install build-essential
sudo apt-get install libpcre3 libpcre3-dev
sudo apt-get install zlib1g zlib1g-dev
sudo apt-get install libssl-dev
```
2. 下载Nginx源码:
```shell
wget http://nginx.org/download/nginx-1.18.0.tar.gz
tar -zxvf nginx-1.18.0.tar.gz
cd nginx-1.18.0
```
3. 配置编译参数:
```shell
./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/local/nginx/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_gzip_static_module \
--with-http_stub_status_module
```
4. 编译和安装:
```shell
make
sudo make install
```
5. 启动Nginx:
```shell
sudo /usr/local/nginx/sbin/nginx
```
现在,您已经成功在Ubuntu系统上编译安装了Nginx。
阅读全文