由网络副手--寻路人于2019.04.26 20:20:00发布在服务器运维 PHP7.2.2+Nginx1.14.2+Redis-4.0 阅读4376 评论0 喜欢0 一、PHP 安装 安装常用依赖 yum install -y gcc bison bison-devel zlib-devel libmcrypt-devel mcrypt mhash-devel \ openssl-devel libxml2-devel libcurl-devel bzip2-devel readline-devel libedit-devel \ sqlite-devel libpng libpng-devel freetype-devel 安装openssh wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz tar -xzvf openssl-1.0.1c.tar.gz cd openssl-1.0.1c ./config --prefix=/usr/local/openssl1.1 && make && make install 安装JPG #jpegsrc.v9.tar.gz git clone https://github.com/clchiou/jpeg.git cd jpeg ./configure --prefix=/usr/local/jpeg && make && make install 安装freetype wget http://download.savannah.gnu.org/releases/freetype/freetype-2.4.0.tar.bz2 tar jxvf freetype-2.4.0.tar.bz2 cd freetype-2.4.0 ./configure --prefix=/usr/local/freetype && make && make install 安装png wget https://iweb.dl.sourceforge.net/project/libpng/libpng16/1.6.35/libpng-1.6.35.tar.gz tar -xzvf libpng-1.6.35.tar.gz cd libpng-1.6.35/ ./configure --prefix=/usr/local/png && make && make install 安装PHP wget https://museum.php.net/php7/php-7.2.2.tar.gz tar xzvf php-7.2.2.tar.gz cd php-7.2.2 ./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7/etc \ --enable-inline-optimization --disable-debug --enable-fpm --with-fpm-user=www \ --with-fpm-group=www --with-mysqli --enable-pdo --with-pdo-mysql --with-gettext \ --enable-mbstring --with-gd --enable-gd-native-ttf --with-iconv --with-mcrypt \ --with-mhash --with-openssl --enable-wddx --enable-zip --with-xmlrpc \ --with-zlib-dir --with-bz2 --with-curl --enable-xml --with-curlwrappers --enable-mbregex \ --enable-session --enable-bcmath --enable-soap --with-libxml-dir --enable-pcntl \ --enable-shmop --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-sockets \ --enable-calendar --with-jpeg-dir=/usr/local/jpeg --with-png-dir=/usr/local/png \ --with-freetype-dir=/usr/local/freetype make && make install #简单配置 build/shtool install -c ext/phar/phar.phar /usr/local/php7/bin cp php.ini-production /usr/local/php7/etc/php.ini ln -s /usr/local/php7/bin/php /usr/bin/ ln -s /usr/local/php7/bin/php /usr/local/bin/ ln -s /usr/local/php7/etc/php.ini /etc/php.ini cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf #配置PHP-fpm #配置进程数、错误日志、配置优化点 vim /usr/local/php7/etc/php-fpm.conf pid = /usr/local/php7/var/run/php7-fpm.pid error_log = /usr/local/php7/var/log/php7-fpm.log log_level = notice emergency_restart_threshold = 10 emergency_restart_interval = 10 process_control_timeout = 10 [www] listen = /dev/shm/php7-cgi.sock listen.backlog=4096 listen.owner = nobody listen.group = nobody listen.mode = 0666 user = nobody group = nobody pm = static pm.max_children = 150 pm.start_servers = 351 pm.min_spare_servers = 261 pm.max_spare_servers = 531 pm.max_requests = 1024 request_terminate_timeout = 600 request_slowlog_timeout = 600 slowlog = /usr/local/php7/var/log/php7-fpm.slow access.format = %R - %u %t "%m %r%Q%q" %s %f %{mili}d %{kilo}M %C%% pm.status_path = /php7fpmstatus -----------php启动脚本---------- vim /etc/init.d/php7-fpm #! /bin/sh ### BEGIN INIT INFO # Provides: php-fpm # Required-Start: $remote_fs $network # Required-Stop: $remote_fs $network # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts php-fpm # Description: starts the PHP FastCGI Process Manager daemon ### END INIT INFO prefix=/usr/local/php7 exec_prefix=${prefix} php_fpm_BIN=${exec_prefix}/sbin/php-fpm php_fpm_CONF=/usr/local/php7/etc/php-fpm.conf php_fpm_PID=${prefix}/var/run/php7-fpm.pid php_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID" wait_for_pid () { try=0 while test $try -lt 35 ; do case "$1" in 'created') if [ -f "$2" ] ; then try='' break fi ;; 'removed') if [ ! -f "$2" ] ; then try='' break fi ;; esac echo -n . try=`expr $try + 1` sleep 1 done } case "$1" in start) echo -n "Starting php-fpm " $php_fpm_BIN --daemonize $php_opts if [ "$?" != 0 ] ; then echo " failed" exit 1 fi wait_for_pid created $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; stop) echo -n "Gracefully shutting down php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -QUIT `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed. Use force-quit" exit 1 else echo " done" fi ;; status) if [ ! -r $php_fpm_PID ] ; then echo "php-fpm is stopped" exit 0 fi PID=`cat $php_fpm_PID` if ps -p $PID | grep -q $PID; then echo "php-fpm (pid $PID) is running..." else echo "php-fpm dead but pid file exists" fi ;; force-quit) echo -n "Terminating php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -TERM `cat $php_fpm_PID` wait_for_pid removed $php_fpm_PID if [ -n "$try" ] ; then echo " failed" exit 1 else echo " done" fi ;; restart) $0 stop $0 start ;; reload) echo -n "Reload service php-fpm " if [ ! -r $php_fpm_PID ] ; then echo "warning, no pid file found - php-fpm is not running ?" exit 1 fi kill -USR2 `cat $php_fpm_PID` echo " done" ;; configtest) $php_fpm_BIN -t ;; *) echo "Usage: $0 {start|stop|force-quit|restart|reload|status|configtest}" exit 1 ;; esac -------NGINX 安装---------- 二、安装Nginx yum install -y gcc gcc-c++ 依赖: with-pcre 8.41 https://ftp.pcre.org/pub/pcre/ https://ftp.pcre.org/pub/pcre/pcre-8.41.tar.gz tar -xzvf pcre-8.41.tar.gz with-zlib 1.2.11 http://zlib.net/ https://github.com/madler/zlib/archive/v1.2.11.tar.gz tar -xzvf v1.2.11.tar.gz wget http://nginx.org/download/nginx-1.14.2.tar.gz tar -xzvf nginx-1.14.2.tar.gz cd nginx-1.14.2 ./configure --prefix=/home/nginx --with-http_ssl_module --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11 --with-http_stub_status_module && make && make install 配置Nginx cd /home/nginx/conf mkdir vhost vim /home/nginx/conf/nginx.conf user nobody nobody; worker_processes auto; #error_log /home/nginx/logs/error.log crit; error_log /home/nginx/logs/error.log error; #error_log /home/nginx/logs/error.log info; pid /home/nginx/logs/nginx.pid; worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; } http { include mime.types; default_type application/octet-stream; server_names_hash_bucket_size 128; client_header_buffer_size 4k; large_client_header_buffers 4 32k; client_max_body_size 50m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 256k; fastcgi_buffers 4 256k; fastcgi_busy_buffers_size 512k; fastcgi_temp_file_write_size 512k; client_body_buffer_size 256k; send_timeout 3m; client_header_timeout 20; client_body_timeout 3m; proxy_ignore_client_abort on; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.0; gzip_comp_level 2; gzip_types text/plain application/x-javascript text/css application/xml; gzip_vary on; server { listen 80; server_name 10.10.136.240; location /nginx_status { stub_status on; access_log off; } location ~ ^/(php56fpmstatus)$ { fastcgi_index index.php; fastcgi_pass unix:/dev/shm/php56-cgi.sock; include fastcgi.conf; } location ~ ^/(php7fpmstatus)$ { fastcgi_index index.php; fastcgi_pass unix:/dev/shm/php7-cgi.sock; include fastcgi.conf; } } log_format main '{ "@timestamp": "$time_iso8601", ' '"hostname": "$hostname", ' '"server_name": "$server_name", ' '"xes-app": "$upstream_http_server", ' '"remote_addr": "$remote_addr", ' '"remote_user": "$remote_user", ' '"body_bytes_sent": $body_bytes_sent, ' '"request_time": $request_time, ' '"upstream_response_time": "$upstream_response_time", ' '"status": $status, ' '"upstream_status": "$upstream_status", ' '"connection_requests": $connection_requests, ' '"request": "$request", ' '"request_method": "$request_method", ' # '"request_body": "$request_body", ' '"http_referrer": "$http_referer", ' '"http_cookie": "$http_cookie", ' '"http_x_request_id": "$http_x_request_id", ' '"http_user_agent": "$http_user_agent" }'; include vhost/*.conf; } 动态编译Nginx 为此增加Nginx 统计模块 --with-http_stub_status_module 查看当前安装 /home/nginx/sbin/nginx -V ./configure --prefix=/home/nginx --with-http_ssl_module --with-pcre=../pcre-8.41 --with-zlib=../zlib-1.2.11 --with-http_stub_status_module # 编译 这里只能执行 make 【 不能执行 make install 】否则会覆盖掉原来的 nginx 执行后停止Nginx service nginx stop 编译完成后 备份原来的 nginx 脚本 用新的 nginx 脚本更替原来的 ,重启 nginx mv /home/nginx/sbin/nginx /home/nginx/sbin/nginx.bak cp ./objs/nginx /home/nginx/sbin/ service nginx start -----------REDIS 模块--------- 三、Redis 安装 wget https://github.com/antirez/redis/archive/4.0.14.tar.gz mv 4.0.14.tar.gz redis_4.0.14.tar.gz tar -xzvf redis_4.0.14.tar.gz cd redis-4.0.14/ make mv redis-4.0.14 /usr/local/redis-4.0 ln -s /usr/local/redis-4.0/src/redis-cli /usr/bin/ ln -s /usr/local/redis-4.0/src/redis-server /usr/bin/ redis-server /usr/local/redis-4.0/redis.conf & 赞 0 分享 赏 您可以选择一种方式赞助本站 支付宝扫码赞助 BraveDu 署名: 网络副手~寻路人