天天看點

PHP腳本調用systemctl,環境安裝腳本

環境安裝腳本

LNP 環境

Nginx + PHP + Composer + Supervisor

适用于 Laravel 環境

包含内容: Nginx, PHP 7.2, Composer, Supervisor

PHP 子產品: fileinfo, imap, ldap, redis, memcached, swoole

安裝

# 安裝 Nginx + PHP,以下4行要全部複制一起執行

wget -c http://mirrors.linuxeye.com/oneinstack-full.tar.gz \

&& tar xzf oneinstack-full.tar.gz && ./oneinstack/install.sh \

--nginx_option 1 --php_option 7 --phpcache_option 1 \

--php_extensions fileinfo,imap,ldap,redis,memcached,swoole

# 安裝 Composer

yum install composer

# 安裝 Supervisor

yum install supervisor

服務管理

# 注冊服務

systemctl enable nginx

systemctl enable php-fpm

systemctl enable supervisor

# 啟動服務

systemctl start nginx

systemctl start php-fpm

systemctl start supervisor

# 重新開機服務

systemctl restart nginx

systemctl restart php-fpm

systemctl restart supervisor

# 檢視服務狀态

systemctl status nginx

systemctl status php-fpm

systemctl status supervisor

PHP 子產品及配置

按需添加子產品

# 首先進入 oneinstack 目錄,然後執行

## 添加 redis

./install.sh --php_extensions redis

## 添加 swoole

./install.sh --php_extensions swoole

## 添加 fileinfo

./install.sh --php_extensions fileinfo

啟用 proc_open

;; Laravel schedule 需要系統程序權限 proc_open, proc_get_status

;; 找到

disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen

;; 改為

disable_functions = passthru,exec,system,chroot,chgrp,chown,shell_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,fsocket,popen

參考

安裝 Nginx;PHP 版本選擇 7.3;PHP 擴充選擇 imagick,fileinfo,imap,ldap,redis,swoole;不裝資料庫;其他功能不安裝。

如果之前沒有安裝元件,後續補充安裝,統一入口為 ./install.sh,addons.sh 腳本不再提供,

如之前沒有安裝php redis擴充,補充安裝指令: ./install.sh --php_extensions redis

如之前沒有安裝php fileinfo擴充,補充安裝指令: ./install.sh --php_extensions fileinfo