Caddy是一个轻量级的http服务器,虽然很轻但是却很实用,功能也很强大。适合各种小内存鸡鸡
反代超级方便,证书申请很方便
本文主要内容是caddy的安装和配置php
apt-get update -y
apt-get install -y gcc g++ make zip lrzsz autoconf curl libxml2 libxml2-dev libssl-dev bzip2 libbz2-dev libjpeg-dev libpng12-dev libfreetype6-dev libgmp-dev libmcrypt-dev libreadline6-dev libsnmp-dev libxslt1-dev libcurl4-openssl-dev
groupadd -r php
groupadd -r www
useradd -r -g php -s /bin/false -d /usr/local/php -M php
useradd -r -g www -s /bin/false -d /usr/local/www -M www
#安装必要的依赖文件和创建PHP运行用户.组
#简便方法?apt?install?php
#编译安装
mkdir php cd php wget http://am1.php.net/distributions/php-7.2.8.tar.gz tar -zxf php-7.2.8.tar.gz cd php-7.2.8 ossl=`find / -name libssl.so` ln -s $ossl /usr/lib ./configure –prefix=/usr/local/php –exec-prefix=/usr/local/php –bindir=/usr/local/php/bin –sbindir=/usr/local/php/sbin –includedir=/usr/local/php/include –libdir=/usr/local/php/lib/php –mandir=/usr/local/php/php/man –with-config-file-path=/usr/local/php/etc –with-mysql-sock=/var/run/mysql/mysql.sock –with-mhash –with-openssl –with-mysqli=shared,mysqlnd –with-pdo-mysql=shared,mysqlnd –with-gd –with-iconv –with-zlib –enable-zip –enable-inline-optimization –disable-debug –disable-rpath –enable-shared –enable-xml –enable-bcmath –enable-shmop –enable-sysvsem –enable-mbregex –enable-mbstring –enable-ftp –enable-pcntl –enable-sockets –with-xmlrpc –enable-soap –without-pear –with-gettext –enable-session –with-curl –with-jpeg-dir –with-freetype-dir –enable-opcache –enable-fpm –with-fpm-user=php –with-fpm-group=php –without-gdbm –disable-fileinfo make && make install
/etc/profile?中增加以下行
“
export PHP_HOME=/usr/local/php export PATH=PHP_HOME/bin:PATH “
source /etc/profile cp sapi/fpm/init.d.php-fpm /usr/local/bin/php-fpm chmod +x /usr/local/bin/php-fpm cp php.ini-production /usr/local/php/etc/php.ini cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
创建进程池?/usr/local/php/etc/php-fpm.d/www.conf
“ ; Start a new pool named ‘www’ [www] listen = /usr/local/php/var/run/\$pool-php-fpm.sock listen.backlog = -1 listen.allowed_clients = 127.0.0.1 listen.owner = www listen.group = www listen.mode = 0660 user = www group = www pm = dynamic pm.max_children = 10 pm.start_servers = 2 pm.min_spare_servers = 1 pm.max_spare_servers = 6 pm.status_path = /status ping.path = /ping ping.response = pong request_terminate_timeout = 100 request_slowlog_timeout = 10s slowlog = /usr/local/php/var/log/$pool.log.slow “
启动php
/usr/local/bin/php-fpm start
curl https://getcaddy.com | bash -s personal http.cgi,http.filemanager
创建网站文件夹
mkdir -p /data/www/default chown -R www:www /data/www/
创建配置文件-实例
http://localhost { root /data/www/default gzip fastcgi / /usr/local/php/var/run/www-php-fpm.sock { ext .php split .php index index.php }
后台运行 Caddy
nohup caddy -conf=/etc/caddy.conf /usr/local/caddy.log 2 &1 &
常规Caddy命令用法
caddy start – 启动
caddy stop – 暂停
caddy restart – 重启
caddy status – 检查状态
caddy install – 全新安装
caddy service – 执行命令任务
caddy update – 更新
caddy delete – 卸载
caddy about – 查看帮助
caddy version – 检查版本
总结,关于Caddy WEB服务环境仅仅是初次接触,看到这个好玩的东西就先记录下来,以便后面如果有遇到深入的使用时候再去学习。