In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/01 Report--
This article introduces the knowledge of "detailed steps to install nginx under Ubuntu". Many people will encounter this dilemma in the operation of actual cases, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
1), download
Sudo wget http://nginx.org/download/nginx-1.2.2.tar.gz
2), decompression
Sudo tar-xzvf nginx-1.2.2.tar.gz
3) enter the relevant directory and do the following
The code is as follows:
. / configure
Make
Sudo make install
If you're lucky, everything ok, but. Ha ha. The default policy of Ubuntu is not to install any libraries, and all dependent libraries need to be installed manually. It usually goes wrong, so let's take a look at the problems that may arise.
4) Solutions to common problems
Missing pcre library
. / configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using-without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using-with-pcre= option.
Solution: download and install pcre-8.31 to solve the problem, decompress and perform the following operations on pcre
The code is as follows:
Sudo wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.31.tar.gz
Sudo tar-xzvf pcre-8.31.tar.gz
Cd / usr/local/src/pcre-8.31
. / configure
Make
Sudo make install
Good luck to pass once, bad luck, make pcre will make mistakes
Lack of gcc-c++ and libtool, that is, C++ compiler package
The code is as follows:
Libtool: compile: unrecognized option `- DHAVE_CONFIG_H'
Libtool: compile: Try `libtool-- help' for more information.
Make [1]: * * [pcrecpp.lo] Error 1
Make [1]: Leaving directory `/ usr/local/src//pcre-8.31'
Make: * * [all] Error 2root@wolfdog-virtual-machine:~/work/pcre-8.12$ libtool-help-DHAVE_CONFIG_H
The program 'libtool' is currently not installed. You can install it by typing:
Sudo apt-get install libtool
Solution: libtool and gcc-c++ need to be installed first
? sudo apt-get install libtool
Sudo apt-get install gcc-c++
Uncle ~ ~ at this time may be wrong ah, cheating ah ~ ~
Missing openssl library
The code is as follows:
. / configure: error: the HTTP cache module requires md5 functions
From OpenSSL library. You can either disable the module by using
-- without-http-cache option, or install the OpenSSL library into the system
Or build the OpenSSL library statically from the source with nginx by using
-with-http_ssl_module-with-openssl= options.
Missing zlib library
The code is as follows:
. / configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using-without-http_gzip_module
Option, or install the zlib library into the system, or build the zlib library
Statically from the source with nginx by using-- with-zlib= option.
Solution: install what is missing.
Sudo apt-get install openssl libssl-dev libperl-dev
4) after solving the above problems, there will be no problem with compiling nginx. Install below. (attach the method of installing the plug-in)
Download the plug-in and extract it first
The code is as follows:
Sudo wget https://github.com/agentzh/echo-nginx-module/tarball/v0.40rc1-O echo-nginx-module.tar.gz
Sudo wget https://nodeload.github.com/agentzh/memc-nginx-module/tarball/v0.13rc3-O memc-nginx-module.tar.gz
Sudo tar-xzvf echo-nginx-module.tar.gz
Sudo tar-xzvf memc-nginx-module.tar.gz
Enter the nginx directory cd nginx-1.2.2/, and execute the following command
The code is as follows:
. / configure-- user=www-data-- group=www-data-- with-debug-- with-http_gzip_static_module-- with-http_ssl_module-- with-pcre=../pcre-8.31/-- with-http_perl_module-- with-perl=/usr/bin/perl-- with-http_stub_status_module-- with-http_realip_module\
-- prefix=/usr/local/nginx\
-- add-module=../agentzh-echo-nginx-module-9259898/\
-- add-module=../agentzh-memc-nginx-module-4007350/\
Note: the first paragraph contains some compilation parameters, followed by add-module, which adds modules.
Make-J2
Make install
Damn it, it may be wrong again. No nginx,logs directory access
The code is as follows:
[alert]: could not open error log file: open () "/ usr/local/nginx/logs/error.log" failed (13: Permission denied)
06:09:33 on 2011-03-21 [emerg] 24855: mkdir () "/ usr/local/nginx/client_body_temp" failed (13: Permission denied)
Solution:
The code is as follows:
Sudo chmod a+rwx-R logs
Sudo chmod a+rwx-R / usr/local/nginx
Now, it's almost all right.
You can go to / usr/local/nginx/sbin/ and execute the following command to see if it is successful:
Nginx-v
5), nginx self-startup
Edit the startup script:
The code is as follows:
Sudo vim / etc/init.d/nginx
The code is as follows:
#! / bin/bash
#
# nginx Start up the nginx server daemon
#
# chkconfig: 2345 55 25
# Description: starts and stops the nginx web server
#
# BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Description: starts and stops the nginx web server
# END INIT INFO
# To install:
# copy this file to / etc/init.d/nginx
# shell > chkconfig-- add nginx (RedHat)
# shell > update-rc.d-f nginx defaults (debian)
# To uninstall:
# shell > chkconfig-- del nginx (RedHat)
# shell > update-rc.d-f nginx remove
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/$NAME.conf
PIDFILE=/var/local/nginx/logs/$NAME.pid
ULIMIT=10240
Set-e
[- x "$DAEMON"] | | exit 0
Do_start () {
Echo "Starting $NAME..."
Ulimit-SHn $ULIMIT
$DAEMON-c $CONFIGFILE
}
Do_stop () {
Echo "Shutting down $NAME..."
Kill 'cat $PIDFILE'
}
Do_reload () {
Echo "Reloading $NAME..."
Kill-HUP 'cat $PIDFILE'
}
Case "$1" in
Start)
[!-f "$PIDFILE"] & & do_start | | echo "nginx already running"
Echo-e ".\ ndone"
Stop)
[- f "$PIDFILE"] & & do_stop | | echo "nginx not running"
Echo-e ".\ ndone"
Restart)
[- f "$PIDFILE"] & & do_stop | | echo "nginx not running"
Do_start
Echo-e ".\ ndone"
Reload)
[- f "$PIDFILE"] & & do_reload | | echo "nginx not running"
Echo-e ".\ ndone"
*)
N=/etc/init.d/$NAME
Echo "Usage: $N {start | stop | restart | reload}" > & 2
Exit 1
Esac
Exit 0
The red part is modified according to your own path.
6), common commands
Restart nginx:service nginx restart
Launch: service nginx start
Turn off: service nginx stop
7), linux common commands
Tar (z-compress or decompress the archive with gzip; x-expand files from the archive; v-detailed display of processed files; f-specify archives or devices)
Tar-zxvf nginx-0.8.54.tar.gz
Ip View
Ifconfig
Compile
Make
Install the compiled source package
Make install
Edit a file
Sudo gedit / etc/profile
Modify root limit: chmod description (u: have the same permissions as the file owner [a: owner]; +: increase permissions; rwx: readable, writable and executable)
-R: recursively all directories and files
Sudo chmod a+rwx-R logs
Check whether the library is installed successfully
Dpkg-- list | grep openssl
Download the installation library
Sudo apt-get install libtool
Check whether the service starts properly
Ps-ef | grep
Find the openssl installation path
Whereis openssl
Update sourc
Sudo apt-get update
Update installed packages
Sudo apt-get upgrade
This is the end of the "detailed steps for installing nginx under Ubuntu". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!
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.