My mac system is too low! My Xcode software version is too low!
My homebrew does not support downloading Nginx (because homebrew requires me to upgrade the computer system and Xcode software version, but I don’t want it, I just don’t)!
I am not satisfied with the Nginx version downloaded by home brew! I want to use the version of Nginx I want!
Do it myself, I have enough food and clothing. I am my own God, my own life, I save myself. Of course, thank my parents, and my grandparents.
Now, I'm not talking nonsense. Dreaming about mountains:
the Nginx\Zlib\Pcre/Openssl that you need and match your computer system.
(I do not recommend downloading the latest one, whether it is for
learning, developing or testing)
Open the terminal and enter the /usr/local directory
, just use that
command:
cd /usr/local/
(I do recommend the Legacy versions)
home website: http://nginx.org/en/download.html
Nginx Legacy versions from 1.6.3 to 1.16.1,
(I recommend, I am using,less than 3 seconds):
sudo curl -O http://nginx.org/download/nginx-1.12.2.tar.gz
sudo curl -O http://nginx.org/download/nginx-1.18.0.tar.gz
Have you found the pattern? For example, if you want to download
nginx-x.yz.s
, just use the following command (recommended to download
the historical stable version):
sudo curl -O http://nginx.org/download/nginx-x.yz.s.tar.gz
It is mentioned in the Nginx reference document that zlib version 1.1.3 or higher is required.
(This selects the latest version 1.2.11 on the homepage of the official website.)
home website: https://zlib.net/
just use this command to download zlib-1.2.11(2 seconds):
sudo curl -O https://zlib.net/zlib-1.2.11.tar.gz
That version are frm 4.4 to 10.39.At first, I downloaded a 10.x version on the old computer, and the compilation failed.
Maybe the 8.x and 10.x interfaces are not compatible, and nginx depends on 8.x.
(It is mentioned in the Nginx reference document that pcre version 4.4 or higher is required)
home website: http://www.pcre.org/
version 8.x download website: https://sourceforge.net/projects/pcre/files/pcre/
sudo curl -O https://sourceforge.net/projects/pcre/files/pcre/8.44/pcre-8.44.tar.gz
sudo curl -O https://sourceforge.net/projects/pcre/files/pcre/8.41/pcre-8.41.tar.gz
But I recommend.
(Go to the latest stable version 1.1.0 on the download page of the official website)
home website: https://www.openssl.org/source/
sudo curl -O https://www.openssl.org/source/openssl-1.1.1h.tar.gz
sudo curl -O https://www.openssl.org/source/openssl-1.1.0.tar.gz
others:Openssl-1.1.1l
did not work.
because there will have two same files during "make install"
if i install
Nginx on the below directory /usr/local/nginx-1.12.2/
.
sudo mkdir -p /usr/local/nginx-install
and ensure that the current user has read and write permissions to the above directory using this command:
sudo chown marryme /usr/local/nginx-install
(The above "marryme" is for the user on my computer, you need to modify it according to your current user name)
/usr/local/nginx-install
using this command:
sudo mv /usr/local/nginx-1.12.2.tar.gz /usr/local/nginx-install/nginx-1.12.2.tar.gz
sudo mv /usr/local/zlib-1.2.11.tar.gz /usr/local/nginx-install/zlib-1.2.11.tar.gz
sudo mv /usr/local/pcre-8.41.tar.gz /usr/local/nginx-install/pcre-8.41.tar.gz
sudo mv /usr/local/openssl-1.1.1h.tar.gz /usr/local/nginx-install/openssl-1.1.1h.tar.gz
/usr/local/nginx-install
using this command:
sudo tar -zxvf nginx-1.12.2.tar.gz
sudo tar -zxvf zlib-1.2.11.tar.gz
sudo tar -zxvf pcre-8.41.tar.gz
sudo tar -zxvf openssl-1.1.1h.tar.gz
if using "pwd && ls -1
" on the directory /usr/local/nginx-install
,you will
get:
/usr/local/nginx-install
nginx-1.12.2
nginx-1.12.2.tar.gz
openssl-1.1.1h
openssl-1.1.1h.tar.gz
pcre-8.41
pcre-8.41.tar.gz
zlib-1.2.11
zlib-1.2.11.tar.gz
cd nginx-1.12.2
./configure --prefix=/usr/local/nginx-1.12.2 \
--with-http_ssl_module \
--with-pcre=../pcre-8.41 \
--with-zlib=../zlib-1.2.11 \
--with-openssl=../openssl-1.1.1h
./configure --prefix=/usr/local/nginx-1.12.2 \
--with-http_ssl_module \
--with-pcre=../pcre-8.41 \
--with-openssl=../openssl-1.1.1h
eg: store nginx.conf
in /usr/local/etc/nginx-conf/nginx.conf
,
store the error-log
in /usr/local/var/log/nginx-logs/error.log
,
store the http-log
in /usr/local/var/log/nginx-logs/access.log
,
store the pid
of Nginx in /usr/local/nginx-1.12.2/nginx-pid/nginx.pid
,
store the lock
of Nginx in /data/db/nginx-lock/nginx.lock
,
you could use this command to configure Nginx:
./configure --prefix=/usr/local/nginx-1.12.2 \
--conf-path=/usr/local/etc/nginx-conf/nginx.conf \
--error-log-path=/usr/local/var/log/nginx-logs/error.log \
--http-log-path=/usr/local/var/log/nginx-logs/access.log \
--pid-path=/usr/local/nginx-1.12.2/nginx-pid/nginx.pid \
--lock-path=/data/db/nginx-lock/nginx.lock \
--with-http_ssl_module \
--with-pcre=../pcre-8.41 \
--with-zlib=../zlib-1.2.11 \
--with-openssl=../openssl-1.1.1h
reference:
--prefix=PATH
: Specify the installation directory of nginx. Default
/usr/local/nginx;
--conf-path=PATH
: Set the path of the nginx.conf configuration file. Nginx
allows to use different configuration files to start, through the -c option
in the command line. The default is prefix/conf/nginx.conf;
--with-pcre
: Set the source path of the PCRE library. If it has been
installed via yum, use --with-pcre to automatically find the library file.
When using --with-pcre=PATH, you need to download the source code of the
pcre library (version 4.4-8.30) from the PCRE website and unzip it, and
leave the rest to Nginx's ./configure and make to complete. Perl regular
expressions are used in the location directive and the
ngx_http_rewrite_module module.
--with-zlib=PATH
: Specify the source decompression directory of zlib
(version 1.1.3-1.2.5). The network transmission compression module
ngx_http_gzip_module, which is enabled by default, requires zlib.
--with-http_ssl_module
: Use https protocol module. By default, this module
is not built. The premise is that openssl and openssl-devel have been i
nstalled.
sudo make
sudo make install
facilitate later version upgrades. just use this command:
cd .. && cd ..
sudo ln -s nginx-1.12.2 nginx
sudo chown marryme nginx
sudo chown marryme nginx-1.12.2
sudo rm -rf nginx-install
(you know, nginx-install could delete.)
Pay attention to the common commands of vim
or bash
:
-
Press the letter key "
i
" to edit mode; -
Press the return key "
esc
" + input the letter ":wq
": save and exit;
command:
vi ~/.bash_profile
Edit and add nginx path: export PATH=/usr/local/nginx/sbin:$PATH
, then save.
Also, save to make the configuration effective using this command:
source ~/.bash_profile
vi ~/.zshrc
also, edit and add nginx path, then save. Using this command:
export PATH=/usr/local/nginx/sbin:$PATH
Finnally, save to make the configuration effective using this command:
source ~/.zshrc
Adjust the listening port of the nginx server from 80 to 8080
./configure --prefix=/usr/local/nginx-1.12.2 \
--with-http_ssl_module \
--with-pcre=../pcre-8.41 \
--with-zlib=../zlib-1.2.11 \
--with-openssl=../openssl-1.1.1h
then, your Nginx conf was in this directory /usr/local/nginx/conf/nginx.conf
.
Also, modify the configuration file nginx.conf of nginx to change the
listening port of the server from 80
to 8080.
Just use this command:
sudo vim /usr/local/nginx/conf/nginx.conf
reference:
Use the letter key "i
" to insert editing, use the "esc
" key to
exit the editing mode, and gradually type ":wq
" to save and exit.
And, Find "server
" in the configuration file nginx.conf
, and change
the "listen
" of "server
" from "80
" to "8080
".
./configure --prefix=/usr/local/nginx-1.12.2 \
--conf-path=/usr/local/etc/nginx-conf/nginx.conf \
--error-log-path=/usr/local/var/log/nginx-logs/error.log \
--http-log-path=/usr/local/var/log/nginx-logs/access.log \
--pid-path=/usr/local/nginx-1.12.2/nginx-pid/nginx.pid \
--lock-path=/data/db/nginx-lock/nginx.lock \
--with-http_ssl_module \
--with-pcre=../pcre-8.41 \
--with-zlib=../zlib-1.2.11 \
--with-openssl=../openssl-1.1.1h
then, your Nginx conf was in this directory /usr/local/etc/nginx-conf/nginx.conf
.
and, modify the configuration file nginx.conf
of nginx to change the
listening port of the server
from 80
to 8080
. Just use this command:
sudo vim /usr/local/etc/nginx-conf/nginx.conf
./configure --prefix=/usr/local/nginx-1.12.2 \
--with-http_ssl_module \
--with-pcre=../pcre-8.41 \
--with-zlib=../zlib-1.2.11 \
--with-openssl=../openssl-1.1.1h
(Start the nginx server for the first time or modify the nginx configuration file and load the test to start)
sudo /usr/local/nginx/sbin/nginx -t -c /usr/local/nginx/conf/nginx.conf
"-t
" option: Use the configuration file to test
"-c
" option: start with the specified configuration file
And use this command to end nginx server(end nginx server for first time):
sudo rm -rf /usr/local/var/run/nginx/nginx.pid
sudo /usr/local/nignx/sbin/nginx
or
sudo nginx
Also, use this command to end:
sudo nginx -s stop
or
sudo nginx -s quit
Type "127.0.0.1:80/
" or "127.0.0.1:8080/
"(if you modify the listening port)
directly in the browser URL bar.
The Nginx version suitable for macOS 1x.x.x
ranges from 1.11.13
to 1.21.4
(the lastest version).
Others reference: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/nginx.rb
Failed at
sudo make
ld: symbol(s) not found for architecture i386
trying to follow your steps on mac pro m1