编译安装nginx及php

安装nginx所需依赖

安装pcre-devel

源安装
1
yum install -y pcre-devel
安装包安装

安装openssl-devel

1
yum install -y openssl-devel

安装nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/local/nginx/sbin/nginx \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_v2_module

make && make test

make install

php7.4.15依赖

libxml2-devel、sqlite-devel、libcurl-devel、libpng-devel、libzip-devel、openssl-devel

安装php7.4.15

安装时可能会出现 libzip 无法找到

执行以下命令

1
export PKG_CONFIG_PATH="/usr/local/lib/pkgconfig/"

安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
./configure \
--prefix=/usr/local/php@7.4 \
--with-config-file-path=/usr/local/php@7.4/etc \
--enable-fpm \
--with-libxml \
--with-openssl \
--with-zlib \
--enable-bcmath \
--enable-calendar \
--with-curl \
--enable-ftp \
--enable-gd \
--enable-pcntl \
--with-pdo-mysql \
--enable-soap \
--enable-sockets \
--with-zip \
--with-pear

make && make test

make install

参数说明:

参数 描述
–prefix 安装目录
–enable-fpm 开启php-fpm
–enable-ftp 开启ftp
–enable-bcmath 开启bcmath
–enable-calendar 开启calendar
–with-libxml 安装XML扩展
–with-openssl 安装OPENSSL扩展
–with-zlib 安装ZLIB扩展
–with-curl 安装CURL扩展
–with-pdo-mysql 安装PDO-MYSQL扩展
–with-zip 安装ZIP扩展
–with-pear 安装PEAR扩展

使用git webhook实现代码自动部署

前言

每次项目修改完代码后,需要通过一些文件传输工具上传到服务器,显得有些繁琐。希望git push的时候,服务器上的代码也能自动更新,这样也能节省不少时间。

阅读更多

PHP常用函数

常用排序算法

冒泡排序

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<?php
function bubble_sort($arr){
$length = count($arr);
if($length<=1){
return $arr;
}
for($i=0;$i<$length;$i++){
for($j=$length-1;$j>$i;$j--){
if($arr[$j]<$arr[$j-1]){
$tmp = $arr[$j];
$arr[$j] = $arr[$j-1];
$arr[$j-1] = $tmp;
}
}
}
return $arr;
}
阅读更多