In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)05/31 Report--
Most people do not understand the knowledge points of this article, "the method of installing Nginx server program and simple environment configuration on Ubuntu", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "Ubuntu installation of Nginx server programs and simple environment configuration method" article.
Ubuntu installs nginx from the official source
Cd ~ wget http://nginx.org/keys/nginx_signing.key sudo apt-key add nginx_signing.key sudo nano / etc/apt/sources.list # add the following two sentences: deb http://nginx.org/packages/ubuntu/ precise nginx deb-src http://nginx.org/packages/ubuntu/ precise nginx sudo apt-get update sudo apt-get install nginx
Ubuntu installs nginx from the ppa source:
Sudo add-apt-repository ppa:nginx/stable sudo apt-get update sudo apt-get install nginx
Ubuntu installs nginx from a regular source:
Sudo apt-get install nginx
Compile and install nginx
Wget http://nginx.org/packages/mainline/ubuntu/pool/nginx/n/nginx/nginx_1.5.7-1~precise_i386.deb wget http://nginx.org/download/nginx-1.5.7.tar.gztar xzf nginx-1.5.7.tar.gzcd nginx-1.5.7
(note: nginx1.5.7 is the mainline version, not the stable version)
Sudo mkdir / pngsudo chown eechen:eechen / png
I define the running user as png:png, so I need to create a new user like this:
Sudo addgroup png-systemsudo adduser png-system-disabled-login-ingroup png-no-create-home-home / nonexistent-gecos "png user"-shell / bin/false
(for commands of new users, please refer to the pre-installation script debian/preinst in the official deb package.)
The compilation parameters refer to the official deb package provided by nginx (nginx-v visible).
. / configure\-prefix=/png/nginx/1.5.7\-sbin-path=/png/nginx/1.5.7/sbin/nginx\-conf-path=/png/nginx/1.5.7/conf/nginx.conf\-error-log-path=/png/nginx/1.5.7/var/log/error.log\-http-log-path=/png/nginx/1.5.7/var/log/access.log\-pid-path=/png/ Nginx/1.5.7/var/run/nginx.pid\-lock-path=/png/nginx/1.5.7/var/run/nginx.lock\-http-client-body-temp-path=/png/nginx/1.5.7/var/cache/client_temp\-http-proxy-temp-path=/png/nginx/1.5.7/var/cache/proxy_temp\-http-fastcgi-temp-path=/png/nginx/1.5.7/var/ Cache/fastcgi_temp\-http-uwsgi-temp-path=/png/nginx/1.5.7/var/cache/uwsgi_temp\-- http-scgi-temp-path=/png/nginx/1.5.7/var/cache/scgi_temp\-- user=png\-- group=png\-- with-http_ssl_module\-- with-http_realip_module\-- with-http_addition_module\-- with-http_sub_module\-- with-http_dav_module\ -- with-http_flv_module\-- with-http_mp4_module\-- with-http_gunzip_module\-- with-http_gzip_static_module\-- with-http_random_index_module\-- with-http_secure_link_module\-- with-http_stub_status_module\-- with-mail\-- with-mail_ssl_module\-- with-file-aio\-- with-ipv6
Note: in this step, follow the error prompt to install the dependent packages, and it's time for apt to be angry, for example, these packages are installed on my system:
Sudo apt-get-y install\ build-essential\ autoconf\ libtool\ libxml2\ libxml2-dev\ openssl\ libcurl4-openssl-dev\ libbz2- 1.0\ libbz2-dev\ libjpeg-dev\ libpng12-dev\ libfreetype6\ libfreetype6-dev\ libldap-2.4-2\ libldap2-dev\ libmcrypt4\ libmcrypt-dev\ libmysqlclient-dev\ libxslt1.1\ libxslt1-dev\ libxt-dev\ libpcre3-dev
After installing these packages, there is no need to install the new version of nginx next time, and it basically meets the requirements of configure when compiling php.
All right, after the success of configure, you can compile and install:
Time make & & make install
Time is mainly used to view the time-consuming compilation.
After compiling, you can take a look at the size of this guy:
Du-sh / png/nginx/1.5.7/sbin/nginx5.5m / png/nginx/1.5.7/sbin/nginx
Summary of simple configuration of environment
Reduce the file size after nginx compilation:
Edit the source file nginx-1.5.7/auto/cc/gcc to remove the debug information (comment out):
# debug # cflags= "$cflags-g"
In this way, the size of the compiled main program is more than 700k, which is similar to the size of the deb package provided by nginx.
In addition, if some unwanted modules are removed in configure, the compiled executable file will be smaller.
Of course, I need a service script to manage nginx, and I can also use the service script etc/init.d/nginx provided in the official deb package.
I put it in / png/nginx/1.5.7/nginx and slightly modified the values defined at the beginning (lines 13 to 19):
Change path=/sbin:/usr/sbin:/bin:/usr/bindesc=nginxname=nginxconffile=/etc/nginx/nginx.confdaemon=/usr/sbin/nginxpidfile=/var/run/$name.pidscriptname=/etc/init.d/$name to path=/sbin:/usr/sbin:/bin:/usr/bindesc=nginxname=nginxconffile=/png/nginx/1.5.7/conf/nginx.confdaemon=/png/nginx/1.5.7/sbin/nginxpidfile=/png/nginx/1.5.7/var/run/$name.pidscriptname=/png/nginx/1.5.7/$name
Create a cache directory before starting, otherwise an error will be prompted:
Mkdir / png/nginx/1.5.7/var/cache
Start nginx:
Sudo / png/nginx/1.5.7/nginx start
Test page:
Curl-I `hostname`
Look at the port:
Sudo netstat-antp | grep nginx
Take a look at the memory it takes:
Htop filter nginx by f4
You can also see similar content with top:
Top-b-N1 | head-N7 & & top-b-N1 | grep nginx
Mainly look at the value of res, resident memory (resident), excluding the physical memory of swap space, the unit of kb,%mem is to take res as the reference object.
You can see that the total physical memory occupied by the two processes of nginx is less than 2 m, which is very small.
In addition, the res value in top corresponds to the rss value in ps aux:
Ps aux | head-N1 & & ps aux | grep nginx
Also, we can see that the worker process in nginx has only one thread:
Cat / proc/25047/status | grep threadsthreads: 1
25047 of them is the nginx worker process pid.
Turn nginx into a system service and boot automatically:
Sudo ln-s / png/nginx/1.5.7/nginx / etc/init.d/png-nginxsudo update-rc.d png-nginx defaults # Boot self-boot sudo update-rc.d-f png-nginx remove # do not want to boot self-boot can disable sudo service png-nginx reload # so that service can be used to manage nginx services, such as reloading configuration
Finally, nginx's main configuration file is located in / png/nginx/1.5.7/conf/nginx.conf, which is configured on demand.
The above is about the content of this article on "how to install Nginx server programs on Ubuntu and how to configure a simple environment". I believe everyone has a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please 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.