Mac下安装LNMP环境
引言
最近想本地写点程序,要不总是commit代码,效率低…
不喜欢默认安装,那就自己手动安装吧;
说明
- nginx采用Tengine2.2安装,对应版本为1.8
- macx10.x报错问题,请耐心安装
- 尽量使用源码编译安装扩展库
- zlib,pcre,openssl不需要单独configure,nginx引用过程会自行编译获取对应库文件
- 本文路径默认为/data/server/
- 编译后才会有 objs/Makefile 文件
更换brew源
#vim ~/.bashrc //追加如下命令
#export HOMEBREW_BOTTLE_DOMAIN=http://7xkcej.dl1.z0.glb.clouddn.com
源码下载
问题汇总
- macOS 10.x nginx限制处理
报错信息
nginx error: ‘OSAtomicAdd64’ is deprecated: first deprecated in macOS 10.12.
解决办法:
vim objs/Makefile,将:
CFLAGS = -pipe -O -Wall -Wextra -Wpointer-arith -Wno-unused-parameter -Werror -g
这一行去掉-Werror
- openssl更改成编译64位
vim objs/Makefile,搜索到如下行:
3.由于macx10+没有ldconfig命令,所以需要更改编译文件,自行添加路径
tengine
安装
#cd /data/install/tengine-2.2.0/
#./configure --prefix=/data/server/nginx --sbin-path=/data/server/nginx/sbin/nginx --conf-path=/data/server/nginx/conf/nginx.conf --error-log-path=/data/server/nginx/log/error.log --http-log-path=/data/server/nginx/log/access.log --pid-path=/data/server/nginx/nginx.pid --lock-path=/data/server/nginx/lock/nginx.lock --with-http_flv_module --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module --with-http_addition_module --with-http_random_index_module --with-http_dav_module --with-openssl=/data/server/src/openssl-1.0.2l --with-pcre=/data/server/src/pcre-8.38 --with-zlib=/data/server/src/zlib-1.2.11
#vim objs/Makefile
#第二行,去掉-Werror
#搜索openssl,将./config --prefix=/data/server/src/openssl-1.0.2l/.openssl no-shared
更换位:./Configure darwin64-x86_64-cc --prefix=/data/server/src/openssl-1.0.2l/.openssl no-shared
#make test
#make
#make install
#/data/server/nginx/sbin/nginx -m
配置
https
证书安装
#mkdir /data/server/nginx/ssl
#cd /data/server/nginx/ssl
/**根据提示输入密码和组织信息即可**/
#/usr/local/openssl/bin/openssl genrsa -des3 -out server.key 1024
#/usr/local/openssl/bin/openssl req -new -key server.key -out server.csr
#/usr/local/openssl/bin/openssl rsa -in server.key -out server_nopwd.key
#/usr/local/openssl/bin/openssl x509 -req -days 365 -in server.csr -signkey server_nopwd.key -out server.crt
配置nginx
/**建立80端口所有域名转发**/
#vim vhost_default.conf
#vim vhost_default.conf //参看附件1</