├── conf ├── nginx.conf ├── vhost │ └── lampol.conf ├── thinkphp.conf ├── my.cnf ├── index.html └── php-fpm.conf ├── common ├── vars.sh ├── configure.txt └── common.sh ├── install ├── cmake.sh ├── thinkphp.sh ├── memcached.sh ├── php_redis.sh ├── php_memcache.sh ├── nginx.sh ├── mysql.sh ├── libzip.sh ├── php.sh ├── yum.sh ├── redis.sh ├── welcome.sh ├── framework.sh ├── main.sh ├── third_main.sh └── conf_redis.sh ├── install.sh ├── shell ├── install_framework.sh ├── install_third_party.sh └── mysql_secure_installation ├── init.d ├── memcached ├── php-fpm ├── nginx ├── redis └── mysqld └── README.md /conf/nginx.conf: -------------------------------------------------------------------------------- 1 | user www; 2 | 3 | worker_processes auto; 4 | 5 | error_log logs/error.log; 6 | 7 | pid /var/run/nginx.pid; 8 | 9 | events { 10 | worker_connections 10240; 11 | } 12 | 13 | http { 14 | include mime.types; 15 | default_type application/octet-stream; 16 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 17 | '$status $body_bytes_sent "$http_referer" ' 18 | '"$http_user_agent" "$http_x_forwarded_for"'; 19 | sendfile on; 20 | tcp_nopush on; 21 | server_tokens off; 22 | keepalive_timeout 60; 23 | 24 | include vhost/lampol.conf ; 25 | } 26 | -------------------------------------------------------------------------------- /common/vars.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName vars.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 14:40 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | SRC_DIR=$BASE_DIR/src 12 | NGINX_GROUP=www 13 | NGINX_USER=www 14 | MYSQL_GROUP=mysql 15 | MYSQL_USER=mysql 16 | SERVER_DIR=/home/www 17 | SOFT_DIR=/usr/local 18 | CONF_DIR=$BASE_DIR/conf 19 | INIT_DIR=$BASE_DIR/init.d 20 | RELEASE=`cat /etc/redhat-release | awk -F'.' '{print $1}'|awk '{print $NF}'` 21 | OS=`cat /etc/redhat-release |awk '{print $1}'` 22 | -------------------------------------------------------------------------------- /install/cmake.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName nginx.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 11:48 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | 12 | 13 | function Install_Cmake(){ 14 | [[ -f $SRC_DIR/$1 ]] && rm -rf $SRC_DIR/${1%%.*}* 15 | wget -c https://cmake.org/files/v3.20/$1 -P $SRC_DIR 16 | [[ $? -ne 0 ]] && clear && echo -e "`Print_Color '31' "download $1 failed please try again"`" && exit 1 17 | CONFIGURE=CONF_CMAKE 18 | Tar $1 && Install $CONFIGURE 19 | cp bin/cmake /usr/bin/cmake 20 | } 21 | -------------------------------------------------------------------------------- /conf/vhost/lampol.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 8080; 3 | server_name 127.0.0.1; 4 | root /home/www; 5 | index index.php index.html; 6 | access_log /var/log/nginx.access.log main; 7 | gzip on; 8 | gzip_types application/x-javascript text/css text/javascript application/x-httpd-php image/jpeg image/gif image/png; 9 | 10 | error_page 500 502 503 504 /50x.html; 11 | location = /50x.html { 12 | root html; 13 | } 14 | 15 | location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ { 16 | expires 10d; 17 | } 18 | 19 | location ~ \.php$ { 20 | fastcgi_pass 127.0.0.1:9000; 21 | fastcgi_index index.php; 22 | include fastcgi.conf; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /conf/thinkphp.conf: -------------------------------------------------------------------------------- 1 | server { 2 | listen 81; 3 | server_name 127.0.0.1; 4 | root /home/www/lampol/public; 5 | index index.php index.html; 6 | access_log /var/log/nginx.access.log main; 7 | gzip on; 8 | gzip_types application/x-javascript text/css text/javascript application/x-httpd-php image/jpeg image/gif image/png; 9 | 10 | error_page 500 502 503 504 /50x.html; 11 | location = /50x.html { 12 | root html; 13 | } 14 | 15 | location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|js|css)$ { 16 | expires 10d; 17 | } 18 | location / { 19 | if (!-e $request_filename) { 20 | rewrite ^(.*)$ /index.php?s=/$1 last; 21 | break; 22 | } 23 | } 24 | 25 | location ~ \.php$ { 26 | fastcgi_pass 127.0.0.1:9000; 27 | fastcgi_index index.php; 28 | include fastcgi.conf; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /install/thinkphp.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName memcached.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 11:49 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | 12 | 13 | function Mk_Cp_Thinkphp(){ 14 | PROJECT_NAME=$1 15 | cp $CONF_DIR/thinkphp.conf $SOFT_DIR/nginx/conf/vhost/ 16 | sed -i "s/lampol/$PROJECT_NAME/g" $SOFT_DIR/nginx/conf/vhost/thinkphp.conf 17 | sed -i 's#include vhost/lampol.conf ;#include vhost/thinkphp.conf ;#g' $SOFT_DIR/nginx/conf/nginx.conf 18 | } 19 | 20 | 21 | 22 | function Install_Thinkphp(){ 23 | 24 | cd /home/www/ && composer create-project topthink/think=$1 $2 --prefer-dist 25 | [[ $? -ne 0 ]] && clear && echo -e "`Print_Color '31' "project name $2 already exists"`" && exit 1 26 | 27 | Mk_Cp_Thinkphp $2 28 | } 29 | -------------------------------------------------------------------------------- /install/memcached.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName memcached.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 11:49 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | function Mk_Cp_Memcached(){ 12 | cp $INIT_DIR/memcached /etc/init.d/ 13 | chmod +x /etc/init.d/memcached 14 | /etc/init.d/memcached start 15 | } 16 | 17 | 18 | function Install_Memcached(){ 19 | yum install libevent-devel -y 20 | [[ -f $SRC_DIR/$1 ]] && rm -rf $SRC_DIR/${1%%.*}* 21 | wget -c http://www.memcached.org/files/$1 -P $SRC_DIR 22 | [[ $? -ne 0 ]] && clear && echo -e "`Print_Color '31' "download $1 failed please try again"`" && exit 1 23 | CONFIGURE=CONF_MEMCACHED 24 | [[ -d $SOFT_DIR/memcached ]] && rm -rf $SOFT_DIR/memcached 25 | Tar $1 && Install $CONFIGURE 26 | Mk_Cp_Memcached 27 | 28 | } 29 | -------------------------------------------------------------------------------- /install/php_redis.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName mysql.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 11:49 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | function Mk_Cp_Php_Redis(){ 12 | REDIS_SO=`find $SOFT_DIR/php/ -name "redis.so"` 13 | sed -i '/redis.so/d' $SOFT_DIR/php/etc/php.ini 14 | sed -i "/Dynamic Extensions/aextension=$REDIS_SO" $SOFT_DIR/php/etc/php.ini 15 | /etc/init.d/php-fpm restart 16 | php -m 17 | } 18 | 19 | 20 | function Install_Php_Redis(){ 21 | REDIS_NAME=${1:0:(${#1}-4)}.tar.gz 22 | [[ -f $SRC_DIR/$1 ]] && rm -rf $SRC_DIR/${1%%.*}* 23 | wget -c https://pecl.php.net/get/$1 -O $SRC_DIR/$REDIS_NAME 24 | [[ $? -ne 0 ]] && clear && echo -e "`Print_Color '31' "download $1 failed please try again"`" && exit 1 25 | CONFIGURE=CONF_MEMCACHE_PHP 26 | Tar_Phpize $REDIS_NAME && Install $CONFIGURE 27 | Mk_Cp_Php_Redis 28 | 29 | } 30 | -------------------------------------------------------------------------------- /install/php_memcache.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName mysql.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 11:49 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | function Mk_Cp_Php_Memcache(){ 12 | MEMCACHE_SO=`find $SOFT_DIR/php/ -name "memcache.so"` 13 | sed -i '/memcache.so/d' $SOFT_DIR/php/etc/php.ini 14 | sed -i "/Dynamic Extensions/aextension=$MEMCACHE_SO" $SOFT_DIR/php/etc/php.ini 15 | /etc/init.d/php-fpm restart 16 | php -m 17 | } 18 | 19 | 20 | function Install_Php_Memcached(){ 21 | PHP_MEM=memcache-2.2.7.tar.gz 22 | [[ -f $SRC_DIR/$PHP_MEM ]] && rm -rf $SRC_DIR/${1%%.*}* 23 | wget -c https://pecl.php.net/get/$1 -O $SRC_DIR/$PHP_MEM 24 | [[ $? -ne 0 ]] && clear && echo -e "`Print_Color '31' "download $1 failed please try again"`" && exit 1 25 | CONFIGURE=CONF_MEMCACHE_PHP 26 | Tar_Phpize $PHP_MEM && Install $CONFIGURE 27 | Mk_Cp_Php_Memcache 28 | 29 | } 30 | -------------------------------------------------------------------------------- /install/nginx.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName nginx.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 11:48 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | 12 | function Mk_Cp(){ 13 | mkdir -p $SERVER_DIR && chown -R $NGINX_USER.$NGINX_GROUP $SERVER_DIR 14 | # rm -f /usr/local/nginx/conf/nginx.conf 15 | 16 | cp $CONF_DIR/nginx.conf $SOFT_DIR/nginx/conf 17 | 18 | cp -r $CONF_DIR/vhost $SOFT_DIR/nginx/conf 19 | 20 | cp $CONF_DIR/index.html /home/www/ 21 | 22 | cp $INIT_DIR/nginx /etc/init.d/ 23 | chmod +x /etc/init.d/nginx 24 | } 25 | 26 | function Install_Nginx(){ 27 | [[ -f $SRC_DIR/$1 ]] && rm -rf $SRC_DIR/${1%%.*}* 28 | wget -c http://nginx.org/download/$1 -P $SRC_DIR 29 | [[ $? -ne 0 ]] && clear && echo -e "`Print_Color '31' "download $1 failed please try again"`" && exit 1 30 | CONFIGURE=CONF_NGINX 31 | [[ -d $SOFT_DIR/nginx ]] && rm -rf $SOFT_DIR/nginx 32 | Add_User $NGINX_USER $NGINX_GROUP 33 | Tar $1 && Install $CONFIGURE 34 | Mk_Cp 35 | } 36 | -------------------------------------------------------------------------------- /install/mysql.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName mysql.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 11:49 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | function Mk_Cp_Mysql(){ 12 | chown -R mysql.mysql $SOFT_DIR/mysql 13 | \cp $SOFT_DIR/mysql/bin/mysql /usr/bin 14 | cp $INIT_DIR/mysqld /etc/init.d/mysqld 15 | mkdir $SOFT_DIR/mysql/etc 16 | cp $CONF_DIR/my.cnf $SOFT_DIR/mysql/etc/ 17 | chmod +x /etc/init.d/mysqld 18 | rm -f /etc/my.cnf 19 | $SOFT_DIR/mysql/scripts/mysql_install_db --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql --user=mysql 20 | } 21 | 22 | 23 | function Install_Mysql(){ 24 | [[ -f $SRC_DIR/$1 ]] && rm -rf $SRC_DIR/${1%%.*}* 25 | wget -c https://dev.mysql.com/get/Downloads/MySQL-$2/$1 --no-check-certificate -P $SRC_DIR 26 | [[ $? -ne 0 ]] && clear && echo -e "`Print_Color '31' "download $1 failed please try again"`" && exit 1 27 | CONFIGURE=CONF_MYSQL 28 | [[ -d $SOFT_DIR/mysql ]] && rm -rf $SOFT_DIR/mysql 29 | Add_User $MYSQL_USER $MYSQL_GROUP 30 | Tar $1 && Install $CONFIGURE 31 | Mk_Cp_Mysql 32 | 33 | } 34 | -------------------------------------------------------------------------------- /install.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName install.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 09:13 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | BASE_DIR=`pwd` 12 | source $BASE_DIR/common/vars.sh 13 | source $BASE_DIR/common/common.sh 14 | source $BASE_DIR/install/main.sh 15 | 16 | 17 | #Check User root 18 | if [ `id -u` -ne 0 ] 19 | then 20 | echo -e "\033[31m Your Current User is `whoami` Please install by root \033[0m" 21 | exit 1 22 | fi 23 | #print welcome info 24 | clear 25 | echo "+------------------------------------------------------------------------+" 26 | Print_Color "32" "This is auto install lnmp script" 27 | echo "+------------------------------------------------------------------------+" 28 | # 29 | cat << EOF 30 | ***********Are You Ready To Install Lnmp?********* 31 | 1) `Print_Color "32" "Install Lnmp Right Now"` 32 | 2) `Print_Color "32" "Exit"` 33 | EOF 34 | 35 | read -p "Please Enter Your Choice(1/2):" input 36 | 37 | case "$input" in 38 | 1) 39 | Init_Install $RELEASE $OS 40 | ;; 41 | *) 42 | Print_Color "32" "You Have Exit Install Welcome Install Again" 43 | exit 1 44 | esac 45 | -------------------------------------------------------------------------------- /common/configure.txt: -------------------------------------------------------------------------------- 1 | CONF_NGINX:./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-http_sub_module 2 | 3 | CONF_PHP:./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=www --with-fpm-group=www --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-iconv-dir --with-freetype-dir=/usr/local/freetype --with-mcrypt --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-inline-optimization --with-curl --enable-mbregex --enable-mbstring --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --with-xmlrpc --enable-zip --enable-soap --with-gettext --enable-opcache --with-xsl --enable-bcmath --enable-posix --enable-sockets 4 | 5 | CONF_MYSQL:cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DMYSQL_USER=mysql -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_MYISAM_STORAGE_ENGINE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_DEBUG=0 -DWITH_READLINE=1 -DWITH_EMBEDDED_SERVER=1 -DENABLED_LOCAL_INFILE=1 6 | 7 | CONF_MEMCACHED:./configure --prefix=/usr/local/memcached 8 | 9 | CONF_MEMCACHE_PHP:./configure --with-php-config=/usr/local/php/bin/php-config 10 | 11 | CONF_REDIS:make PREFIX=/usr/local/redis install 12 | 13 | CONF_CMAKE:./bootstrap 14 | -------------------------------------------------------------------------------- /install/libzip.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName nginx.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 11:48 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | 12 | 13 | function Install_Libzip(){ 14 | wget -c https://github.com/nih-at/libzip/releases/download/v1.10.0/libzip-1.10.0.tar.gz -P $SRC_DIR 15 | cd $SRC_DIR 16 | tar xf libzip-1.10.0.tar.gz 17 | cd libzip-1.10.0 18 | mkdir build 19 | cd build 20 | cmake .. 21 | make && make install 22 | echo '/usr/local/lib64 23 | /usr/local/lib 24 | /usr/lib 25 | /usr/lib64'>>/etc/ld.so.conf 26 | 27 | ldconfig -v 28 | 29 | Install_oniguruma 30 | } 31 | 32 | 33 | function Install_oniguruma(){ 34 | yum install -y expat-devel autoconf automake libtool sqlite-devel 35 | 36 | wget https://github.com/kkos/oniguruma/archive/v6.9.4.tar.gz -O $SRC_DIR/oniguruma-6.9.4.tar.gz 37 | cd $SRC_DIR 38 | tar -zxf oniguruma-6.9.4.tar.gz 39 | cd oniguruma-6.9.4 40 | ./autogen.sh && ./configure --prefix=/usr --libdir=/lib64 41 | make && make install 42 | } 43 | -------------------------------------------------------------------------------- /install/php.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName php.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 11:49 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | 12 | function Mk_Cp_Php(){ 13 | cp php.ini-production $SOFT_DIR/php/etc/php.ini 14 | cp $CONF_DIR/php-fpm.conf $SOFT_DIR/php/etc/php-fpm.conf 15 | cp $INIT_DIR/php-fpm /etc/init.d/ 16 | \cp $SOFT_DIR/php/bin/php /usr/bin/ 17 | chmod +x /etc/init.d/php-fpm 18 | } 19 | 20 | 21 | function Install_Php(){ 22 | [[ -f $SRC_DIR/$1 ]] && rm -rf $SRC_DIR/${1%%.*}* 23 | #wget -c http://am1.php.net/get/$1/from/this/mirror -O $SRC_DIR/$1 24 | #wget -c http://cn2.php.net/get/$1/from/this/mirror -O $SRC_DIR/$1 25 | wget -c https://www.php.net/distributions/$1 --no-check-certificate -O $SRC_DIR/$1 26 | [[ $? -ne 0 ]] && clear && echo -e "`Print_Color '31' "download $1 failed please try again"`" && exit 1 27 | CONFIGURE=CONF_PHP 28 | [[ -d $SOFT_DIR/php ]] && rm -rf $SOFT_DIR/php 29 | Tar $1 && Install $CONFIGURE 30 | Mk_Cp_Php 31 | 32 | } 33 | #yum install libxml2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel libicu-devel libmcrypt-devel openssl-devel -y 34 | -------------------------------------------------------------------------------- /install/yum.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName yum.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 13:49 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | 12 | function Yum_Install(){ 13 | #check centos7 or 6 14 | if [ $1 -eq 7 ] 15 | then 16 | yum install -y https://mirrors.tuna.tsinghua.edu.cn/epel//epel-release-latest-7.noarch.rpm 17 | elif [ $1 -eq 6 ] 18 | then 19 | yum install -y https://mirrors.tuna.tsinghua.edu.cn/epel//epel-release-latest-6.noarch.rpm 20 | fi 21 | #start install dependency 22 | yum install -y pcre-devel openssl openssl-devel libxml2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel libicu-devel libmcrypt-devel libxslt-devel cmake ncurses-devel perl bison figlet 23 | } 24 | 25 | 26 | function Yum_Install_Tool(){ 27 | yum install -y gcc gcc-c++ wget git lrzsz autoconf net-tools telnet vim 28 | 29 | } 30 | 31 | function Install_Composer(){ 32 | curl -sS https://getcomposer.org/installer | php 33 | [[ $? -ne 0 ]] && clear && echo -e "`Print_Color '31' "composer install failed please try again"`" && exit 1 34 | mv composer.phar /usr/local/bin/composer 35 | composer config -g repo.packagist composer https://packagist.phpcomposer.com 36 | } 37 | -------------------------------------------------------------------------------- /shell/install_framework.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName install.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 09:13 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | BASE_DIR=`pwd` 12 | BASE_DIR=${BASE_DIR%/*} 13 | source $BASE_DIR/common/vars.sh 14 | source $BASE_DIR/common/common.sh 15 | source $BASE_DIR/install/framework.sh 16 | 17 | 18 | #Check User root 19 | if [ `id -u` -ne 0 ] 20 | then 21 | echo -e "\033[31m Your Current User is `whoami` Please install by root \033[0m" 22 | exit 1 23 | fi 24 | #print welcome info 25 | clear 26 | echo "+------------------------------------------------------------------------+" 27 | Print_Color "32" "This is auto install ThinkPHP framework" 28 | echo "+------------------------------------------------------------------------+" 29 | # 30 | cat << EOF 31 | ***********Are You Ready To Install ThinkPHP You Can Install:********* 32 | 33 | ***********ThinkPHP....*************************************** 34 | 1) `Print_Color "32" "Install Now"` 35 | 2) `Print_Color "32" "There Is No Software What I Want And Exit"` 36 | EOF 37 | 38 | read -p "Please Enter Your Choice(1/2):" input 39 | 40 | case "$input" in 41 | 1) 42 | Install_Framework 43 | ;; 44 | *) 45 | Print_Color "32" "You Have Exit Install Welcome Install Again" 46 | exit 1 47 | esac 48 | -------------------------------------------------------------------------------- /shell/install_third_party.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName install.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 09:13 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | BASE_DIR=`pwd` 12 | BASE_DIR=${BASE_DIR%/*} 13 | source $BASE_DIR/common/vars.sh 14 | source $BASE_DIR/common/common.sh 15 | source $BASE_DIR/install/third_main.sh 16 | 17 | 18 | #Check User root 19 | if [ `id -u` -ne 0 ] 20 | then 21 | echo -e "\033[31m Your Current User is `whoami` Please install by root \033[0m" 22 | exit 1 23 | fi 24 | #print welcome info 25 | clear 26 | echo "+------------------------------------------------------------------------+" 27 | Print_Color "32" "This is auto install third extension" 28 | echo "+------------------------------------------------------------------------+" 29 | # 30 | cat << EOF 31 | ***********Are You Ready To Install Third Party You Can Install:********* 32 | 33 | ***********Memcached php-memcache Redis php-redis*************************************** 34 | 1) `Print_Color "32" "Install Now"` 35 | 2) `Print_Color "32" "There Is No Software What I Want And Exit"` 36 | EOF 37 | 38 | read -p "Please Enter Your Choice(1/2):" input 39 | 40 | case "$input" in 41 | 1) 42 | Install_Third 43 | ;; 44 | *) 45 | Print_Color "32" "You Have Exit Install Welcome Install Again" 46 | exit 1 47 | esac 48 | -------------------------------------------------------------------------------- /install/redis.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName memcached.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 11:49 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | function Mk_Cp_Redis(){ 12 | REDIS_NAME=$1 13 | REDIS_NAME_DIR=${REDIS_NAME:0:(${#REDIS_NAME}-7) } 14 | mkdir -p $SOFT_DIR/redis/etc/ $SOFT_DIR/redis/data $SOFT_DIR/redis/log 15 | touch $SOFT_DIR/redis/log/redis.log 16 | cp $SRC_DIR/$REDIS_NAME_DIR/redis.conf $SOFT_DIR/redis/etc/ 17 | cp $INIT_DIR/redis /etc/init.d/ 18 | chmod +x /etc/init.d/redis 19 | sed -i 's#^logfile .*$#logfile '"$SOFT_DIR"'/redis/log/redis.log#g' $SOFT_DIR/redis/etc/redis.conf 20 | sed -i 's#^dir .*$#dir '"$SOFT_DIR"'/redis/data#g' $SOFT_DIR/redis/etc/redis.conf 21 | sed -i 's#^pidfile .*$#pidfile /var/run/redis.pid#g' $SOFT_DIR/redis/etc/redis.conf 22 | sed -i 's#^daemonize no#daemonize yes#g' $SOFT_DIR/redis/etc/redis.conf 23 | } 24 | 25 | 26 | function Install_Redis(){ 27 | [[ -f $SRC_DIR/$1 ]] && rm -rf $SRC_DIR/${1%%.*}* 28 | wget -c http://download.redis.io/releases/$1 -P $SRC_DIR 29 | [[ $? -ne 0 ]] && clear && echo -e "`Print_Color '31' "download $1 failed please try again"`" && exit 1 30 | CONFIGURE=CONF_REDIS 31 | [[ -d $SOFT_DIR/redis ]] && rm -rf $SOFT_DIR/redis 32 | Tar $1 && Install $CONFIGURE 33 | Mk_Cp_Redis $1 34 | 35 | } 36 | -------------------------------------------------------------------------------- /init.d/memcached: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ================================================================= 4 | # FileName memcached.sh 5 | # Copyright (C) 2016 root 6 | # CreateTime 2016-11-16 21:12 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #================================================================== 11 | 12 | #======================REBOOT AUTOSTART============================ 13 | #chkconfig:2345 64 65 14 | #Description:startup memcached 15 | 16 | #source script library 17 | . /etc/init.d/functions 18 | 19 | 20 | PROG=memcached 21 | EXEC=/usr/local/memcached/bin/memcached 22 | LOCKFILE=/var/lock/subsys/memcached 23 | PORT=11211 24 | PIDFILE=/var/run/memcached.pid 25 | USER=root 26 | 27 | 28 | if [ $UID -ne 0 -a $# -ne 1 ] 29 | then 30 | echo "USAGE $0 {start|stop|restart}" 31 | fi 32 | 33 | function start_mem(){ 34 | if netstat -nltp| grep -v grep | grep -q memcached 35 | then 36 | echo "Memcached IS Running..." 37 | exit 1 38 | fi 39 | 40 | if test -f $EXEC 41 | then 42 | $EXEC -u $USER -p $PORT -P $PIDFILE -d 43 | RETVAL=$? 44 | [ $RETVAL -eq 0 ] && touch $LOCKFILE 45 | action "START MySQL SUCCESS" /bin/true 46 | fi 47 | } 48 | 49 | function stop_mem(){ 50 | if netstat -nltp| grep -v grep | grep -q memcached 51 | then 52 | killproc $EXEC 53 | RETVAL=$? 54 | [ $RETVAL -eq 0 ] && rm -f $LOCKFILE 55 | action "STOP Memcached SUCCESS" /bin/true 56 | else 57 | action "Memcached IS NOT RUNNING" /bin/false 58 | fi 59 | 60 | } 61 | 62 | case "$1" in 63 | start) 64 | start_mem 65 | ;; 66 | stop) 67 | stop_mem 68 | ;; 69 | restart) 70 | stop_mem 71 | start_mem 72 | ;; 73 | *) 74 | echo "USAGE $0 {start|stop|restart}" 75 | exit 1 76 | esac 77 | -------------------------------------------------------------------------------- /common/common.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName common.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 09:35 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | 12 | 13 | function Print_Color(){ 14 | 15 | echo -e "\033[$1m $2 \033[0m" 16 | } 17 | 18 | # 19 | function Tar(){ 20 | NAME=$1 21 | [[ -d $SRC_DIR/$NAME ]] && rm -rf $SRC_DIR/$NAME 22 | tar xf $SRC_DIR/$NAME -C $SRC_DIR 23 | NAME_DIR=${NAME:0:(${#NAME}-7) } 24 | cd $SRC_DIR/$NAME_DIR 25 | Print_Color "32" "Start Install $NAME_DIR Please Wait" 26 | sleep 3 27 | } 28 | 29 | #tar and phpize 30 | function Tar_Phpize(){ 31 | NAME=$1 32 | [[ -d $SRC_DIR/$NAME ]] && rm -rf $SRC_DIR/$NAME 33 | tar xf $SRC_DIR/$NAME -C $SRC_DIR 34 | NAME_DIR=${NAME:0:(${#NAME}-7) } 35 | cd $SRC_DIR/$NAME_DIR 36 | $SOFT_DIR/php/bin/phpize 37 | Print_Color "32" "Start Install $NAME_DIR Please Wait" 38 | sleep 3 39 | } 40 | 41 | #add user 42 | function Add_User(){ 43 | USER=$1 44 | GROUP=$2 45 | egrep "^$GROUP" /etc/group >/dev/null 46 | if [ $? -ne 0 ] 47 | then 48 | groupadd $GROUP 49 | fi 50 | egrep "^$USER" /etc/passwd >/dev/null 51 | if [ $? -ne 0 -a "$USER"="www" ] 52 | then 53 | useradd -s /sbin/nologin -g $GROUP $USER 54 | 55 | else 56 | useradd -M -s /sbin/nologin -g $GROUP $USER 57 | fi 58 | } 59 | 60 | function Install(){ 61 | CONF_NAME=$1 62 | CONFIGURE=`cat $BASE_DIR/common/configure.txt | grep $CONF_NAME|awk -F ":" '{print $2}'` 63 | $CONFIGURE && make && make install 64 | Print_Color "32" "Install $NAME_DIR SUCCESS" 65 | } 66 | 67 | -------------------------------------------------------------------------------- /init.d/php-fpm: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ================================================================= 4 | # FileName php.sh 5 | # Copyright (C) 2016 root 6 | # CreateTime 2016-11-28 10:25 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #================================================================== 11 | 12 | #======================REBOOT AUTOSTART============================ 13 | #chkconfig:2345 53 77 14 | #Description:This is php start stop reload script 15 | 16 | #====================Source Fucntions============================== 17 | 18 | . /etc/init.d/functions 19 | 20 | if [ $# -ne 1 ] 21 | then 22 | echo "Usage $0 {start|stop|reload}" 23 | exit 8 24 | fi 25 | 26 | 27 | PROG=php-fpm 28 | EXEC=/usr/local/php/sbin/$PROG 29 | PIDFILE=/var/run/$PROG.pid 30 | LOCKFILE=/var/lock/subsys/$PROG 31 | CONFFILE=/usr/local/php/etc/$PROG.conf 32 | 33 | function start(){ 34 | if netstat -nltp| grep -q $PROG 35 | then 36 | echo "$PROG(pid `pidof $PROG`) already running" 37 | exit 1 38 | else 39 | $EXEC -y $CONFFILE 40 | [ $? -eq 0 ] && touch $LOCKFILE 41 | action "Start $PROG SUCCESS" /bin/true 42 | fi 43 | } 44 | function stop(){ 45 | if netstat -nltp| grep -q $PROG 46 | then 47 | kill -QUIT `cat $PIDFILE` 48 | [ $? -ne 0 ] && rm -f $PIDFILE && rm -f $LOCKFILE 49 | action "Stop $PROG SUCCESS" /bin/true 50 | else 51 | action "$PROG is not running" /bin/false 52 | 53 | fi 54 | 55 | } 56 | 57 | case "$1" in 58 | start) 59 | start 60 | ;; 61 | stop) 62 | stop 63 | ;; 64 | restart) 65 | stop 66 | sleep 1 67 | start 68 | ;; 69 | *) 70 | echo "Usage $0 {start|stop|reload}" 71 | exit 5 72 | esac 73 | 74 | -------------------------------------------------------------------------------- /install/welcome.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName welcome.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-10-9 11:49 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | 12 | IP=`ifconfig| grep Bcast:|awk -F':' '{print $2}'|awk '{print $1}'` 13 | 14 | 15 | function welcome(){ 16 | #启动服务 17 | /etc/init.d/nginx start 18 | /etc/init.d/php-fpm start 19 | /etc/init.d/mysqld start 20 | chkconfig --add nginx 21 | chkconfig --add php-fpm 22 | chkconfig --add mysqld 23 | 24 | clear 25 | 26 | figlet install success 27 | 28 | 29 | echo -e "****" VERSION 30 | echo -e "*" 31 | echo -e "*" `Print_Color '32' "$1"` 32 | echo -e "*" `Print_Color '32' "$2"` 33 | echo -e "*" `Print_Color '32' "$3"` 34 | echo -e "*" 35 | echo -e "****" 根目录 36 | echo -e "*" 37 | echo -e "*" `Print_Color '32' '/home/www'` 38 | echo -e "*" 39 | echo -e "****" 启动/停止服务 40 | echo -e "*" 41 | echo -e "*" `Print_Color '32' '/etc/init.d/nginx start|stop|restart'` 42 | echo -e "*" `Print_Color '32' '/etc/init.d/php-fpm start|stop|restart'` 43 | echo -e "*" `Print_Color '32' '/etc/init.d/mysqld start|stop|restart'` 44 | echo -e "*" 45 | echo -e "****" 配置目录 46 | echo -e "*" 47 | echo -e "*" `Print_Color '32' "$SOFT_DIR/nginx/conf(vhost)"` 48 | echo -e "*" `Print_Color '32' "$SOFT_DIR/php/etc"` 49 | echo -e "*" `Print_Color '32' "$SOFT_DIR/mysql/etc"` 50 | echo -e "*" 51 | echo -e "****" 访问项目 52 | echo -e "*" 53 | echo -e "*" `Print_Color '32' "IP($IP):8080"` 54 | echo -e "*" 55 | echo -e "=================================================" 56 | echo -e "*" `Print_Color '32' ' START YOUR PROJECT'` 57 | echo -e "=================================================" 58 | } 59 | -------------------------------------------------------------------------------- /install/framework.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName main.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-10-11 10:07 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | source $BASE_DIR/install/thinkphp.sh 12 | source $BASE_DIR/install/yum.sh 13 | 14 | function Start_Install_Framework(){ 15 | THINKPHP_VER=$1 16 | PROJECT_NAME=$2 17 | case "$THINKPHP_VER" in 18 | 1) 19 | THINKPHP_VER=v5.0.24 20 | ;; 21 | 2) 22 | THINKPHP_VER=v5.1.29 23 | ;; 24 | 3) 25 | THINKPHP_VER=N 26 | ;; 27 | esac 28 | 29 | [[ $THINKPHP_VER != N ]] && Install_Thinkphp $THINKPHP_VER $PROJECT_NAME 30 | } 31 | 32 | function Install_Framework(){ 33 | 34 | clear 35 | #Start Select ThinkPHP Version 36 | echo -e "=================================================" 37 | echo -e "`Print_Color '32' 'Please Select ThinkPHP Version'`" 38 | echo -e "=================================================" 39 | THINKPHP_VER=1 40 | echo -e "1) `Print_Color '32' '5.0.24'`" 41 | echo -e "2) `Print_Color '32' '5.1.29'`" 42 | echo -e "3) `Print_Color '32' 'I Don not Want To Install ThinkPHP'`" 43 | read -p "Please Enter Your Choice(1/2) Default(1):" THINKPHP_VER 44 | [[ $THINKPHP_VER -lt 1 ]] || [[ $THINKPHP_VER -ge 3 ]] && THINKPHP_VER=1 45 | #End Select Thinkphp Ver 46 | clear 47 | #Start Select project name 48 | echo -e "=================================================" 49 | echo -e "`Print_Color '32' 'Please Insert Your Project Name '`" 50 | echo -e "=================================================" 51 | read -p "Please Enter Your Project Name (Ex:shop/blog) Default(lampol):" PROJECT_NAME 52 | [[ -z $PROJECT_NAME ]] && PROJECT_NAME=lampol 53 | #End Select php-memcache Ver 54 | 55 | clear 56 | 57 | echo -e "=================================================" 58 | echo -e "`Print_Color '32' 'Start Install Composer Please Hold On '`" 59 | echo -e "=================================================" 60 | Install_Composer 61 | 62 | Start_Install_Framework $THINKPHP_VER $PROJECT_NAME 63 | } 64 | -------------------------------------------------------------------------------- /init.d/nginx: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ================================================================= 4 | # FileName nginx.sh 5 | # Copyright (C) 2016 root 6 | # CreateTime 2016-11-28 10:25 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #================================================================== 11 | 12 | #======================REBOOT AUTOSTART============================ 13 | #chkconfig:2345 55 75 14 | #Description:This is nginx start stop reload script 15 | 16 | #====================Source Fucntions============================== 17 | 18 | . /etc/init.d/functions 19 | 20 | if [ $# -ne 1 ] 21 | then 22 | echo "Usage $0 {start|stop|reload}" 23 | exit 8 24 | fi 25 | 26 | 27 | PROG=nginx 28 | EXEC=/usr/local/nginx/sbin/$PROG 29 | PIDFILE=/var/run/$PROG.pid 30 | LOCKFILE=/var/lock/subsys/$PROG 31 | CONFFILE=/usr/local/nginx/conf/$PROG.conf 32 | 33 | function start(){ 34 | if netstat -nltp| grep -q $PROG 35 | then 36 | echo "$PROG(pid `pidof $PROG`) already running" 37 | exit 1 38 | else 39 | $EXEC -c $CONFFILE 40 | [ $? -eq 0 ] && touch $LOCKFILE 41 | action "Start $PROG SUCCESS" /bin/true 42 | fi 43 | } 44 | function stop(){ 45 | if netstat -nltp| grep -q $PROG 46 | then 47 | $EXEC -s stop 48 | [ $? -ne 0 ] && rm -f $PIDFILE && rm -f $LOCKFILE 49 | action "Stop $PROG SUCCESS" /bin/true 50 | else 51 | action "$PROG is not running" /bin/false 52 | 53 | fi 54 | 55 | } 56 | 57 | function reload(){ 58 | if netstat -nltp| grep -q $PROG 59 | then 60 | $EXEC -s reload 61 | action "Reload $PROG SUCCESS" /bin/true 62 | else 63 | action "$PROG is not running" /bin/false 64 | exit 3 65 | fi 66 | 67 | } 68 | 69 | case "$1" in 70 | start) 71 | start 72 | ;; 73 | stop) 74 | stop 75 | ;; 76 | restart) 77 | stop 78 | sleep 1 79 | start 80 | ;; 81 | reload) 82 | reload 83 | ;; 84 | *) 85 | echo "Usage $0 {start|stop|reload}" 86 | exit 5 87 | esac 88 | -------------------------------------------------------------------------------- /init.d/redis: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ================================================================= 4 | # FileName nginx.sh 5 | # Copyright (C) 2016 root 6 | # CreateTime 2016-11-28 10:25 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #================================================================== 11 | 12 | #======================REBOOT AUTOSTART============================ 13 | #chkconfig:2345 55 75 14 | #Description:This is nginx start stop reload script 15 | 16 | #====================Source Fucntions============================== 17 | 18 | . /etc/init.d/functions 19 | 20 | if [ $# -ne 1 ] 21 | then 22 | echo "Usage $0 {start|stop|reload}" 23 | exit 8 24 | fi 25 | 26 | PROG=redis-server 27 | EXEC=/usr/local/redis/bin/redis-server 28 | CLIEXEC=/usr/local/redis/bin/redis-cli 29 | PIDFILE=/var/run/redis.pid 30 | LOCKFILE=/var/lock/subsys/$PROG 31 | CONF="/usr/local/redis/etc/redis.conf" 32 | REDISPORT="6379" 33 | 34 | 35 | function start(){ 36 | if netstat -nltp| grep -q $PROG 37 | then 38 | echo "$PROG(pid `pidof $PROG`) already running" 39 | exit 1 40 | else 41 | $EXEC $CONF 42 | [ $? -eq 0 ] && touch $LOCKFILE 43 | action "Start $PROG SUCCESS" /bin/true 44 | fi 45 | } 46 | function stop(){ 47 | if netstat -nltp| grep -q $PROG 48 | then 49 | $CLIEXEC -p $REDISPORT shutdown 50 | [ $? -ne 0 ] && rm -f $PIDFILE && rm -f $LOCKFILE 51 | action "Stop $PROG SUCCESS" /bin/true 52 | else 53 | action "$PROG is not running" /bin/false 54 | 55 | fi 56 | 57 | } 58 | 59 | function reload(){ 60 | if netstat -nltp| grep -q $PROG 61 | then 62 | $EXEC -s reload 63 | action "Reload $PROG SUCCESS" /bin/true 64 | else 65 | action "$PROG is not running" /bin/false 66 | exit 3 67 | fi 68 | 69 | } 70 | 71 | case "$1" in 72 | start) 73 | start 74 | ;; 75 | stop) 76 | stop 77 | ;; 78 | restart) 79 | stop 80 | sleep 1 81 | start 82 | ;; 83 | reload) 84 | reload 85 | ;; 86 | *) 87 | echo "Usage $0 {start|stop|reload}" 88 | exit 5 89 | esac 90 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # 一键安装lnmp环境的脚本 2 | ### 系统版本 3 | 4 | >亲测 **Centos6 Centos7** 系统没有问题--- 5 | 6 | 7 | ------------ 8 | 9 | ### 可安装的软件版本 10 | 11 | ------------ 12 | 13 | #### nginx 14 | >1. nginx-1.8.1 15 | >2. nginx-1.10.3 16 | >3. nginx-1.11.10 17 | 18 | #### php 19 | >1. php-5.6.40 20 | >2. php-7.2.19 21 | >3. php-7.4.33 22 | >4. php-8.2.15 23 | 24 | #### MySQL 25 | >1. mysql-5.5.54 26 | >2. mysql-5.6.37 27 | 28 | #### ThinkPHP 29 | > ThinkPHP 5.0.22 30 | > ThinkPHP 5.1.29 31 | 32 | #### Memcached 服务端 33 | >1. memcached-1.5.2.tar.gz 34 | >2. memcached-1.4.39.tar.gz 35 | 36 | #### php-memcache 客户端 37 | >1. memcache-2.2.7.tgz 38 | 39 | #### Redis 服务端 40 | >1 redis-3.2.9.tar.gz 41 | >2 redis-4.0.1.tar.gz 42 | 43 | #### php-redis 客户端 44 | >1 redis-3.1.4.tgz 45 | >2 redis-2.2.8.tgz 46 | 47 | ### 安装教程 48 | #### 下载 49 | 50 | > git clone https://github.com/lampol/lnmp.git 51 | 52 | #### 开始安装 53 | 54 | ``` 55 | cd lnmp //下载到本地后进到目录里面 56 | chmod +x install.sh //给安装脚本赋执行的权限 57 | ./install.sh //开始执行安装 58 | 根据提示选择软件安装的版本。(注意要联网,如果出现错误可能是网络问题) 59 | ``` 60 | #### 使用 61 | #### 启动服务 62 | 63 | ``` 64 | /etc/init.d/nginx start //注意nginx的端口改成了8080 65 | /etc/init.d/php-fpm start 66 | /etc/init.d/mysql start 67 | ``` 68 | ### 注意!!! 69 | 70 | > 强烈建议安装完后修改MySQL的密码 默认为空 71 | 72 | #### 修改root密码 禁止远程root登录 73 | 74 | ``` 75 | cd lnmp/shell //进入到shell文件夹 76 | chmod +x mysql_secure_installation //给执行的权限 77 | ./mysql_secure_installation //按照提示一步一步操作 设置root密码 以及禁止root的远程登录 78 | 79 | ``` 80 | 81 | #### 检测启动 82 | ``` 83 | 运行这个命令 netstat -nltp 84 | 如果有8080 9000 3306 端口号 代表启动成功 85 | 86 | ``` 87 | #### 根目录 88 | > 项目的根目录在 /home/www 目录下面 89 | 90 | #### 访问 91 | IP/域名:8080 即可访问到根目录 92 | 如果访问不到请检测网络 或者关闭防火墙重试 93 | 94 | ## 安装php 框架 暂时只支持 ThinkPHP 5.0.22/5.1.29 95 | 96 | > 注意 安装框架前一定要先安装lnmp的环境 97 | > 已经配置好了nginx的配置 直接ip访问即可 98 | 99 | #### 开始安装 100 | 101 | ``` 102 | cd lnmp/shell 103 | chmod +x install_framework.sh 104 | ./install_framework.sh 105 | //剩下的按提示操作 106 | 107 | ``` 108 | 109 | ## 安装其他扩展 110 | 111 | ### 安装memcached redis 服务端 php-memcache php-redis客户端 112 | 113 | > memcache的服务端和客户端可以单独安装互不影响, 114 | > 注意php-memcache要求是要安装php,安装完前面的php才可以安装 115 | 116 | #### 安装教程 117 | 118 | ``` 119 | cd lnmp/shell 120 | chmod +x install_third_party.sh 121 | ./install_third_party.sh 122 | 然后选择 安装的软件和版本可以选择安装或者不安装 123 | 124 | ``` 125 | 126 | #### 启动服务 127 | 128 | 129 | ``` 130 | /etc/init.d/memcached start|stop|restart 131 | /etc/init.d/redis start|stop|restart 132 | 133 | ``` 134 | 135 | ## 有问题反馈 136 | 在使用中有任何问题,欢迎反馈给我,可以用以下联系方式跟我交流 137 | 138 | * QQ: 807968192 139 | * php/linux技术交流群:163656536 140 | * 腾讯课堂: (https://ke.qq.com/course/list/lampol) 141 | 142 | ## 常见问题及解决 143 | * 如果出现安装错误,可以重试,特别是下载软件的时候,网络不好可能会出错误 144 | * 如果不能访问,请关闭防火墙重试 145 | 146 | #### 声明 147 | > 欢迎大家提出建设性的意见或者建议。 148 | -------------------------------------------------------------------------------- /install/main.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName main.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-02-17 10:07 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | source $BASE_DIR/install/yum.sh 12 | source $BASE_DIR/install/nginx.sh 13 | source $BASE_DIR/install/php.sh 14 | source $BASE_DIR/install/mysql.sh 15 | source $BASE_DIR/install/welcome.sh 16 | source $BASE_DIR/install/cmake.sh 17 | source $BASE_DIR/install/libzip.sh 18 | 19 | function Start_Install(){ 20 | NGINX_VER=$1 21 | MySQL_VER=$3 22 | PHP_VER=$2 23 | case "$NGINX_VER" in 24 | 1) 25 | NGINX_VER=nginx-1.8.1.tar.gz 26 | ;; 27 | 2) 28 | NGINX_VER=nginx-1.10.3.tar.gz 29 | ;; 30 | 3) 31 | NGINX_VER=nginx-1.11.10.tar.gz 32 | ;; 33 | esac 34 | case "$PHP_VER" in 35 | 1) 36 | PHP_VER="php-5.6.40.tar.gz" 37 | ;; 38 | 2) 39 | PHP_VER="php-7.2.19.tar.gz" 40 | ;; 41 | 3) 42 | PHP_VER="php-7.4.33.tar.gz" 43 | ;; 44 | 4) 45 | PHP_VER="php-8.2.15.tar.gz" 46 | ;; 47 | 5) 48 | PHP_VER="php-7.3.6.tar.gz" 49 | ;; 50 | esac 51 | 52 | case "$MySQL_VER" in 53 | 1) 54 | MySQL_VER="mysql-5.5.54.tar.gz" 55 | VER="5.5" 56 | ;; 57 | 2) 58 | MySQL_VER="mysql-5.6.37.tar.gz" 59 | VER="5.6" 60 | ;; 61 | # 3) 62 | # MySQL_VER="mysql-5.7.17.tar.gz" 63 | # VER="5.7" 64 | # ;; 65 | esac 66 | # YUM_COUNT=`rpm -aq| grep -e cmake -e libpng-devel -e ncurses-devel -e openssl-devel|wc -l` 67 | # [[ $YUM_COUNT -lt 4 ]] && Yum_Install 68 | Install_Nginx $NGINX_VER 69 | if [ "$PHP_VER" == php-7.4.33.tar.gz ] || [ "$PHP_VER" == php-8.2.15.tar.gz ] 70 | then 71 | yum remove -y cmake 72 | Install_Cmake 'cmake-3.20.6.tar.gz' 73 | Install_Libzip 74 | fi 75 | Install_Php $PHP_VER 76 | Install_Mysql $MySQL_VER $VER 77 | welcome $NGINX_VER $MySQL_VER $PHP_VER 78 | } 79 | 80 | function Init_Install(){ 81 | #check OS 82 | 83 | if [ "$2" != CentOS ] 84 | then 85 | clear 86 | echo -e " `Print_Color '31' 'NOW ONLY SUPPORT CentOS6 AND 7'`" 87 | exit 1 88 | fi 89 | 90 | clear 91 | #Start Select Nginx Ver 92 | echo -e "=================================================" 93 | echo -e "`Print_Color '32' 'Please Select Nginx Version'`" 94 | echo -e "=================================================" 95 | NGINX_VER=2 96 | echo -e "1) `Print_Color '32' 'nginx-1.8.1'`" 97 | echo -e "2) `Print_Color '32' 'nginx-1.10.3'`" 98 | echo -e "3) `Print_Color '32' 'nginx-1.11.10'`" 99 | read -p "Please Enter Your Nginx Choice(1-3) Default(2):" NGINX_VER 100 | [[ $NGINX_VER -lt 1 ]] || [[ $NGINX_VER -ge 4 ]] && NGINX_VER=2 101 | #End Select Nginx Ver 102 | clear 103 | #Start Select PHP Ver 104 | echo -e "=================================================" 105 | echo -e "`Print_Color '32' 'Please Select PHP Version '`" 106 | echo -e "=================================================" 107 | PHP_VER=2 108 | echo -e "1) `Print_Color '32' 'php-5.6.40'`" 109 | echo -e "2) `Print_Color '32' 'php-7.2.19'`" 110 | echo -e "3) `Print_Color '32' 'php-7.4.33'`" 111 | echo -e "4) `Print_Color '32' 'php-8.2.15'`" 112 | read -p "Please Enter Your PHP Choice(1-7) Default(2):" PHP_VER 113 | [[ $PHP_VER -lt 1 ]] || [[ $PHP_VER -ge 6 ]] && PHP_VER=2 114 | #End Select PHP Ver 115 | clear 116 | #Start Select MySQL Ver 117 | echo -e "=================================================" 118 | echo -e "`Print_Color '32' 'Please Select MySQL Version '`" 119 | echo -e "=================================================" 120 | MySQL_VER=2 121 | echo -e "1) `Print_Color '32' 'mysql-5.5.54'`" 122 | echo -e "2) `Print_Color '32' 'mysql-5.6.37'`" 123 | #echo -e "3) `Print_Color '32' 'mysql-5.7.17'`" 124 | read -p "Please Enter Your MySQL Choice(1-3) Default(2):" MySQL_VER 125 | [[ $MySQL_VER -lt 1 ]] || [[ $MySQL_VER -ge 4 ]] && MySQL_VER=2 126 | #End Select MySQL Ver 127 | 128 | # yum install 129 | Yum_Install_Tool 130 | YUM_COUNT=`rpm -aq| grep -e cmake -e libpng-devel -e ncurses-devel -e openssl-devel|wc -l` 131 | [[ $YUM_COUNT -lt 4 ]] && Yum_Install $1 132 | #install 133 | Start_Install $NGINX_VER $PHP_VER $MySQL_VER 134 | } 135 | -------------------------------------------------------------------------------- /install/third_main.sh: -------------------------------------------------------------------------------- 1 | #! /bin/sh 2 | 3 | # ============================================================ 4 | # FileName main.sh 5 | # Copyright (C) 2017 root 6 | # CreateTime 2017-10-11 10:07 7 | # Author Lampol 8 | # Email 807968192@qq.com 9 | # Distributed under terms of the MIT license. 10 | #============================================================= 11 | source $BASE_DIR/install/memcached.sh 12 | source $BASE_DIR/install/php_memcache.sh 13 | source $BASE_DIR/install/redis.sh 14 | source $BASE_DIR/install/php_redis.sh 15 | source $BASE_DIR/install/yum.sh 16 | 17 | function Start_Install_Third(){ 18 | MEMCACHED_VER=$1 19 | PHP_MEMCACHE_VER=$2 20 | REDIS_VER=$3 21 | PHP_REDIS_VER=$4 22 | 23 | case "$MEMCACHED_VER" in 24 | 1) 25 | MEMCACHED_VER=memcached-1.5.2.tar.gz 26 | ;; 27 | 2) 28 | MEMCACHED_VER=memcached-1.4.39.tar.gz 29 | ;; 30 | 3) 31 | MEMCACHED_VER=N 32 | ;; 33 | esac 34 | case "$PHP_MEMCACHE_VER" in 35 | 1) 36 | PHP_MEMCACHE_VER=memcache-2.2.7.tgz 37 | ;; 38 | 2) 39 | PHP_MEMCACHE_VER=N 40 | ;; 41 | esac 42 | case "$REDIS_VER" in 43 | 1) 44 | REDIS_VER=redis-3.2.9.tar.gz 45 | ;; 46 | 2) 47 | REDIS_VER=redis-4.0.1.tar.gz 48 | ;; 49 | 3) 50 | REDIS_VER=N 51 | ;; 52 | esac 53 | case "$PHP_REDIS_VER" in 54 | 1) 55 | PHP_REDIS_VER=redis-3.1.4.tgz 56 | ;; 57 | 2) 58 | PHP_REDIS_VER=redis-2.2.8.tgz 59 | ;; 60 | 3) 61 | PHP_REDIS_VER=N 62 | ;; 63 | esac 64 | 65 | [[ $MEMCACHED_VER != N ]] && Install_Memcached $MEMCACHED_VER 66 | [[ $PHP_MEMCACHE_VER != N ]] && Install_Php_Memcached $PHP_MEMCACHE_VER 67 | [[ $REDIS_VER != N ]] && Install_Redis $REDIS_VER 68 | [[ $PHP_REDIS_VER != N ]] && Install_Php_Redis $PHP_REDIS_VER 69 | } 70 | 71 | function Install_Third(){ 72 | 73 | 74 | clear 75 | #Start Select Memcached Ver 76 | echo -e "=================================================" 77 | echo -e "`Print_Color '32' 'Please Select memcached Version'`" 78 | echo -e "=================================================" 79 | MEMCACHED_VER=1 80 | echo -e "1) `Print_Color '32' 'memcached-1.5.2.tar.gz'`" 81 | echo -e "2) `Print_Color '32' 'memcached-1.4.39.tar.gz'`" 82 | echo -e "3) `Print_Color '32' 'I Don not Want To Install Memcached'`" 83 | read -p "Please Enter Your Memcached Choice(1/2/3) Default(1):" MEMCACHED_VER 84 | [[ $MEMCACHED_VER -lt 1 ]] || [[ $MEMCACHED_VER -ge 4 ]] && MEMCACHED_VER=1 85 | #End Select Memcached Ver 86 | clear 87 | #Start Select php-memcache Ver 88 | echo -e "=================================================" 89 | echo -e "`Print_Color '32' 'Please Select php-memcache Version '`" 90 | echo -e "=================================================" 91 | PHP_MEMCACHE_VER=1 92 | echo -e "1) `Print_Color '32' 'memcache-2.2.7.tgz'`" 93 | echo -e "2) `Print_Color '32' 'I Don not Want To Install php-memcache'`" 94 | read -p "Please Enter Your PHP-memcache Choice(1/2) Default(1):" PHP_MEMCACHE_VER 95 | [[ $PHP_MEMCACHE_VER -lt 1 ]] || [[ $PHP_MEMCACHE_VER -ge 3 ]] && PHP_MEMCACHE_VER=1 96 | #End Select php-memcache Ver 97 | clear 98 | #Start Select Redis Ver 99 | echo -e "=================================================" 100 | echo -e "`Print_Color '32' 'Please Select Redis Version '`" 101 | echo -e "=================================================" 102 | REDIS_VER=1 103 | echo -e "1) `Print_Color '32' 'redis-3.2.9.tar.gz'`" 104 | echo -e "2) `Print_Color '32' 'redis-4.0.1.tar.gz'`" 105 | echo -e "3) `Print_Color '32' 'I Don not Want To Install Redis'`" 106 | read -p "Please Enter Your Redis Choice(1/2/3) Default(1):" REDIS_VER 107 | [[ $REDIS_VER -lt 1 ]] || [[ $REDIS_VER -ge 4 ]] && REDIS_VER=1 108 | #End Select Redis Ver 109 | clear 110 | #Start Select php-Redis Ver 111 | echo -e "=================================================" 112 | echo -e "`Print_Color '32' 'Please Select php-Redis Version '`" 113 | echo -e "=================================================" 114 | PHP_REDIS_VER=1 115 | echo -e "1) `Print_Color '32' 'redis-3.1.4.tgz'`" 116 | echo -e "2) `Print_Color '32' 'redis-2.2.8.tgz'`" 117 | echo -e "3) `Print_Color '32' 'I Don not Want To Install php-Redis'`" 118 | read -p "Please Enter Your php-Redis Choice(1/2/3) Default(1):" PHP_REDIS_VER 119 | [[ $PHP_REDIS_VER -lt 1 ]] || [[ $PHP_REDIS_VER -ge 4 ]] && PHP_REDIS_VER=1 120 | #End Select php-Redis Ver 121 | 122 | 123 | Yum_Install_Tool 124 | Start_Install_Third $MEMCACHED_VER $PHP_MEMCACHE_VER $REDIS_VER $PHP_REDIS_VER 125 | } 126 | -------------------------------------------------------------------------------- /conf/my.cnf: -------------------------------------------------------------------------------- 1 | # Example MySQL config file for medium systems. 2 | # 3 | # This is for a system with little memory (32M - 64M) where MySQL plays 4 | # an important part, or systems up to 128M where MySQL is used together with 5 | # other programs (such as a web server) 6 | # 7 | # MySQL programs look for option files in a set of 8 | # locations which depend on the deployment platform. 9 | # You can copy this option file to one of those 10 | # locations. For information about these locations, see: 11 | # http://dev.mysql.com/doc/mysql/en/option-files.html 12 | # 13 | # In this file, you can use all long options that a program supports. 14 | # If you want to know which options a program supports, run the program 15 | # with the "--help" option. 16 | 17 | # The following options will be passed to all MySQL clients 18 | [client] 19 | #password = your_password 20 | port = 3306 21 | socket = /tmp/mysql.sock 22 | 23 | # Here follows entries for some specific programs 24 | 25 | # The MySQL server 26 | [mysqld] 27 | port = 3306 28 | socket = /tmp/mysql.sock 29 | skip-external-locking 30 | key_buffer_size = 16M 31 | max_allowed_packet = 1M 32 | table_open_cache = 64 33 | sort_buffer_size = 512K 34 | net_buffer_length = 8K 35 | read_buffer_size = 256K 36 | read_rnd_buffer_size = 512K 37 | myisam_sort_buffer_size = 8M 38 | bind-address=0.0.0.0 39 | 40 | # Don't listen on a TCP/IP port at all. This can be a security enhancement, 41 | # if all processes that need to connect to mysqld run on the same host. 42 | # All interaction with mysqld must be made via Unix sockets or named pipes. 43 | # Note that using this option without enabling named pipes on Windows 44 | # (via the "enable-named-pipe" option) will render mysqld useless! 45 | # 46 | #skip-networking 47 | 48 | # Replication Master Server (default) 49 | # binary logging is required for replication 50 | log-bin=mysql-bin 51 | 52 | # binary logging format - mixed recommended 53 | binlog_format=mixed 54 | 55 | # required unique id between 1 and 2^32 - 1 56 | # defaults to 1 if master-host is not set 57 | # but will not function as a master if omitted 58 | server-id = 1 59 | 60 | # Replication Slave (comment out master section to use this) 61 | # 62 | # To configure this host as a replication slave, you can choose between 63 | # two methods : 64 | # 65 | # 1) Use the CHANGE MASTER TO command (fully described in our manual) - 66 | # the syntax is: 67 | # 68 | # CHANGE MASTER TO MASTER_HOST=, MASTER_PORT=, 69 | # MASTER_USER=, MASTER_PASSWORD= ; 70 | # 71 | # where you replace , , by quoted strings and 72 | # by the master's port number (3306 by default). 73 | # 74 | # Example: 75 | # 76 | # CHANGE MASTER TO MASTER_HOST='125.564.12.1', MASTER_PORT=3306, 77 | # MASTER_USER='joe', MASTER_PASSWORD='secret'; 78 | # 79 | # OR 80 | # 81 | # 2) Set the variables below. However, in case you choose this method, then 82 | # start replication for the first time (even unsuccessfully, for example 83 | # if you mistyped the password in master-password and the slave fails to 84 | # connect), the slave will create a master.info file, and any later 85 | # change in this file to the variables' values below will be ignored and 86 | # overridden by the content of the master.info file, unless you shutdown 87 | # the slave server, delete master.info and restart the slaver server. 88 | # For that reason, you may want to leave the lines below untouched 89 | # (commented) and instead use CHANGE MASTER TO (see above) 90 | # 91 | # required unique id between 2 and 2^32 - 1 92 | # (and different from the master) 93 | # defaults to 2 if master-host is set 94 | # but will not function as a slave if omitted 95 | #server-id = 2 96 | # 97 | # The replication master for this slave - required 98 | #master-host = 99 | # 100 | # The username the slave will use for authentication when connecting 101 | # to the master - required 102 | #master-user = 103 | # 104 | # The password the slave will authenticate with when connecting to 105 | # the master - required 106 | #master-password = 107 | # 108 | # The port the master is listening on. 109 | # optional - defaults to 3306 110 | #master-port = 111 | # 112 | # binary logging - not required for slaves, but recommended 113 | #log-bin=mysql-bin 114 | 115 | # Uncomment the following if you are using InnoDB tables 116 | #innodb_data_home_dir = /usr/local/mysql/data 117 | #innodb_data_file_path = ibdata1:10M:autoextend 118 | #innodb_log_group_home_dir = /usr/local/mysql/data 119 | # You can set .._buffer_pool_size up to 50 - 80 % 120 | # of RAM but beware of setting memory usage too high 121 | innodb_buffer_pool_size = 1G 122 | #innodb_additional_mem_pool_size = 2M 123 | # Set .._log_file_size to 25 % of buffer pool size 124 | #innodb_log_file_size = 5M 125 | #innodb_log_buffer_size = 8M 126 | #innodb_flush_log_at_trx_commit = 1 127 | #innodb_lock_wait_timeout = 50 128 | 129 | [mysqldump] 130 | quick 131 | max_allowed_packet = 16M 132 | 133 | [mysql] 134 | no-auto-rehash 135 | # Remove the next comment character if you are not familiar with SQL 136 | #safe-updates 137 | 138 | [myisamchk] 139 | key_buffer_size = 20M 140 | sort_buffer_size = 20M 141 | read_buffer = 2M 142 | write_buffer = 2M 143 | 144 | [mysqlhotcopy] 145 | interactive-timeout 146 | -------------------------------------------------------------------------------- /conf/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 欢迎使用---lampol/lnmp 6 | 24 | 25 | 26 |
27 | 28 |

欢迎使用lampol/lnmp

29 |

在使用中有任何问题,欢迎反馈给我,可以用以下联系方式跟我交流

30 |
QQ: 807968192
31 |
php/linux技术交流群:163656536
32 |
头条号 : (IT圈的那些事儿)
33 | 34 | 35 |

36 |
37 | 38 | 192 |
193 |

更多源码:源码之家

194 |
195 | 196 | 197 | -------------------------------------------------------------------------------- /install/conf_redis.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright 2011 Dvir Volk . All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions are met: 7 | # 8 | # 1. Redistributions of source code must retain the above copyright notice, 9 | # this list of conditions and the following disclaimer. 10 | # 11 | # 2. Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the distribution. 14 | # 15 | # THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 16 | # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 17 | # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 18 | # EVENT SHALL Dvir Volk OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 19 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 20 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, 21 | # OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 22 | # LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 23 | # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 24 | # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | # 26 | ################################################################################ 27 | # 28 | # Interactive service installer for redis server 29 | # this generates a redis config file and an /etc/init.d script, and installs them 30 | # this scripts should be run as root 31 | 32 | die () { 33 | echo "ERROR: $1. Aborting!" 34 | exit 1 35 | } 36 | 37 | 38 | #Absolute path to this script 39 | #SCRIPT=$(readlink -f $0) 40 | #Absolute path this script is in 41 | SCRIPTPATH=$REDIS_UTILS 42 | 43 | #Initial defaults 44 | REDIS_PORT=6379 45 | REDIS_CONFIG_FILE=/usr/local/redis/etc/reids.conf 46 | REDIS_LOG_FILE="/usr/local/redis/log/redis.log" 47 | REDIS_DATA_DIR="/usr/local/redis/data" 48 | 49 | echo "Welcome to the redis service installer" 50 | echo "This script will help you easily set up a running redis server" 51 | echo 52 | 53 | #check for root user 54 | if [ "$(id -u)" -ne 0 ] ; then 55 | echo "You must run this script as root. Sorry!" 56 | exit 1 57 | fi 58 | 59 | 60 | _REDIS_EXECUTABLE=`command -v redis-server` 61 | if [ ! -x "$REDIS_EXECUTABLE" ] ; then 62 | REDIS_EXECUTABLE=$_REDIS_EXECUTABLE 63 | 64 | if [ ! -x "$REDIS_EXECUTABLE" ] ; then 65 | echo "Mmmmm... it seems like you don't have a redis executable. Did you run make install yet?" 66 | exit 1 67 | fi 68 | fi 69 | 70 | #check the default for redis cli 71 | CLI_EXEC=`command -v redis-cli` 72 | if [ -z "$CLI_EXEC" ] ; then 73 | CLI_EXEC=`dirname $REDIS_EXECUTABLE`"/redis-cli" 74 | fi 75 | 76 | echo "Selected config:" 77 | 78 | echo "Port : $REDIS_PORT" 79 | echo "Config file : $REDIS_CONFIG_FILE" 80 | echo "Log file : $REDIS_LOG_FILE" 81 | echo "Data dir : $REDIS_DATA_DIR" 82 | echo "Executable : $REDIS_EXECUTABLE" 83 | echo "Cli Executable : $CLI_EXEC" 84 | 85 | 86 | mkdir -p `dirname "$REDIS_CONFIG_FILE"` || die "Could not create redis config directory" 87 | mkdir -p `dirname "$REDIS_LOG_FILE"` || die "Could not create redis log dir" 88 | mkdir -p "$REDIS_DATA_DIR" || die "Could not create redis data directory" 89 | 90 | #render the templates 91 | TMP_FILE="/tmp/${REDIS_PORT}.conf" 92 | DEFAULT_CONFIG="${SCRIPTPATH}/../redis.conf" 93 | INIT_TPL_FILE="${SCRIPTPATH}/redis_init_script.tpl" 94 | INIT_SCRIPT_DEST="/etc/init.d/redis_${REDIS_PORT}" 95 | PIDFILE="/var/run/redis_${REDIS_PORT}.pid" 96 | 97 | if [ ! -f "$DEFAULT_CONFIG" ]; then 98 | echo "Mmmmm... the default config is missing. Did you switch to the utils directory?" 99 | exit 1 100 | fi 101 | 102 | #Generate config file from the default config file as template 103 | #changing only the stuff we're controlling from this script 104 | echo "## Generated by install_server.sh ##" > $TMP_FILE 105 | 106 | read -r SED_EXPR <<-EOF 107 | s#^port [0-9]{4}\$#port ${REDIS_PORT}#; \ 108 | s#^logfile .+\$#logfile ${REDIS_LOG_FILE}#; \ 109 | s#^dir .+\$#dir ${REDIS_DATA_DIR}#; \ 110 | s#^pidfile .+\$#pidfile ${PIDFILE}#; \ 111 | s#^daemonize no\$#daemonize yes#; 112 | EOF 113 | sed -r "$SED_EXPR" $DEFAULT_CONFIG >> $TMP_FILE 114 | 115 | #cat $TPL_FILE | while read line; do eval "echo \"$line\"" >> $TMP_FILE; done 116 | cp $TMP_FILE $REDIS_CONFIG_FILE || die "Could not write redis config file $REDIS_CONFIG_FILE" 117 | 118 | #Generate sample script from template file 119 | rm -f $TMP_FILE 120 | 121 | #we hard code the configs here to avoid issues with templates containing env vars 122 | #kinda lame but works! 123 | REDIS_INIT_HEADER=\ 124 | "#!/bin/sh\n 125 | #Configurations injected by install_server below....\n\n 126 | EXEC=$REDIS_EXECUTABLE\n 127 | CLIEXEC=$CLI_EXEC\n 128 | PIDFILE=\"$PIDFILE\"\n 129 | CONF=\"$REDIS_CONFIG_FILE\"\n\n 130 | REDISPORT=\"$REDIS_PORT\"\n\n 131 | ###############\n\n" 132 | 133 | REDIS_CHKCONFIG_INFO=\ 134 | "# REDHAT chkconfig header\n\n 135 | # chkconfig: - 58 74\n 136 | # description: redis_${REDIS_PORT} is the redis daemon.\n 137 | ### BEGIN INIT INFO\n 138 | # Provides: redis_6379\n 139 | # Required-Start: \$network \$local_fs \$remote_fs\n 140 | # Required-Stop: \$network \$local_fs \$remote_fs\n 141 | # Default-Start: 2 3 4 5\n 142 | # Default-Stop: 0 1 6\n 143 | # Should-Start: \$syslog \$named\n 144 | # Should-Stop: \$syslog \$named\n 145 | # Short-Description: start and stop redis_${REDIS_PORT}\n 146 | # Description: Redis daemon\n 147 | ### END INIT INFO\n\n" 148 | 149 | if command -v chkconfig >/dev/null; then 150 | #if we're a box with chkconfig on it we want to include info for chkconfig 151 | echo "$REDIS_INIT_HEADER" "$REDIS_CHKCONFIG_INFO" > $TMP_FILE && cat $INIT_TPL_FILE >> $TMP_FILE || die "Could not write init script to $TMP_FILE" 152 | else 153 | #combine the header and the template (which is actually a static footer) 154 | echo "$REDIS_INIT_HEADER" > $TMP_FILE && cat $INIT_TPL_FILE >> $TMP_FILE || die "Could not write init script to $TMP_FILE" 155 | fi 156 | 157 | ### 158 | # Generate sample script from template file 159 | # - No need to check which system we are on. The init info are comments and 160 | # do not interfere with update_rc.d systems. Additionally: 161 | # Ubuntu/debian by default does not come with chkconfig, but does issue a 162 | # warning if init info is not available. 163 | 164 | cat > ${TMP_FILE} <> ${TMP_FILE} 191 | 192 | #copy to /etc/init.d 193 | cp $TMP_FILE $INIT_SCRIPT_DEST && \ 194 | chmod +x $INIT_SCRIPT_DEST || die "Could not copy redis init script to $INIT_SCRIPT_DEST" 195 | echo "Copied $TMP_FILE => $INIT_SCRIPT_DEST" 196 | 197 | #Install the service 198 | echo "Installing service..." 199 | if command -v chkconfig >/dev/null 2>&1; then 200 | # we're chkconfig, so lets add to chkconfig and put in runlevel 345 201 | chkconfig --add redis_${REDIS_PORT} && echo "Successfully added to chkconfig!" 202 | chkconfig --level 345 redis_${REDIS_PORT} on && echo "Successfully added to runlevels 345!" 203 | elif command -v update-rc.d >/dev/null 2>&1; then 204 | #if we're not a chkconfig box assume we're able to use update-rc.d 205 | update-rc.d redis_${REDIS_PORT} defaults && echo "Success!" 206 | else 207 | echo "No supported init tool found." 208 | fi 209 | 210 | /etc/init.d/redis_$REDIS_PORT start || die "Failed starting service..." 211 | 212 | #tada 213 | echo "Installation successful!" 214 | exit 0 215 | -------------------------------------------------------------------------------- /shell/mysql_secure_installation: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved. 4 | # 5 | # This program is free software; you can redistribute it and/or modify 6 | # it under the terms of the GNU General Public License as published by 7 | # the Free Software Foundation; version 2 of the License. 8 | # 9 | # This program is distributed in the hope that it will be useful, 10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # GNU General Public License for more details. 13 | # 14 | # You should have received a copy of the GNU General Public License 15 | # along with this program; if not, write to the Free Software 16 | # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17 | 18 | config=".my.cnf.$$" 19 | command=".mysql.$$" 20 | mysql_client="" 21 | 22 | trap "interrupt" 1 2 3 6 15 23 | 24 | rootpass="" 25 | echo_n= 26 | echo_c= 27 | 28 | set_echo_compat() { 29 | case `echo "testing\c"`,`echo -n testing` in 30 | *c*,-n*) echo_n= echo_c= ;; 31 | *c*,*) echo_n=-n echo_c= ;; 32 | *) echo_n= echo_c='\c' ;; 33 | esac 34 | } 35 | 36 | prepare() { 37 | touch $config $command 38 | chmod 600 $config $command 39 | } 40 | 41 | find_mysql_client() 42 | { 43 | for n in ./bin/mysql mysql 44 | do 45 | $n --no-defaults --help > /dev/null 2>&1 46 | status=$? 47 | if test $status -eq 0 48 | then 49 | mysql_client=$n 50 | return 51 | fi 52 | done 53 | echo "Can't find a 'mysql' client in PATH or ./bin" 54 | exit 1 55 | } 56 | 57 | do_query() { 58 | echo "$1" >$command 59 | #sed 's,^,> ,' < $command # Debugging 60 | $mysql_client --defaults-file=$config <$command 61 | return $? 62 | } 63 | 64 | # Simple escape mechanism (\-escape any ' and \), suitable for two contexts: 65 | # - single-quoted SQL strings 66 | # - single-quoted option values on the right hand side of = in my.cnf 67 | # 68 | # These two contexts don't handle escapes identically. SQL strings allow 69 | # quoting any character (\C => C, for any C), but my.cnf parsing allows 70 | # quoting only \, ' or ". For example, password='a\b' quotes a 3-character 71 | # string in my.cnf, but a 2-character string in SQL. 72 | # 73 | # This simple escape works correctly in both places. 74 | basic_single_escape () { 75 | # The quoting on this sed command is a bit complex. Single-quoted strings 76 | # don't allow *any* escape mechanism, so they cannot contain a single 77 | # quote. The string sed gets (as argv[1]) is: s/\(['\]\)/\\\1/g 78 | # 79 | # Inside a character class, \ and ' are not special, so the ['\] character 80 | # class is balanced and contains two characters. 81 | echo "$1" | sed 's/\(['"'"'\]\)/\\\1/g' 82 | } 83 | 84 | make_config() { 85 | echo "# mysql_secure_installation config file" >$config 86 | echo "[mysql]" >>$config 87 | echo "user=root" >>$config 88 | esc_pass=`basic_single_escape "$rootpass"` 89 | echo "password='$esc_pass'" >>$config 90 | #sed 's,^,> ,' < $config # Debugging 91 | } 92 | 93 | get_root_password() { 94 | status=1 95 | while [ $status -eq 1 ]; do 96 | stty -echo 97 | echo $echo_n "Enter current password for root (enter for none): $echo_c" 98 | read password 99 | echo 100 | stty echo 101 | if [ "x$password" = "x" ]; then 102 | hadpass=0 103 | else 104 | hadpass=1 105 | fi 106 | rootpass=$password 107 | make_config 108 | do_query "" 109 | status=$? 110 | done 111 | echo "OK, successfully used password, moving on..." 112 | echo 113 | } 114 | 115 | set_root_password() { 116 | stty -echo 117 | echo $echo_n "New password: $echo_c" 118 | read password1 119 | echo 120 | echo $echo_n "Re-enter new password: $echo_c" 121 | read password2 122 | echo 123 | stty echo 124 | 125 | if [ "$password1" != "$password2" ]; then 126 | echo "Sorry, passwords do not match." 127 | echo 128 | return 1 129 | fi 130 | 131 | if [ "$password1" = "" ]; then 132 | echo "Sorry, you can't use an empty password here." 133 | echo 134 | return 1 135 | fi 136 | 137 | esc_pass=`basic_single_escape "$password1"` 138 | do_query "UPDATE mysql.user SET Password=PASSWORD('$esc_pass') WHERE User='root';" 139 | if [ $? -eq 0 ]; then 140 | echo "Password updated successfully!" 141 | echo "Reloading privilege tables.." 142 | reload_privilege_tables 143 | if [ $? -eq 1 ]; then 144 | clean_and_exit 145 | fi 146 | echo 147 | rootpass=$password1 148 | make_config 149 | else 150 | echo "Password update failed!" 151 | clean_and_exit 152 | fi 153 | 154 | return 0 155 | } 156 | 157 | remove_anonymous_users() { 158 | do_query "DELETE FROM mysql.user WHERE User='';" 159 | if [ $? -eq 0 ]; then 160 | echo " ... Success!" 161 | else 162 | echo " ... Failed!" 163 | clean_and_exit 164 | fi 165 | 166 | return 0 167 | } 168 | 169 | remove_remote_root() { 170 | do_query "DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');" 171 | if [ $? -eq 0 ]; then 172 | echo " ... Success!" 173 | else 174 | echo " ... Failed!" 175 | fi 176 | } 177 | 178 | remove_test_database() { 179 | echo " - Dropping test database..." 180 | do_query "DROP DATABASE test;" 181 | if [ $? -eq 0 ]; then 182 | echo " ... Success!" 183 | else 184 | echo " ... Failed! Not critical, keep moving..." 185 | fi 186 | 187 | echo " - Removing privileges on test database..." 188 | do_query "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'" 189 | if [ $? -eq 0 ]; then 190 | echo " ... Success!" 191 | else 192 | echo " ... Failed! Not critical, keep moving..." 193 | fi 194 | 195 | return 0 196 | } 197 | 198 | reload_privilege_tables() { 199 | do_query "FLUSH PRIVILEGES;" 200 | if [ $? -eq 0 ]; then 201 | echo " ... Success!" 202 | return 0 203 | else 204 | echo " ... Failed!" 205 | return 1 206 | fi 207 | } 208 | 209 | interrupt() { 210 | echo 211 | echo "Aborting!" 212 | echo 213 | cleanup 214 | stty echo 215 | exit 1 216 | } 217 | 218 | cleanup() { 219 | echo "Cleaning up..." 220 | rm -f $config $command 221 | } 222 | 223 | # Remove the files before exiting. 224 | clean_and_exit() { 225 | cleanup 226 | exit 1 227 | } 228 | 229 | # The actual script starts here 230 | 231 | prepare 232 | find_mysql_client 233 | set_echo_compat 234 | 235 | echo 236 | echo 237 | echo 238 | echo 239 | echo "NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL" 240 | echo " SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!" 241 | echo 242 | echo 243 | 244 | echo "In order to log into MySQL to secure it, we'll need the current" 245 | echo "password for the root user. If you've just installed MySQL, and" 246 | echo "you haven't set the root password yet, the password will be blank," 247 | echo "so you should just press enter here." 248 | echo 249 | 250 | get_root_password 251 | 252 | 253 | # 254 | # Set the root password 255 | # 256 | 257 | echo "Setting the root password ensures that nobody can log into the MySQL" 258 | echo "root user without the proper authorisation." 259 | echo 260 | 261 | if [ $hadpass -eq 0 ]; then 262 | echo $echo_n "Set root password? [Y/n] $echo_c" 263 | else 264 | echo "You already have a root password set, so you can safely answer 'n'." 265 | echo 266 | echo $echo_n "Change the root password? [Y/n] $echo_c" 267 | fi 268 | 269 | read reply 270 | if [ "$reply" = "n" ]; then 271 | echo " ... skipping." 272 | else 273 | status=1 274 | while [ $status -eq 1 ]; do 275 | set_root_password 276 | status=$? 277 | done 278 | fi 279 | echo 280 | 281 | 282 | # 283 | # Remove anonymous users 284 | # 285 | 286 | echo "By default, a MySQL installation has an anonymous user, allowing anyone" 287 | echo "to log into MySQL without having to have a user account created for" 288 | echo "them. This is intended only for testing, and to make the installation" 289 | echo "go a bit smoother. You should remove them before moving into a" 290 | echo "production environment." 291 | echo 292 | 293 | echo $echo_n "Remove anonymous users? [Y/n] $echo_c" 294 | 295 | read reply 296 | if [ "$reply" = "n" ]; then 297 | echo " ... skipping." 298 | else 299 | remove_anonymous_users 300 | fi 301 | echo 302 | 303 | 304 | # 305 | # Disallow remote root login 306 | # 307 | 308 | echo "Normally, root should only be allowed to connect from 'localhost'. This" 309 | echo "ensures that someone cannot guess at the root password from the network." 310 | echo 311 | 312 | echo $echo_n "Disallow root login remotely? [Y/n] $echo_c" 313 | read reply 314 | if [ "$reply" = "n" ]; then 315 | echo " ... skipping." 316 | else 317 | remove_remote_root 318 | fi 319 | echo 320 | 321 | 322 | # 323 | # Remove test database 324 | # 325 | 326 | echo "By default, MySQL comes with a database named 'test' that anyone can" 327 | echo "access. This is also intended only for testing, and should be removed" 328 | echo "before moving into a production environment." 329 | echo 330 | 331 | echo $echo_n "Remove test database and access to it? [Y/n] $echo_c" 332 | read reply 333 | if [ "$reply" = "n" ]; then 334 | echo " ... skipping." 335 | else 336 | remove_test_database 337 | fi 338 | echo 339 | 340 | 341 | # 342 | # Reload privilege tables 343 | # 344 | 345 | echo "Reloading the privilege tables will ensure that all changes made so far" 346 | echo "will take effect immediately." 347 | echo 348 | 349 | echo $echo_n "Reload privilege tables now? [Y/n] $echo_c" 350 | read reply 351 | if [ "$reply" = "n" ]; then 352 | echo " ... skipping." 353 | else 354 | reload_privilege_tables 355 | fi 356 | echo 357 | 358 | cleanup 359 | 360 | echo 361 | echo 362 | echo 363 | echo "All done! If you've completed all of the above steps, your MySQL" 364 | echo "installation should now be secure." 365 | echo 366 | echo "Thanks for using MySQL!" 367 | echo 368 | echo 369 | 370 | 371 | -------------------------------------------------------------------------------- /init.d/mysqld: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Copyright Abandoned 1996 TCX DataKonsult AB & Monty Program KB & Detron HB 3 | # This file is public domain and comes with NO WARRANTY of any kind 4 | 5 | # MySQL daemon start/stop script. 6 | 7 | # Usually this is put in /etc/init.d (at least on machines SYSV R4 based 8 | # systems) and linked to /etc/rc3.d/S99mysql and /etc/rc0.d/K01mysql. 9 | # When this is done the mysql server will be started when the machine is 10 | # started and shut down when the systems goes down. 11 | 12 | # Comments to support chkconfig on RedHat Linux 13 | # chkconfig: 2345 50 80 14 | # description: A very fast and reliable SQL database engine. 15 | 16 | # Comments to support LSB init script conventions 17 | ### BEGIN INIT INFO 18 | # Provides: mysql 19 | # Required-Start: $local_fs $network $remote_fs 20 | # Should-Start: ypbind nscd ldap ntpd xntpd 21 | # Required-Stop: $local_fs $network $remote_fs 22 | # Default-Start: 2 3 4 5 23 | # Default-Stop: 0 1 6 24 | # Short-Description: start and stop MySQL 25 | # Description: MySQL is a very fast and reliable SQL database engine. 26 | ### END INIT INFO 27 | 28 | # If you install MySQL on some other places than /usr/local/mysql, then you 29 | # have to do one of the following things for this script to work: 30 | # 31 | # - Run this script from within the MySQL installation directory 32 | # - Create a /etc/my.cnf file with the following information: 33 | # [mysqld] 34 | # basedir= 35 | # - Add the above to any other configuration file (for example ~/.my.ini) 36 | # and copy my_print_defaults to /usr/bin 37 | # - Add the path to the mysql-installation-directory to the basedir variable 38 | # below. 39 | # 40 | # If you want to affect other MySQL variables, you should make your changes 41 | # in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files. 42 | 43 | # If you change base dir, you must also change datadir. These may get 44 | # overwritten by settings in the MySQL configuration files. 45 | 46 | basedir= 47 | datadir= 48 | 49 | # Default value, in seconds, afterwhich the script should timeout waiting 50 | # for server start. 51 | # Value here is overriden by value in my.cnf. 52 | # 0 means don't wait at all 53 | # Negative numbers mean to wait indefinitely 54 | service_startup_timeout=900 55 | 56 | # Lock directory for RedHat / SuSE. 57 | lockdir='/var/lock/subsys' 58 | lock_file_path="$lockdir/mysql" 59 | 60 | # The following variables are only set for letting mysql.server find things. 61 | 62 | # Set some defaults 63 | mysqld_pid_file_path= 64 | if test -z "$basedir" 65 | then 66 | basedir=/usr/local/mysql 67 | bindir=/usr/local/mysql/bin 68 | if test -z "$datadir" 69 | then 70 | datadir=/usr/local/mysql/data 71 | fi 72 | sbindir=/usr/local/mysql/bin 73 | libexecdir=/usr/local/mysql/bin 74 | else 75 | bindir="$basedir/bin" 76 | if test -z "$datadir" 77 | then 78 | datadir="$basedir/data" 79 | fi 80 | sbindir="$basedir/sbin" 81 | libexecdir="$basedir/libexec" 82 | fi 83 | 84 | # datadir_set is used to determine if datadir was set (and so should be 85 | # *not* set inside of the --basedir= handler.) 86 | datadir_set= 87 | 88 | # 89 | # Use LSB init script functions for printing messages, if possible 90 | # 91 | lsb_functions="/lib/lsb/init-functions" 92 | if test -f $lsb_functions ; then 93 | . $lsb_functions 94 | else 95 | log_success_msg() 96 | { 97 | echo " SUCCESS! $@" 98 | } 99 | log_failure_msg() 100 | { 101 | echo " ERROR! $@" 102 | } 103 | fi 104 | 105 | PATH="/sbin:/usr/sbin:/bin:/usr/bin:$basedir/bin" 106 | export PATH 107 | 108 | mode=$1 # start or stop 109 | 110 | [ $# -ge 1 ] && shift 111 | 112 | 113 | other_args="$*" # uncommon, but needed when called from an RPM upgrade action 114 | # Expected: "--skip-networking --skip-grant-tables" 115 | # They are not checked here, intentionally, as it is the resposibility 116 | # of the "spec" file author to give correct arguments only. 117 | 118 | case `echo "testing\c"`,`echo -n testing` in 119 | *c*,-n*) echo_n= echo_c= ;; 120 | *c*,*) echo_n=-n echo_c= ;; 121 | *) echo_n= echo_c='\c' ;; 122 | esac 123 | 124 | parse_server_arguments() { 125 | for arg do 126 | case "$arg" in 127 | --basedir=*) basedir=`echo "$arg" | sed -e 's/^[^=]*=//'` 128 | bindir="$basedir/bin" 129 | if test -z "$datadir_set"; then 130 | datadir="$basedir/data" 131 | fi 132 | sbindir="$basedir/sbin" 133 | libexecdir="$basedir/libexec" 134 | ;; 135 | --datadir=*) datadir=`echo "$arg" | sed -e 's/^[^=]*=//'` 136 | datadir_set=1 137 | ;; 138 | --pid-file=*) mysqld_pid_file_path=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; 139 | --service-startup-timeout=*) service_startup_timeout=`echo "$arg" | sed -e 's/^[^=]*=//'` ;; 140 | esac 141 | done 142 | } 143 | 144 | wait_for_pid () { 145 | verb="$1" # created | removed 146 | pid="$2" # process ID of the program operating on the pid-file 147 | pid_file_path="$3" # path to the PID file. 148 | 149 | i=0 150 | avoid_race_condition="by checking again" 151 | 152 | while test $i -ne $service_startup_timeout ; do 153 | 154 | case "$verb" in 155 | 'created') 156 | # wait for a PID-file to pop into existence. 157 | test -s "$pid_file_path" && i='' && break 158 | ;; 159 | 'removed') 160 | # wait for this PID-file to disappear 161 | test ! -s "$pid_file_path" && i='' && break 162 | ;; 163 | *) 164 | echo "wait_for_pid () usage: wait_for_pid created|removed pid pid_file_path" 165 | exit 1 166 | ;; 167 | esac 168 | 169 | # if server isn't running, then pid-file will never be updated 170 | if test -n "$pid"; then 171 | if kill -0 "$pid" 2>/dev/null; then 172 | : # the server still runs 173 | else 174 | # The server may have exited between the last pid-file check and now. 175 | if test -n "$avoid_race_condition"; then 176 | avoid_race_condition="" 177 | continue # Check again. 178 | fi 179 | 180 | # there's nothing that will affect the file. 181 | log_failure_msg "The server quit without updating PID file ($pid_file_path)." 182 | return 1 # not waiting any more. 183 | fi 184 | fi 185 | 186 | echo $echo_n ".$echo_c" 187 | i=`expr $i + 1` 188 | sleep 1 189 | 190 | done 191 | 192 | if test -z "$i" ; then 193 | log_success_msg 194 | return 0 195 | else 196 | log_failure_msg 197 | return 1 198 | fi 199 | } 200 | 201 | # Get arguments from the my.cnf file, 202 | # the only group, which is read from now on is [mysqld] 203 | if test -x ./bin/my_print_defaults 204 | then 205 | print_defaults="./bin/my_print_defaults" 206 | elif test -x $bindir/my_print_defaults 207 | then 208 | print_defaults="$bindir/my_print_defaults" 209 | elif test -x $bindir/mysql_print_defaults 210 | then 211 | print_defaults="$bindir/mysql_print_defaults" 212 | else 213 | # Try to find basedir in /etc/my.cnf 214 | conf=/etc/my.cnf 215 | print_defaults= 216 | if test -r $conf 217 | then 218 | subpat='^[^=]*basedir[^=]*=\(.*\)$' 219 | dirs=`sed -e "/$subpat/!d" -e 's//\1/' $conf` 220 | for d in $dirs 221 | do 222 | d=`echo $d | sed -e 's/[ ]//g'` 223 | if test -x "$d/bin/my_print_defaults" 224 | then 225 | print_defaults="$d/bin/my_print_defaults" 226 | break 227 | fi 228 | if test -x "$d/bin/mysql_print_defaults" 229 | then 230 | print_defaults="$d/bin/mysql_print_defaults" 231 | break 232 | fi 233 | done 234 | fi 235 | 236 | # Hope it's in the PATH ... but I doubt it 237 | test -z "$print_defaults" && print_defaults="my_print_defaults" 238 | fi 239 | 240 | # 241 | # Read defaults file from 'basedir'. If there is no defaults file there 242 | # check if it's in the old (depricated) place (datadir) and read it from there 243 | # 244 | 245 | extra_args="" 246 | if test -r "$basedir/my.cnf" 247 | then 248 | extra_args="-e $basedir/my.cnf" 249 | else 250 | if test -r "$datadir/my.cnf" 251 | then 252 | extra_args="-e $datadir/my.cnf" 253 | fi 254 | fi 255 | 256 | parse_server_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server` 257 | 258 | # 259 | # Set pid file if not given 260 | # 261 | if test -z "$mysqld_pid_file_path" 262 | then 263 | mysqld_pid_file_path=$datadir/`hostname`.pid 264 | else 265 | case "$mysqld_pid_file_path" in 266 | /* ) ;; 267 | * ) mysqld_pid_file_path="$datadir/$mysqld_pid_file_path" ;; 268 | esac 269 | fi 270 | 271 | case "$mode" in 272 | 'start') 273 | # Start daemon 274 | 275 | # Safeguard (relative paths, core dumps..) 276 | cd $basedir 277 | 278 | echo $echo_n "Starting MySQL" 279 | if test -x $bindir/mysqld_safe 280 | then 281 | # Give extra arguments to mysqld with the my.cnf file. This script 282 | # may be overwritten at next upgrade. 283 | $bindir/mysqld_safe --datadir="$datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null & 284 | wait_for_pid created "$!" "$mysqld_pid_file_path"; return_value=$? 285 | 286 | # Make lock for RedHat / SuSE 287 | if test -w "$lockdir" 288 | then 289 | touch "$lock_file_path" 290 | fi 291 | 292 | exit $return_value 293 | else 294 | log_failure_msg "Couldn't find MySQL server ($bindir/mysqld_safe)" 295 | fi 296 | ;; 297 | 298 | 'stop') 299 | # Stop daemon. We use a signal here to avoid having to know the 300 | # root password. 301 | 302 | if test -s "$mysqld_pid_file_path" 303 | then 304 | mysqld_pid=`cat "$mysqld_pid_file_path"` 305 | 306 | if (kill -0 $mysqld_pid 2>/dev/null) 307 | then 308 | echo $echo_n "Shutting down MySQL" 309 | kill $mysqld_pid 310 | # mysqld should remove the pid file when it exits, so wait for it. 311 | wait_for_pid removed "$mysqld_pid" "$mysqld_pid_file_path"; return_value=$? 312 | else 313 | log_failure_msg "MySQL server process #$mysqld_pid is not running!" 314 | rm "$mysqld_pid_file_path" 315 | fi 316 | 317 | # Delete lock for RedHat / SuSE 318 | if test -f "$lock_file_path" 319 | then 320 | rm -f "$lock_file_path" 321 | fi 322 | exit $return_value 323 | else 324 | log_failure_msg "MySQL server PID file could not be found!" 325 | fi 326 | ;; 327 | 328 | 'restart') 329 | # Stop the service and regardless of whether it was 330 | # running or not, start it again. 331 | if $0 stop $other_args; then 332 | $0 start $other_args 333 | else 334 | log_failure_msg "Failed to stop running server, so refusing to try to start." 335 | exit 1 336 | fi 337 | ;; 338 | 339 | 'reload'|'force-reload') 340 | if test -s "$mysqld_pid_file_path" ; then 341 | read mysqld_pid < "$mysqld_pid_file_path" 342 | kill -HUP $mysqld_pid && log_success_msg "Reloading service MySQL" 343 | touch "$mysqld_pid_file_path" 344 | else 345 | log_failure_msg "MySQL PID file could not be found!" 346 | exit 1 347 | fi 348 | ;; 349 | 'status') 350 | # First, check to see if pid file exists 351 | if test -s "$mysqld_pid_file_path" ; then 352 | read mysqld_pid < "$mysqld_pid_file_path" 353 | if kill -0 $mysqld_pid 2>/dev/null ; then 354 | log_success_msg "MySQL running ($mysqld_pid)" 355 | exit 0 356 | else 357 | log_failure_msg "MySQL is not running, but PID file exists" 358 | exit 1 359 | fi 360 | else 361 | # Try to find appropriate mysqld process 362 | mysqld_pid=`pidof $libexecdir/mysqld` 363 | 364 | # test if multiple pids exist 365 | pid_count=`echo $mysqld_pid | wc -w` 366 | if test $pid_count -gt 1 ; then 367 | log_failure_msg "Multiple MySQL running but PID file could not be found ($mysqld_pid)" 368 | exit 5 369 | elif test -z $mysqld_pid ; then 370 | if test -f "$lock_file_path" ; then 371 | log_failure_msg "MySQL is not running, but lock file ($lock_file_path) exists" 372 | exit 2 373 | fi 374 | log_failure_msg "MySQL is not running" 375 | exit 3 376 | else 377 | log_failure_msg "MySQL is running but PID file could not be found" 378 | exit 4 379 | fi 380 | fi 381 | ;; 382 | *) 383 | # usage 384 | basename=`basename "$0"` 385 | echo "Usage: $basename {start|stop|restart|reload|force-reload|status} [ MySQL server options ]" 386 | exit 1 387 | ;; 388 | esac 389 | 390 | exit 0 391 | -------------------------------------------------------------------------------- /conf/php-fpm.conf: -------------------------------------------------------------------------------- 1 | ;;;;;;;;;;;;;;;;;;;;; 2 | ; FPM Configuration ; 3 | ;;;;;;;;;;;;;;;;;;;;; 4 | 5 | ; All relative paths in this configuration file are relative to PHP's install 6 | ; prefix (/usr/local/php). This prefix can be dynamically changed by using the 7 | ; '-p' argument from the command line. 8 | 9 | ; Include one or more files. If glob(3) exists, it is used to include a bunch of 10 | ; files from a glob(3) pattern. This directive can be used everywhere in the 11 | ; file. 12 | ; Relative path can also be used. They will be prefixed by: 13 | ; - the global prefix if it's been set (-p argument) 14 | ; - /usr/local/php otherwise 15 | ;include=etc/fpm.d/*.conf 16 | 17 | ;;;;;;;;;;;;;;;;;; 18 | ; Global Options ; 19 | ;;;;;;;;;;;;;;;;;; 20 | 21 | [global] 22 | ; Pid file 23 | ; Note: the default prefix is /usr/local/php/var 24 | ; Default Value: none 25 | pid = /var/run/php-fpm.pid 26 | 27 | ; Error log file 28 | ; If it's set to "syslog", log is sent to syslogd instead of being written 29 | ; in a local file. 30 | ; Note: the default prefix is /usr/local/php/var 31 | ; Default Value: log/php-fpm.log 32 | ;error_log = log/php-fpm.log 33 | 34 | ; syslog_facility is used to specify what type of program is logging the 35 | ; message. This lets syslogd specify that messages from different facilities 36 | ; will be handled differently. 37 | ; See syslog(3) for possible values (ex daemon equiv LOG_DAEMON) 38 | ; Default Value: daemon 39 | ;syslog.facility = daemon 40 | 41 | ; syslog_ident is prepended to every message. If you have multiple FPM 42 | ; instances running on the same server, you can change the default value 43 | ; which must suit common needs. 44 | ; Default Value: php-fpm 45 | ;syslog.ident = php-fpm 46 | 47 | ; Log level 48 | ; Possible Values: alert, error, warning, notice, debug 49 | ; Default Value: notice 50 | ;log_level = notice 51 | 52 | ; If this number of child processes exit with SIGSEGV or SIGBUS within the time 53 | ; interval set by emergency_restart_interval then FPM will restart. A value 54 | ; of '0' means 'Off'. 55 | ; Default Value: 0 56 | ;emergency_restart_threshold = 0 57 | 58 | ; Interval of time used by emergency_restart_interval to determine when 59 | ; a graceful restart will be initiated. This can be useful to work around 60 | ; accidental corruptions in an accelerator's shared memory. 61 | ; Available Units: s(econds), m(inutes), h(ours), or d(ays) 62 | ; Default Unit: seconds 63 | ; Default Value: 0 64 | ;emergency_restart_interval = 0 65 | 66 | ; Time limit for child processes to wait for a reaction on signals from master. 67 | ; Available units: s(econds), m(inutes), h(ours), or d(ays) 68 | ; Default Unit: seconds 69 | ; Default Value: 0 70 | ;process_control_timeout = 0 71 | 72 | ; The maximum number of processes FPM will fork. This has been design to control 73 | ; the global number of processes when using dynamic PM within a lot of pools. 74 | ; Use it with caution. 75 | ; Note: A value of 0 indicates no limit 76 | ; Default Value: 0 77 | ; process.max = 128 78 | 79 | ; Specify the nice(2) priority to apply to the master process (only if set) 80 | ; The value can vary from -19 (highest priority) to 20 (lower priority) 81 | ; Note: - It will only work if the FPM master process is launched as root 82 | ; - The pool process will inherit the master process priority 83 | ; unless it specified otherwise 84 | ; Default Value: no set 85 | ; process.priority = -19 86 | 87 | ; Send FPM to background. Set to 'no' to keep FPM in foreground for debugging. 88 | ; Default Value: yes 89 | ;daemonize = yes 90 | 91 | ; Set open file descriptor rlimit for the master process. 92 | ; Default Value: system defined value 93 | ;rlimit_files = 1024 94 | 95 | ; Set max core size rlimit for the master process. 96 | ; Possible Values: 'unlimited' or an integer greater or equal to 0 97 | ; Default Value: system defined value 98 | ;rlimit_core = 0 99 | 100 | ; Specify the event mechanism FPM will use. The following is available: 101 | ; - select (any POSIX os) 102 | ; - poll (any POSIX os) 103 | ; - epoll (linux >= 2.5.44) 104 | ; - kqueue (FreeBSD >= 4.1, OpenBSD >= 2.9, NetBSD >= 2.0) 105 | ; - /dev/poll (Solaris >= 7) 106 | ; - port (Solaris >= 10) 107 | ; Default Value: not set (auto detection) 108 | ;events.mechanism = epoll 109 | 110 | ; When FPM is build with systemd integration, specify the interval, 111 | ; in second, between health report notification to systemd. 112 | ; Set to 0 to disable. 113 | ; Available Units: s(econds), m(inutes), h(ours) 114 | ; Default Unit: seconds 115 | ; Default value: 10 116 | ;systemd_interval = 10 117 | 118 | ;;;;;;;;;;;;;;;;;;;; 119 | ; Pool Definitions ; 120 | ;;;;;;;;;;;;;;;;;;;; 121 | 122 | ; Multiple pools of child processes may be started with different listening 123 | ; ports and different management options. The name of the pool will be 124 | ; used in logs and stats. There is no limitation on the number of pools which 125 | ; FPM can handle. Your system will tell you anyway :) 126 | 127 | ; Start a new pool named 'www'. 128 | ; the variable $pool can we used in any directive and will be replaced by the 129 | ; pool name ('www' here) 130 | [www] 131 | 132 | ; Per pool prefix 133 | ; It only applies on the following directives: 134 | ; - 'access.log' 135 | ; - 'slowlog' 136 | ; - 'listen' (unixsocket) 137 | ; - 'chroot' 138 | ; - 'chdir' 139 | ; - 'php_values' 140 | ; - 'php_admin_values' 141 | ; When not set, the global prefix (or /usr/local/php) applies instead. 142 | ; Note: This directive can also be relative to the global prefix. 143 | ; Default Value: none 144 | ;prefix = /path/to/pools/$pool 145 | 146 | ; Unix user/group of processes 147 | ; Note: The user is mandatory. If the group is not set, the default user's group 148 | ; will be used. 149 | user = www 150 | group = www 151 | 152 | ; The address on which to accept FastCGI requests. 153 | ; Valid syntaxes are: 154 | ; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific IPv4 address on 155 | ; a specific port; 156 | ; '[ip:6:addr:ess]:port' - to listen on a TCP socket to a specific IPv6 address on 157 | ; a specific port; 158 | ; 'port' - to listen on a TCP socket to all IPv4 addresses on a 159 | ; specific port; 160 | ; '[::]:port' - to listen on a TCP socket to all addresses 161 | ; (IPv6 and IPv4-mapped) on a specific port; 162 | ; '/path/to/unix/socket' - to listen on a unix socket. 163 | ; Note: This value is mandatory. 164 | listen = 127.0.0.1:9000 165 | 166 | ; Set listen(2) backlog. 167 | ; Default Value: 65535 (-1 on FreeBSD and OpenBSD) 168 | ;listen.backlog = 65535 169 | 170 | ; Set permissions for unix socket, if one is used. In Linux, read/write 171 | ; permissions must be set in order to allow connections from a web server. Many 172 | ; BSD-derived systems allow connections regardless of permissions. 173 | ; Default Values: user and group are set as the running user 174 | ; mode is set to 0660 175 | ;listen.owner = www 176 | ;listen.group = www 177 | ;listen.mode = 0660 178 | ; When POSIX Access Control Lists are supported you can set them using 179 | ; these options, value is a comma separated list of user/group names. 180 | ; When set, listen.owner and listen.group are ignored 181 | ;listen.acl_users = 182 | ;listen.acl_groups = 183 | 184 | ; List of addresses (IPv4/IPv6) of FastCGI clients which are allowed to connect. 185 | ; Equivalent to the FCGI_WEB_SERVER_ADDRS environment variable in the original 186 | ; PHP FCGI (5.2.2+). Makes sense only with a tcp listening socket. Each address 187 | ; must be separated by a comma. If this value is left blank, connections will be 188 | ; accepted from any ip address. 189 | ; Default Value: any 190 | ;listen.allowed_clients = 127.0.0.1 191 | 192 | ; Specify the nice(2) priority to apply to the pool processes (only if set) 193 | ; The value can vary from -19 (highest priority) to 20 (lower priority) 194 | ; Note: - It will only work if the FPM master process is launched as root 195 | ; - The pool processes will inherit the master process priority 196 | ; unless it specified otherwise 197 | ; Default Value: no set 198 | ; process.priority = -19 199 | 200 | ; Choose how the process manager will control the number of child processes. 201 | ; Possible Values: 202 | ; static - a fixed number (pm.max_children) of child processes; 203 | ; dynamic - the number of child processes are set dynamically based on the 204 | ; following directives. With this process management, there will be 205 | ; always at least 1 children. 206 | ; pm.max_children - the maximum number of children that can 207 | ; be alive at the same time. 208 | ; pm.start_servers - the number of children created on startup. 209 | ; pm.min_spare_servers - the minimum number of children in 'idle' 210 | ; state (waiting to process). If the number 211 | ; of 'idle' processes is less than this 212 | ; number then some children will be created. 213 | ; pm.max_spare_servers - the maximum number of children in 'idle' 214 | ; state (waiting to process). If the number 215 | ; of 'idle' processes is greater than this 216 | ; number then some children will be killed. 217 | ; ondemand - no children are created at startup. Children will be forked when 218 | ; new requests will connect. The following parameter are used: 219 | ; pm.max_children - the maximum number of children that 220 | ; can be alive at the same time. 221 | ; pm.process_idle_timeout - The number of seconds after which 222 | ; an idle process will be killed. 223 | ; Note: This value is mandatory. 224 | pm = dynamic 225 | 226 | ; The number of child processes to be created when pm is set to 'static' and the 227 | ; maximum number of child processes when pm is set to 'dynamic' or 'ondemand'. 228 | ; This value sets the limit on the number of simultaneous requests that will be 229 | ; served. Equivalent to the ApacheMaxClients directive with mpm_prefork. 230 | ; Equivalent to the PHP_FCGI_CHILDREN environment variable in the original PHP 231 | ; CGI. The below defaults are based on a server without much resources. Don't 232 | ; forget to tweak pm.* to fit your needs. 233 | ; Note: Used when pm is set to 'static', 'dynamic' or 'ondemand' 234 | ; Note: This value is mandatory. 235 | pm.max_children = 36 236 | 237 | ; The number of child processes created on startup. 238 | ; Note: Used only when pm is set to 'dynamic' 239 | ; Default Value: min_spare_servers + (max_spare_servers - min_spare_servers) / 2 240 | pm.start_servers = 20 241 | 242 | ; The desired minimum number of idle server processes. 243 | ; Note: Used only when pm is set to 'dynamic' 244 | ; Note: Mandatory when pm is set to 'dynamic' 245 | pm.min_spare_servers = 12 246 | 247 | ; The desired maximum number of idle server processes. 248 | ; Note: Used only when pm is set to 'dynamic' 249 | ; Note: Mandatory when pm is set to 'dynamic' 250 | pm.max_spare_servers = 24 251 | 252 | ; The number of seconds after which an idle process will be killed. 253 | ; Note: Used only when pm is set to 'ondemand' 254 | ; Default Value: 10s 255 | ;pm.process_idle_timeout = 10s; 256 | 257 | ; The number of requests each child process should execute before respawning. 258 | ; This can be useful to work around memory leaks in 3rd party libraries. For 259 | ; endless request processing specify '0'. Equivalent to PHP_FCGI_MAX_REQUESTS. 260 | ; Default Value: 0 261 | ;pm.max_requests = 500 262 | 263 | ; The URI to view the FPM status page. If this value is not set, no URI will be 264 | ; recognized as a status page. It shows the following informations: 265 | ; pool - the name of the pool; 266 | ; process manager - static, dynamic or ondemand; 267 | ; start time - the date and time FPM has started; 268 | ; start since - number of seconds since FPM has started; 269 | ; accepted conn - the number of request accepted by the pool; 270 | ; listen queue - the number of request in the queue of pending 271 | ; connections (see backlog in listen(2)); 272 | ; max listen queue - the maximum number of requests in the queue 273 | ; of pending connections since FPM has started; 274 | ; listen queue len - the size of the socket queue of pending connections; 275 | ; idle processes - the number of idle processes; 276 | ; active processes - the number of active processes; 277 | ; total processes - the number of idle + active processes; 278 | ; max active processes - the maximum number of active processes since FPM 279 | ; has started; 280 | ; max children reached - number of times, the process limit has been reached, 281 | ; when pm tries to start more children (works only for 282 | ; pm 'dynamic' and 'ondemand'); 283 | ; Value are updated in real time. 284 | ; Example output: 285 | ; pool: www 286 | ; process manager: static 287 | ; start time: 01/Jul/2011:17:53:49 +0200 288 | ; start since: 62636 289 | ; accepted conn: 190460 290 | ; listen queue: 0 291 | ; max listen queue: 1 292 | ; listen queue len: 42 293 | ; idle processes: 4 294 | ; active processes: 11 295 | ; total processes: 15 296 | ; max active processes: 12 297 | ; max children reached: 0 298 | ; 299 | ; By default the status page output is formatted as text/plain. Passing either 300 | ; 'html', 'xml' or 'json' in the query string will return the corresponding 301 | ; output syntax. Example: 302 | ; http://www.foo.bar/status 303 | ; http://www.foo.bar/status?json 304 | ; http://www.foo.bar/status?html 305 | ; http://www.foo.bar/status?xml 306 | ; 307 | ; By default the status page only outputs short status. Passing 'full' in the 308 | ; query string will also return status for each pool process. 309 | ; Example: 310 | ; http://www.foo.bar/status?full 311 | ; http://www.foo.bar/status?json&full 312 | ; http://www.foo.bar/status?html&full 313 | ; http://www.foo.bar/status?xml&full 314 | ; The Full status returns for each process: 315 | ; pid - the PID of the process; 316 | ; state - the state of the process (Idle, Running, ...); 317 | ; start time - the date and time the process has started; 318 | ; start since - the number of seconds since the process has started; 319 | ; requests - the number of requests the process has served; 320 | ; request duration - the duration in µs of the requests; 321 | ; request method - the request method (GET, POST, ...); 322 | ; request URI - the request URI with the query string; 323 | ; content length - the content length of the request (only with POST); 324 | ; user - the user (PHP_AUTH_USER) (or '-' if not set); 325 | ; script - the main script called (or '-' if not set); 326 | ; last request cpu - the %cpu the last request consumed 327 | ; it's always 0 if the process is not in Idle state 328 | ; because CPU calculation is done when the request 329 | ; processing has terminated; 330 | ; last request memory - the max amount of memory the last request consumed 331 | ; it's always 0 if the process is not in Idle state 332 | ; because memory calculation is done when the request 333 | ; processing has terminated; 334 | ; If the process is in Idle state, then informations are related to the 335 | ; last request the process has served. Otherwise informations are related to 336 | ; the current request being served. 337 | ; Example output: 338 | ; ************************ 339 | ; pid: 31330 340 | ; state: Running 341 | ; start time: 01/Jul/2011:17:53:49 +0200 342 | ; start since: 63087 343 | ; requests: 12808 344 | ; request duration: 1250261 345 | ; request method: GET 346 | ; request URI: /test_mem.php?N=10000 347 | ; content length: 0 348 | ; user: - 349 | ; script: /home/fat/web/docs/php/test_mem.php 350 | ; last request cpu: 0.00 351 | ; last request memory: 0 352 | ; 353 | ; Note: There is a real-time FPM status monitoring sample web page available 354 | ; It's available in: /usr/local/php/share/php/fpm/status.html 355 | ; 356 | ; Note: The value must start with a leading slash (/). The value can be 357 | ; anything, but it may not be a good idea to use the .php extension or it 358 | ; may conflict with a real PHP file. 359 | ; Default Value: not set 360 | ;pm.status_path = /status 361 | 362 | ; The ping URI to call the monitoring page of FPM. If this value is not set, no 363 | ; URI will be recognized as a ping page. This could be used to test from outside 364 | ; that FPM is alive and responding, or to 365 | ; - create a graph of FPM availability (rrd or such); 366 | ; - remove a server from a group if it is not responding (load balancing); 367 | ; - trigger alerts for the operating team (24/7). 368 | ; Note: The value must start with a leading slash (/). The value can be 369 | ; anything, but it may not be a good idea to use the .php extension or it 370 | ; may conflict with a real PHP file. 371 | ; Default Value: not set 372 | ;ping.path = /ping 373 | 374 | ; This directive may be used to customize the response of a ping request. The 375 | ; response is formatted as text/plain with a 200 response code. 376 | ; Default Value: pong 377 | ;ping.response = pong 378 | 379 | ; The access log file 380 | ; Default: not set 381 | ;access.log = log/$pool.access.log 382 | 383 | ; The access log format. 384 | ; The following syntax is allowed 385 | ; %%: the '%' character 386 | ; %C: %CPU used by the request 387 | ; it can accept the following format: 388 | ; - %{user}C for user CPU only 389 | ; - %{system}C for system CPU only 390 | ; - %{total}C for user + system CPU (default) 391 | ; %d: time taken to serve the request 392 | ; it can accept the following format: 393 | ; - %{seconds}d (default) 394 | ; - %{miliseconds}d 395 | ; - %{mili}d 396 | ; - %{microseconds}d 397 | ; - %{micro}d 398 | ; %e: an environment variable (same as $_ENV or $_SERVER) 399 | ; it must be associated with embraces to specify the name of the env 400 | ; variable. Some exemples: 401 | ; - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e 402 | ; - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e 403 | ; %f: script filename 404 | ; %l: content-length of the request (for POST request only) 405 | ; %m: request method 406 | ; %M: peak of memory allocated by PHP 407 | ; it can accept the following format: 408 | ; - %{bytes}M (default) 409 | ; - %{kilobytes}M 410 | ; - %{kilo}M 411 | ; - %{megabytes}M 412 | ; - %{mega}M 413 | ; %n: pool name 414 | ; %o: output header 415 | ; it must be associated with embraces to specify the name of the header: 416 | ; - %{Content-Type}o 417 | ; - %{X-Powered-By}o 418 | ; - %{Transfert-Encoding}o 419 | ; - .... 420 | ; %p: PID of the child that serviced the request 421 | ; %P: PID of the parent of the child that serviced the request 422 | ; %q: the query string 423 | ; %Q: the '?' character if query string exists 424 | ; %r: the request URI (without the query string, see %q and %Q) 425 | ; %R: remote IP address 426 | ; %s: status (response code) 427 | ; %t: server time the request was received 428 | ; it can accept a strftime(3) format: 429 | ; %d/%b/%Y:%H:%M:%S %z (default) 430 | ; %T: time the log has been written (the request has finished) 431 | ; it can accept a strftime(3) format: 432 | ; %d/%b/%Y:%H:%M:%S %z (default) 433 | ; %u: remote user 434 | ; 435 | ; Default: "%R - %u %t \"%m %r\" %s" 436 | ;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%" 437 | 438 | ; The log file for slow requests 439 | ; Default Value: not set 440 | ; Note: slowlog is mandatory if request_slowlog_timeout is set 441 | slowlog = /var/log/php-fpm.log.slow 442 | 443 | ; The timeout for serving a single request after which a PHP backtrace will be 444 | ; dumped to the 'slowlog' file. A value of '0s' means 'off'. 445 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 446 | ; Default Value: 0 447 | request_slowlog_timeout = 10 448 | 449 | ; The timeout for serving a single request after which the worker process will 450 | ; be killed. This option should be used when the 'max_execution_time' ini option 451 | ; does not stop script execution for some reason. A value of '0' means 'off'. 452 | ; Available units: s(econds)(default), m(inutes), h(ours), or d(ays) 453 | ; Default Value: 0 454 | ;request_terminate_timeout = 0 455 | 456 | ; Set open file descriptor rlimit. 457 | ; Default Value: system defined value 458 | rlimit_files = 2048 459 | 460 | ; Set max core size rlimit. 461 | ; Possible Values: 'unlimited' or an integer greater or equal to 0 462 | ; Default Value: system defined value 463 | ;rlimit_core = 0 464 | 465 | ; Chroot to this directory at the start. This value must be defined as an 466 | ; absolute path. When this value is not set, chroot is not used. 467 | ; Note: you can prefix with '$prefix' to chroot to the pool prefix or one 468 | ; of its subdirectories. If the pool prefix is not set, the global prefix 469 | ; will be used instead. 470 | ; Note: chrooting is a great security feature and should be used whenever 471 | ; possible. However, all PHP paths will be relative to the chroot 472 | ; (error_log, sessions.save_path, ...). 473 | ; Default Value: not set 474 | ;chroot = 475 | 476 | ; Chdir to this directory at the start. 477 | ; Note: relative path can be used. 478 | ; Default Value: current directory or / when chroot 479 | ;chdir = /var/www 480 | 481 | ; Redirect worker stdout and stderr into main error log. If not set, stdout and 482 | ; stderr will be redirected to /dev/null according to FastCGI specs. 483 | ; Note: on highloaded environement, this can cause some delay in the page 484 | ; process time (several ms). 485 | ; Default Value: no 486 | ;catch_workers_output = yes 487 | 488 | ; Clear environment in FPM workers 489 | ; Prevents arbitrary environment variables from reaching FPM worker processes 490 | ; by clearing the environment in workers before env vars specified in this 491 | ; pool configuration are added. 492 | ; Setting to "no" will make all environment variables available to PHP code 493 | ; via getenv(), $_ENV and $_SERVER. 494 | ; Default Value: yes 495 | ;clear_env = no 496 | 497 | ; Limits the extensions of the main script FPM will allow to parse. This can 498 | ; prevent configuration mistakes on the web server side. You should only limit 499 | ; FPM to .php extensions to prevent malicious users to use other extensions to 500 | ; exectute php code. 501 | ; Note: set an empty value to allow all extensions. 502 | ; Default Value: .php 503 | ;security.limit_extensions = .php .php3 .php4 .php5 504 | 505 | ; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from 506 | ; the current environment. 507 | ; Default Value: clean env 508 | ;env[HOSTNAME] = $HOSTNAME 509 | ;env[PATH] = /usr/local/bin:/usr/bin:/bin 510 | ;env[TMP] = /tmp 511 | ;env[TMPDIR] = /tmp 512 | ;env[TEMP] = /tmp 513 | 514 | ; Additional php.ini defines, specific to this pool of workers. These settings 515 | ; overwrite the values previously defined in the php.ini. The directives are the 516 | ; same as the PHP SAPI: 517 | ; php_value/php_flag - you can set classic ini defines which can 518 | ; be overwritten from PHP call 'ini_set'. 519 | ; php_admin_value/php_admin_flag - these directives won't be overwritten by 520 | ; PHP call 'ini_set' 521 | ; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no. 522 | 523 | ; Defining 'extension' will load the corresponding shared extension from 524 | ; extension_dir. Defining 'disable_functions' or 'disable_classes' will not 525 | ; overwrite previously defined php.ini values, but will append the new value 526 | ; instead. 527 | 528 | ; Note: path INI options can be relative and will be expanded with the prefix 529 | ; (pool, global or /usr/local/php) 530 | 531 | ; Default Value: nothing is defined by default except the values in php.ini and 532 | ; specified at startup with the -d argument 533 | ;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com 534 | ;php_flag[display_errors] = off 535 | ;php_admin_value[error_log] = /var/log/fpm-php.www.log 536 | ;php_admin_flag[log_errors] = on 537 | ;php_admin_value[memory_limit] = 32M 538 | --------------------------------------------------------------------------------