In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
In this article, the editor introduces in detail "how to use Nginx to achieve port 80 forwarding port 8080 in Mac". The content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to use Nginx to achieve port 80 forwarding port 8080 in Mac" can help you solve your doubts.
Environment
Mac os version: 10.12.6
Nginx version: 1.12.1
Installation
The author installs the library using homebrew
Brew search nginxbrew install nginx
After this installation, you will find that the listening port of nginx is 8080, not 80, so you need to change the listening port of nginx, so this step is very critical. You cannot change it in the traditional way. Please take a closer look at the section.
Because mac os comes with apache service, it occupies port 80, first of all, you need to change the listening port of apache to something else or uninstall it directly. The author is to change its listening port to 8011.
Command Lin
Sudo vim / etc/apache2/httpd.conf
The red box in the picture opens the original port 80, but the author has changed it to 8011.
Apache_conf.png
Restart sudo / usr/sbin/apachectl restart after the change
At this point, you have released port 80.
The second thing you need to know is the plist file. Plist means property list format, the format that Apple uses to save application data, which is actually a xml. You can find the corresponding plist file for nginx under / usr/local/opt/nginx, such as homebrew.mxcl.nginx.plist on the author's computer.
Its contents are as follows:
Labelhomebrew.mxcl.nginxrunatloadkeepaliveprogramarguments/usr/local/opt/nginx/bin/nginx-gdaemon off;workingdirectory/usr/local
You need to copy this file to / library/launchdaemons, or ~ / library/launchagents, but there is a difference between the two.
The former starts when the system starts, and the latter starts when the user logs in. Then execute launchctl load-w, as follows:
Sudo cp / usr/local/opt/nginx/*.plist / library/launchdaemons
Sudo launchctl load-w / library/launchdaemons/homebrew.mxcl.nginx.plist
Finally, restart your machine, you will find that nginx is started on port 80, try to access directly through http://localhost, if the following picture appears, it means that your nginx port 80 has been configured, which means that you have completed 60% of the work.
If your tomcat port is 8080, you need to start it at this time. The reason why you start tomcat at this time is to let tomcat occupy port 8080 first, because when configuring nginx forwarding later, you need to configure port 8080 forwarding, in order not to be preempted by nginx at that time to occupy port 8080 (you can also not start tomcat here, as long as you do not start the nginx service immediately after configuring nginx forwarding configuration. Because starting it directly takes up port 8080 for forwarding, but you haven't used port 8080 yet) it leads to the failure of tomcat startup, so you can let tomcat occupy the port first and then map and forward nginx to port 8080.
At this point, your tomcat has been started, and we begin to configure the forwarding configuration of nginx:
Command Lin
Sudo vim / usr/local/etc/nginx/nginx.conf
You only need to care about the configuration in the server node.
Nginx_conf.png
Nodes under server:
Listen: listening on port 80
Server_name: which address to forward to?
Proxy_pass: which address is the agent to?
After several of these items have been configured, we will restart nginx (restart needs to be changed to the nginx directory) sudo / usr/local/cellar/nginx/1.12.1/bin/nginx-s reload
All the operations are done here, and now you and your other partners on the same network segment can access your tomcat project by directly accessing the ip address.
Related commands operate apache commands
Stop service: sudo / usr/sbin/apachectl stop
Enable the service: sudo / usr/sbin/apachectl start
Restart the service: sudo / usr/sbin/apachectl restart
Nginx command (need to be executed under the directory of nginx, directory: / usr/local/cellar/nginx/1.12.1/bin/)
Enable: sudo nginx
Restart: sudo nginx-s reload
Close
First, query the nginx main process number (the process with master identity): ps-ef | grep nginx
Stop the sudo kill-quit main process number normally
Quick stop sudo kill-term main process number
After reading this, the article "how to use Nginx to achieve port 80 forwarding port 8080 in Mac" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.