新金沙3777

【新金沙3777】编写翻译更加快,先安装编写翻译正视的有的构件

二月 11th, 2020  |  未分类

上边脚本之家笔者把PHP7+Nginx的构造与安装教程分享给大家,供我们参照他事他说加以考察,本文写的倒霉还请见谅。

搭建Nginx+PHP环境

搭建Nginx+PHP情况用于Memcached的PHP扩张的测验

系统情状:centos6.5 x64

1. 安装PHP

[root@chunlin PHP]# tar -zxf php-7.1.5.tar.gz
[root@chunlin PHP]# cd php-7.1.5
[root@chunlin php-7.1.5]# mkdir /usr/local/php
[root@chunlin php-7.1.5]# mkdir /usr/local/php/etc
[root@chunlin php-7.1.5]# mkdir /usr/local/php/etc/php.d
[root@chunlin php-7.1.5]# useradd -s /sbin/nologin php_fpm
[root@chunlin php-7.1.5]# yum install -y libxml2.x86_64
[root@chunlin php-7.1.5]# yum install -y libxml2-devel.x86_64
[root@chunlin php-7.1.5]# ./configure –prefix=/usr/local/php
–with-config-file-path=/usr/local/php/etc
–with-config-file-scan-dir=/usr/local/php/etc/php.d  
–enable-fpm –with-fpm-user=php_fpm –with-fpm-group=php_fpm  
–with-mysqli=/usr/bin/mysql_config  
–with-pdo-mysql=/usr/local/mysql
–with-mysql-sock=/var/lib/data/mysql/mysql.sock  
–enable-xml –with-libxml-dir=/usr/bin/xml2-config

软件版本:nginx-1.10.0 php-7.0.6

2. PHP配置

  • 计划安顿文件

[root@chunlin php-7.1.5]#十大正规网赌网址新金沙3777 , cp php.ini-production
/usr/local/php/etc/php.ini
[root@chunlin php-7.1.5]# cd /usr/local/php/etc/
[root@chunlin etc]# mv php-fpm.conf.default php-fpm.conf
[root@chunlin etc]# ln -s /usr/local/php/etc/php.ini /etc/php.ini
[root@chunlin etc]# ln -s /usr/local/php/etc/php-fpm.conf
/etc/php-fpm.conf
[root@chunlin ~]# cd /usr/local/php/etc/php-fpm.d/
[root@chunlin php-fpm.d]# mv www.conf.default www.conf

  • 改良配置文件

  • vim php-fpm.conf

    [root@chunlin ~]# cd /usr/local/php/etc/
    [root@chunlin etc]# vim php-fpm.conf
    [global]
    pid = run/php-fpm.pid
    error_log = log/php-fpm.log
    log_level = warning
    #其他选项使用文件中付出的暗中同意配置就可以

  • vim www.conf

    [root@chunlin php-fpm.d]# cd /usr/local/php/etc/php-fpm.d/
    [root@chunlin php-fpm.d]# vim www.conf
    user = php_fpm
    group = php_fpm
    listen.owner = php_fpm
    listen.group = php_fpm
    listen.mode = 0660
    #其余选取使用文件中提交的暗许配置就可以

  • vim php.ini

    [root@chunlin ~]# ln -s /usr/share/zoneinfo/Asia/Shanghai
    /etc/localtime
    #设置时区为新加坡
    [root@chunlin ~]# vim /etc/php.ini
    date.timezone = Asia/Shanghai
    expose_php = Off
    #鉴于安全靠虑
    short_open_tag = On
    #支撑短标签
    disable_functions =
    passthru,exec,system,chroot,chgrp,chown,shell_exec,
    proc_open,proc_get_status,ini_alter,ini_restore,dl,openlog,
    syslog,readlink,symlink,popepassthru,stream_socket_server,
    fsocket,popen
    #由于安全的酌量禁止使用某个函数
    opcache.enable=1
    opcache.enable_cli=1
    extension_dir = “/usr/local/php/lib/php/extensions
    /no-debug-non-zts-20160303″
    zend_extension=opcache.so
    #开启opcache缓存
    #其余选项使用文件中提交的默许配置就能够

  • 配置php-fpm自启动

[root@chunlin ~]# cd /usr/local/package/LNMP/PHP/php-7.1.5
[root@chunlin php-7.1.5]# cp sapi/fpm/init.d.php-fpm
/etc/init.d/php-fpm
[root@chunlin php-7.1.5]# chmod 755 /etc/init.d/php-fpm
[root@chunlin php-7.1.5]# chkconfig –add php-fpm
[root@chunlin php-7.1.5]# chkconfig php-fpm on

安装 Nginx

3. Nginx编写翻译安装

Nginx官网:

1)安装计划
  • 系统:redhat6.5.x86_64
  • 软件:nginx-1.10.3.tar.gz(稳定版)、gcc.x86_64、pcre-devel.x86_64、perl-ExtUtils-Embed.x86_64、zlib-devel.x86_64、openssl-devel.x86_64

[root@chunlin Nginx]# mkdir /opt/nginx
[root@chunlin Nginx]# tar -zxf nginx-1.10.3.tar.gz
[root@chunlin Nginx]# ls
nginx-1.10.3 nginx-1.10.3.tar.gz
[root@chunlin Nginx]# cd nginx-1.10.3

[root@chunlin nginx-1.10.3]# vim auto/cc/gcc
#debug
#CFLAGS=”$CFLAGS -g”

将以上两行注释掉,撤销nginx的debug编写翻译情势,编写翻译越来越快。

[root@chunlin nginx-1.10.3]# vim src/core/nginx.h
#define NGINX_VER “nginx”

上边的那条修正是为了nginx服务器的安全,隐瞒了nginx版本,供给将#define
NGINX_VE君越后边的双引号中的字符串改为nginx

先安装编写翻译依赖的有些零构件

2)编写翻译安装

[root@chunlin nginx-1.10.3]# ./configure –prefix=/opt/nginx
–with-http_gzip_static_module –with-http_stub_status_module
–with-http_perl_module –with-http_ssl_module

configure是个shell脚本,是autoconf的工具的基本选用,用来布置软件属性,安装目录,检查编写翻译所需的库文件是或不是留存也许符合条件等,生成编写翻译所要求的Makefile
文件。

编写翻译的时候作者采取将http_gzip_static_module、http_stub_status_module、http_perl_module、http_ssl_module这八个模块编写翻译进去。

  • http_gzip_static_module:这几个模块支持在线实时压缩输出数据流
  • http_stub_status_module:监控Nginx的状态
  • http_perl_module:支持Perl脚本
  • http_ssl_module:开启SSL模块,补助采用HTTPS合同的网页

[root@chunlin nginx-1.10.3]# make
#make 是 Linux
开荒套件里面自动化编写翻译的三个垄断程序,它依照Makefile调整代码编写翻译源码。要是在make进度中失误了,能够通过先make
clean,然后再重复make。
[【新金沙3777】编写翻译更加快,先安装编写翻译正视的有的构件。root@chunlin nginx-1.10.3]# make install

复制代码 代码如下:yum install pcre
pcre-devel openssl openssl-devel -y

4. Nginx配置

[root@chunlin ~]# vim /opt/nginx/conf/nginx.conf
#急需先安装Nginx,以下是安顿文件中要校勘或追加的源委

user  php_fpm php_fpm;
location / {
        root   html;
        index  index.html index.htm index.php;
    }
location ~ .php$ {
        root           html;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }

[root@chunlin ~]# nginx -t
[root@chunlin ~]# nginx -s reload

1、解压程序包

复制代码 代码如下:tar xf
nginx-1.10.0.tar.gz cd nginx-1.10.0

2、预编写翻译配置参数

复制代码 代码如下:./configure –user=www
–group=www –prefix=/data/server/nginx
–with-http_stub_status_module –without-http-cache
–with-http_ssl_module –with-http_gzip_static_module

3、实践编写翻译

复制代码 代码如下:make && make install

4、替换配置文件

nginx.conf

user www www;worker_processes 1;error_log /u01/data/log/nginx/error.log crit;pid /u01/data/server/nginx/logs/nginx.pid;#Specifies the value for maximum file descriptors that can be opened by this process.worker_rlimit_nofile 65535;events{use epoll;worker_connections 65535;}http {include mime.types;default_type application/octet-stream;#charset gb2312;server_names_hash_bucket_size 128;client_header_buffer_size 32k;large_client_header_buffers 4 32k;client_max_body_size 8m;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 64k;fastcgi_buffers 4 64k;fastcgi_busy_buffers_size 128k;fastcgi_temp_file_write_size 128k;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;#limit_zone crawler $binary_remote_addr 10m;log_format main '$remote_addr - "$request_time" [$time_local] "$request" ''"$status" $body_bytes_sent "$http_referer" ''"$http_user_agent" $http_x_forwarded_for';log_format '$remote_addr - $remote_user [$time_local] "$request" ''$status $body_bytes_sent "$http_referer" ''"$http_user_agent" $http_x_forwarded_for "$request_time"';include /u01/alidata/server/nginx/conf/vhosts/*.conf;

设想主机配置文件模板

server {listen 8080;server_name localhost;index index.html index.htm index.php;root /u01/data/www;location ~ .*.?${fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;fastcgi_index index.php;include fastcgi.conf;}location ~ .*.(gif|jpg|jpeg|png|bmp|swf)${expires 30d;}location ~ .*.?${expires 1h;}###this is to use open website lianjie like on apache##location / {if (!-e $request_filename) {rewrite ^$ /index.php?s=$1 last;break;}}location ~ /.svn/ {deny all;}###end##access_log /u01/data/log/nginx/access/test.log main;}

5、提供Nginx运转脚本

#!/bin/bash#nginxd=/u01/data/server/nginx/sbin/nginxnginx_config=/u01/data/server/nginx/conf/nginx.confnginx_pid=/u01/data/server/nginx/logs/nginx.pidRETVAL=0prog="nginx"[ -x $nginxd ] || exit 0# Start nginx daemons functions.start() {if [ -e $nginx_pid ] && netstat -tunpl | grep nginx &> /dev/null;thenecho "nginx already running...."exit 1fiecho -n $"Starting $prog!"$nginxd -c ${nginx_config}RETVAL=$?echo[ $RETVAL = 0 ] && touch /var/lock/nginxreturn $RETVAL}# Stop nginx daemons functions.stop() {echo -n $"Stopping $prog!"$nginxd -s stopRETVAL=$?echo[ $RETVAL = 0 ] && rm -f /var/lock/nginx}# reload nginx service functions.reload() {echo -n $"Reloading $prog!"stop() {echo -n $"Stopping $prog!"$nginxd -s stopRETVAL=$?echo[ $RETVAL = 0 ] && rm -f /var/lock/nginx}# reload nginx service functions.reload() {echo -n $"Reloading $prog!"#kill -HUP `cat ${nginx_pid}`$nginxd -s reloadRETVAL=$?echo}# See how we were called.case "$1" instart)start;;stop)stop;;reload)reload;;restart)stopstart;;*)echo $"Usage: $prog {start|stop|restart|reload|help}"exit 1esacexit $RETVAL

只须求稍加修正程序路径就可马上采取

安装 PHP7

PHP官网:

PHP扩展:

先安装一些为编写翻译正视的组装

yum -y install gcc gcc-c++ gcc-g77 make libtool autoconf patch unzip automake libxml2 libxml2-devel ncurses ncurses-devel libtool-ltdl-devel libtool-ltdl libmcrypt libmcrypt-devel libpng libpng-devel libjpeg-devel openssl openssl-devel curl curl-devel libxml2 libxml2-devel ncurses ncurses-devel libtool-ltdl-devel libtool-ltdl autoconf automake libaio*

1、解压程序包

复制代码 代码如下:tar xf
php-7.0.6.tar.bz2cd php-7.0.6

2、安装编写翻译重视的图片库

复制代码
代码如下:jpegsrc.v6b.tar.gzlibpng-1.2.50.tar.gzfreetype-2.1.10.tar.gz

# 安装 jpegsrc.v6b.tar.gz#这个需要先创建好存放程序的文件夹不然会报错mkdir /usr/local/jpeg.6/{bin,lib,include,man/man1} -pvtar xf jpegsrc.v6b.tar.gz cd jpeg-6b/./configure --prefix=/usr/local/jpeg.6/make && make install# 安装 libpng-1.2.50.tar.gztar xf libpng-1.2.50.tar.gzcd libpng-1.2.50./configure --prefix=/usr/local/libpng.1.2.50make && make install# 安装 freetype-2.1.10.tar.gztar xf freetype-2.1.10.tar.gzcd freetype-2.1.10./configure --prefix=/usr/local/freetype.2.1.10/make && make install

3、预编写翻译配置参数

./configure --prefix=/data/server/php --enable-opcache --with-config-file-path=/u01/data/server/php/etc --enable-mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --enable-fpm --enable-static --enable-inline-optimization --enable-sockets --enable-wddx --enable-zip --enable-calendar --with-gd --with-iconv --with-openssl --with-zlib --enable-bcmath --enable-soap --with-xmlrpc --enable-mbstring --enable-shared --with-curl --enable-xml --enable-ftp --with-mcrypt --with-mhash --enable-shmop --enable-sysvsem --enable-mbregex --enable-gd-native-ttf --enable-pcntl --enable-session --with-gettext --with-freetype-dir=/usr/local/freetype.2.1.10 --with-jpeg-dir=/usr/local/jpeg.6 --with-png-dir=/usr/local/libpng.1.2.50 --disable-ipv6 --disable-debug --disable-maintainer-zts --disable-rpath --disable-fileinfo --without-gdbm 

4、实施编写翻译

复制代码 代码如下:make && make install

5、提供php.ini文件

复制代码 代码如下:cp php.ini-production
/u01/data/server/php/etc/php.ini

配置php.ini

# 在840行左右-设置PHP的opcache和memcache扩展库zend_extension=opcache.soextension=memcache.so# 722行左右-设置PHP的扩展库路径extension_dir = "/u01/data/server/php7/lib/php/extensions/no-debug-non-zts-20151012/"# 避免PHP信息暴露在http头中expose_php = Off# 避免暴露php调用mysql的错误信息display_errors = Off# 开启PHP错误日志log_errors = On# 设置PHP的时区date.timezone = PRC# 开启opcacheopcache.enable=1# 设置PHP脚本允许访问的目录# open_basedir = /usr/share/nginx/html;

6、配置php-fpm

php-fpm.conf 进度服务主配置文件

# 设置错误日志的路径error_log = /var/log/php-fpm/error.log# 引入www.conf文件中的配置include=/usr/local/php7/etc/php-fpm.d/*.conf# 设置主进程打开的最大文件数rlimit_files = 102400www.conf 进程服务扩展配置文件# 设置用户和用户组user = wwwgroup = www# 设置php监听方式# listen = 127.0.0.1:9000 # 注意这里要设置PHP套接字文件的权限,默认是root,Nginx无法访问。listen = /var/run/php-fpm/php-fpm.sock# 开启慢日志slowlog = /var/log/php-fpm/php-slow.logrequest_slowlog_timeout = 10s# 设置工作进程数pm.max_children = 50# 这里需要注意,pm.start_servers 不能小于 pm.min_spare_serverspm.start_servers = 5pm.min_spare_servers = 5pm.max_spare_servers = 10pm.max_requests = 10240# 设置php的session目录php_value[session.save_handler] = filesphp_value[session.save_path] = /var/tmp/php/session

7、提供php-fpm运营脚本

#! /bin/sh#prefix=/u01/data/server/php7exec_prefix=${prefix}php_fpm_BIN=${exec_prefix}/sbin/php-fpmphp_fpm_CONF=${prefix}/etc/php-fpm.confphp_fpm_PID=${prefix}/var/run/php-fpm.pidphp_opts="--fpm-config $php_fpm_CONF --pid $php_fpm_PID"wait_for_pid () {try=0while test $try -lt 35 ; docase "$1" in'created')if [ -f "$2" ] ; thentry=''breakfi;;'removed')if [ ! -f "$2" ] ; thentry=''breakfi;;esacecho -n .try=`expr $try + 1`sleep 1done}case "$1" instart)echo -n "Starting php-fpm "$php_fpm_BIN --daemonize $php_optsif [ "$?" != 0 ] ; thenecho " failed"exit 1fiwait_for_pid created $php_fpm_PIDif [ -n "$try" ] ; thenecho " failed"exit 1elseecho " done"fi;;stop)echo -n "Gracefully shutting down php-fpm "if [ ! -r $php_fpm_PID ] ; thenecho "warning, no pid file found - php-fpm is not running ?"exit 1fikill -QUIT `cat $php_fpm_PID`wait_for_pid removed $php_fpm_PIDif [ -n "$try" ] ; thenecho " failed. Use force-quit"exit 1elseecho " done"fi;;status)if [ ! -r $php_fpm_PID ] ; thenecho "php-fpm is stopped"exit 0fiPID=`cat $php_fpm_PID`if ps -p $PID | grep -q $PID; thenecho "php-fpm  is running..."elseecho "php-fpm dead but pid file exists"fi;;force-quit)echo -n "Terminating php-fpm "if [ ! -r $php_fpm_PID ] ; thenecho "warning, no pid file found - php-fpm is not running ?"exit 1fikill -TERM `cat $php_fpm_PID`wait_for_pid removed $php_fpm_PIDif [ -n "$try" ] ; thenecho " failed"exit 1elseecho " done"fi;;restart)$0 stop$0 start;;reload)echo -n "Reload service php-fpm "if [ ! -r $php_fpm_PID ] ; thenecho "warning, no pid file found - php-fpm is not running ?"exit 1fikill -USR2 `cat $php_fpm_PID`echo " done";;*)echo "Usage: $0 {start|stop|force-quit|restart|reload|status}"exit 1;;esac

八、启动php-fpm程序

/etc/init.d/php-fpm start# 修改套接字文件权限chown -R /var/run/php-fpm/

相关文章

Your Comments

近期评论

    分类目录

    • 没有分类目录

    功能


    网站地图xml地图