Home > Operation and Maintenance > Nginx > How to install Nginx server on Ubuntu

How to install Nginx server on Ubuntu

WBOY
Release: 2023-05-16 09:25:05
forward
1209 people have browsed it

Install nginx

sudo apt-get install nginx
Copy after login

If you have installed apache and apache is running at this time, please modify the configuration file first (students who do not have it will skip it directly):

#打开配置文件 
sudo vim /etc/nginx/sites-available/default
Copy after login

Then make the following two modifications (in order not to conflict with apache):

server { 
  #修改这里 我将 80 改为 88 
 listen 88 default_server; 
  #还有这里 同样改为你想要的监听端口 
 listen [::]:88 default_server ipv6only=on; 
  .....
Copy after login


At this point, we test whether nginx is successfully installed. If you have not made the above modifications, enter localhost directly in the browser. If you have changed it, remember to add the port. Mine is localhost:88. If the following interface appears, the installation is successful:

How to install Nginx server on Ubuntu


nginx startup and shutdown

Start nginx:

# nginx -c /etc/nginx/nginx.conf 
关闭 nginx

# nginx -s stop
重读配置文件

# nginx -s reload
# pkill -hup nginx
重新打开日志文件

# nginx -s reopen
# pkill -usr1 nginx
还可以下载 nginx rpm 包中的 /etc/init.d/nginx 文件,修改路径后即可使用:

# service nginx {start|stop|status|restart|reload|configtest|}
Copy after login

The above is the detailed content of How to install Nginx server on Ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template