pocketmine手动安装php7.2,mac下手动安装与配置tengine2.2+php7

Mac下安装LNMP环境

引言

说明

更换brew源

源码下载

问题汇总

tengine

安装

配置

https

证书安装

配置nginx

mysql

brew方式

PHP7

openssl安装

编译扩展

编译php

安装扩展

启动脚本

附录1 nginx conf

附录2 php-fpm start.sh

引言

最近想本地写点程序,要不总是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

源码下载

zib下载地址

pcre下载地址

tengine2.2下载地址

openssl下载地址

问题汇总

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

#vim vhost_localhost_ssl.conf //参看附件1文件

#nginx -t && nginx -s reload

mysql

brew方式

其他方式坑太他妈多了,数据目录一定要放在自己的非系统环境里,否则丢失了就麻烦了

#brew install mysql

#unset TMPDIR

#mysql_install_db --verbose --user='_mysql' --basedir="$(brew --prefix mysql)" --datadir=/data/server/mysql/data/

#mysql.server start

PHP7

openssl安装

#brew upgrade openssl

#ls -l /usr/local/openssl/ //查看是否有动态库

编译扩展

libcurl

libiconv

zlib

#wget https://curl.haxx.se/download/curl-7.54.1.tar.gz

#wget http://zlib.net/zlib-1.2.11.tar.gz

#wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.8.tar.gz

#tar zxvf curl-7.54.1.tar.gz

# tar zxvf zlib-1.2.11.tar.gz

# tar zxvf libiconv-1.8.tar.gz

# configure --prefix=/data/server/libs/*

# make && make install

//以上根据实际情况自行安装即可

编译php

#./configure --prefix=/data/server/php/ --with-config-file-path=/data/server/php/etc/ --enable-mysqlnd --with-mysqli=/usr/local/Cellar/mysql/5.7.18_1/bin/mysql_config --with-pdo-mysql=/usr/local/Cellar/mysql/5.7.18_1/ --with-freetype-dir --with-jpeg-dir --with-png-dir --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --enable-calendar --enable-opcache --with-openssl=/usr/local/openssl/ --with-zlib=/usr/local/opt/zlib/ --with-curl=/usr/local/opt/curl/ --with-iconv=/usr/local/opt/libiconv/

#vim Makefile

#make && make install

#data/server/php/bin/php -v //查看是否安装成功

下边非常重要,否则macx 10+安装不上的,因为没有ld命令

这里需要注意,configure后就要开始编辑Makefile文件了,

如果不完整,可以根据错误进行增加替换,但方式一样。

#vim Makefile

#找到112行或者EXTRA_LIBS,做如下替换

EXTRA_LIBS = -lz -lresolv -lmcrypt -lltdl -lpng -lz -ljpeg -lcurl -lz -lcrypto -lm -lxml2 -lz -licucore -lm -lcurl -lldap -lz -lxml2 -lz -licucore -lm -lfreetype -lmysqlclient -lmysqlclient -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm -lxml2 -lz -licucore -lm /usr/local/openssl/lib/libssl.dylib /usr/local/openssl/lib/libcrypto.dylib /usr/local/Cellar/libiconv/1.15/lib/libiconv.dylib

例如里边有lssl 那么把全部它删掉,替换成 /usr/local/openssl/lib/libssl.dylib 如果找不全可以根据实际报错同理处理

安装扩展

/**imagick**/

#wget http://pecl.php.net/get/imagick-3.4.3.tgz

#tar zxvf imagick-3.4.3.tgz

#/data/server/php/bin/phpize

#brew install imagemagick

#./configure --with-php-config=/data/server/php/bin/php-config --with-imagick=/usr/local/opt/imagemagick/

#make && make install

/**memcached**/

#brew install libmemcached

#cd memcached-1.5.0

#/data/server/php/bin/phpize

#./configure --with-zlib-dir=/usr/local/Cellar/zlib/1.2.11/ --with-php-config=/data/server/php/bin/php-config --with-libmemcached-dir=/usr/local/opt/libmemcached/

#make && make install

/**mongodb**/

#git clone https://github.com/mongodb/mongo-php-driver.git

#cd /mongo-php-driver/

#git submodule update --init

#/data/server/php/bin/phpize

#./configure --with-php-config=/data/server/php/bin/php-config --with-openssl-dir=/usr/local/opt/openssl/

#make & make install

启动脚本

#vim /data/server/php/etc/php-fpm.conf

/**在global下边添加一行pid**/

#pid = run/php-fpm.pid

/**在下边文件里插入附件里的脚本文件**/

#vim /data/server/php/start.sh

附录1 nginx conf

/**default.conf**/

server {

listen 80 default_server;

#listen [::]:80 default_server;

server_name _;

# Discourage deep links by using a permanent redirect to home page of HTTPS site

return 301 https://$host;

# Alternatively, redirect all HTTP links to the matching HTTPS page

# return 301 https://$host$request_uri;

}

/**local demo conf**/

server {

listen 443 ssl;

server_name localhost 127.0.0.1;

//HSTL协议添加,确保第一次访问也安全

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

ssl_certificate /data/server/nginx/ssl/server.crt;

ssl_certificate_key /data/server/nginx/ssl/server_nopwd.key;

index index.html index.htm index.php;

root /data/www/localhost/web/;

location / {

if (-d $request_filename) {

rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;

}

if (!-e $request_filename){

rewrite ^/(.*)$ /index.php?s=/$1 last;

}

}

location ~ \.php$ {

index index.php;

fastcgi_pass fastcgi_backend;

fastcgi_param SCRIPT_FILENAME;

$document_root$fastcgi_script_name;

include fastcgi_params;

include fastcgi.conf;

}

}

附录2 php-fpm start.sh

/**start.sh**/

DESC="php-fpm daemon"

NAME=php-fpm

# php-fpm路径

DAEMON=/data/server/php/sbin/$NAME

# 配置文件路径

CONFIGFILE=/data/server/php/etc/$NAME.conf

# PID文件路径(在php-fpm.conf设置)

PIDFILE=/data/server/php/var/run/$NAME.pid

SCRIPTNAME=/data/server/php/start.sh

# Gracefully exit if the package has been removed.

test -x $DAEMON || exit 0

rh_start() {

$DAEMON -y $CONFIGFILE || echo -n " already running"

}

rh_stop() {

kill -QUIT `cat $PIDFILE` || echo -n " not running"

}

rh_reload() {

kill -HUP `cat $PIDFILE` || echo -n " can't reload"

}

case "$1" in

start)

echo "Starting $DESC: $NAME"

rh_start

#echo "\n"

;;

stop)

echo "Stopping $DESC: $NAME"

rh_stop

#echo "\n"

;;

reload)

echo "Reloading $DESC configuration..."

rh_reload

echo "reloaded."

;;

restart)

echo "Restarting $DESC: $NAME"

rh_stop

sleep 1

rh_start

#echo "\n"

;;

*)

echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2

exit 3

;;

esac

exit 0

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值