Install the high performance Nginx web server on Ubuntu

Look out Apache, there’s a web server – Nginx (pronounced Engine X) – that means to dismantle you as the defacto standard web server. The Nginx project started development in 2002, but it’s just now really showing its strength and starting to gain a serious following. Nginx is a free, open-source, high-performance HTTP server and reverse proxy, as well as an IMAP/POP3 proxy server, and it’s known for high performance, stability, a vast feature set, easy configuration, and very low resource consumption.

Since Nginx is new to many users, I thought I should begin a series of articles to get everyone up to speed on using this fantastic web server. Throughout this series, I’ll be using the Ubuntu platform. You can use this series as the basis for other platforms – just pay close attention to the variances of installation technology and (in some cases) directory structure. With that said, let’s install Nginx on the Ubuntu platform.

Note: As this series won’t bother with basic platform setup and security, I’ll assume that you already have the server up and running and secure to your liking. I’ll also assume that you have MySQL up and running (along with PHP support).

Requirements

Nginx has few dependencies that Ubuntu doesn’t already take care of. Here’s what you’ll need:

  • The Gzip modules requires the zlib library
  • The rewrite module requires the pcre library
  • SSL support requires the openssl library

With the Ubuntu platform, the only library from the list above that you’ll need to install is the pcre library. To install this, follow these steps:

1.Open a terminal window
2.Issue the command:

sudo apt-get install libpcre3-dev

3.Type your sudo password and hit Enter
4.Accept the installation
5.Allow the installation to complete

Nginx can use PHP5 with the help of PHP-FPM (an alternative PHP FastCGI implementation with additional features, which is useful to busier sites). Here’s how to install PHP-FPM:

1.Open a terminal window
2.Issue the command:

sudo apt-get install php5-fpm

3.Type your sudo password (if prompted) and hit Enter
4.Accept the installation
5.Allow the installation to complete

Installing Nginx

As you might expect, the installation of Nginx is quite simple. Just follow these steps:
1.Open a terminal window
2.Issue the command:

sudo apt-get install nginx

3.Type your sudo password (if prompted) and hit Enter
4.Accept the installation
5.Allow the installation to complete
That’s it. The new web server is installed. Now, let’s peek around a bit.

Starting and stopping the server

To start the Nginx server, issue the following command:

sudo service nginx start

Top stop the Nginx server, issue the following command:

sudo service nginx stop

With the Nginx service started, fire up your browser and point it to the IP address (or domain) of the hosting server. If you see the “Welcome to Nginx” page, everything is good to go.

Before you close that terminal window, it’s necessary to set the Nginx service to start at boot. Just issue the following command:

update-rc.d nginx defaults

If you see:

System start/stop links for /etc/init.d/nginx already exist
That means Nginx is already set to start at boot time. You can now rest assured that you won’t have to manually start your web server upon reboot.

Configuration files/folders

  • The main configuration file for Nginx is /etc/nginx/nginx.conf
  • Virtual hosts are defined in /etc/nginx/sites-available/default
  • PHP will be configured in /etc/php5/fpm/php.ini

That should do it for Nginx installation on the Ubuntu platform. In upcoming posts, we’ll start working through various configurations and optimizations to round out the series. Enjoy your new web server!

reference:http://www.techrepublic.com/blog/linux-and-open-source/install-the-high-performance-nginx-web-server-on-ubuntu/

转载于:https://www.cnblogs.com/lanzhi/p/6468760.html

Ubuntu Server 22.04上安装web服务器,可以选择安装Nginx作为高性能的HTTP和反向代理服务器。首先,你需要使用以下命令安装Nginx: ``` sudo apt update sudo apt install nginx ``` 安装完成后,你可以使用以下命令来检查Nginx服务的状态: ``` sudo systemctl status nginx ``` 如果服务正在运行,你将看到类似于以下内容的输出: ``` ● nginx.service - A high performance web server and a reverse proxy server Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2020-05-02 20:25:43 UTC; 13s ago ... ``` 这表示Nginx已成功安装并正在运行。你可以通过在Web浏览器中输入服务器的IP地址来访问Nginx默认的欢迎页面,例如:http://服务器IP地址。 希望这可以帮助你在Ubuntu Server 22.04上安装web服务器。如果你还有其他问题,请随时提问。 #### 引用[.reference_title] - *1* *3* [服务器Ubuntu 22.04 64位 安装Nginx](https://blog.csdn.net/weixin_45500785/article/details/129403525)[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^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [Ubuntu 22.04LTS静态IP配置及源更新](https://blog.csdn.net/qq_44281591/article/details/127195233)[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^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值