#更新源

yum -y update

#添加用户和组

adduser www
groupadd www
usermod -G www www

#初始化目录

mkdir -p /data/app/php
mkdir -p /data/app/nginx
mkdir -p /data/www
mkdir -p /data/download
mkdir -p /data/logs
chown www.www /data/logs
mkdir -p /data/logs/www
chown www.www /data/logs/www
mkdir -p /data/logs/nginx
chown www.www /data/logs/nginx
mkdir /data/logs/php
chown www.www /data/logs/php touch /data/logs/php/php-fpm.err
chown www.www /data/logs/php/php-fpm.err touch /data/logs/php/phpslow.log
chown www.www /data/logs/php/phpslow.log
touch /data/logs/php/phpslow2.log
chown www.www /data/logs/php/phpslow2.log
touch /data/logs/php/phpslow3.log
chown www.www /data/logs/php/phpslow3.log mkdir -p /data/phptmp
chown www.www /data/phptmp touch /tmp/php-cgi.sock
chown www.www /tmp/php-cgi.sock touch /tmp/php-cgi2.sock
chown www.www /tmp/php-cgi2.sock touch /tmp/php-cgi3.sock
chown www.www /tmp/php-cgi3.sock mkdir /data/logs/rsync

#安装依赖

yum install -y gcc gcc-c++ make libtool zlib zlib-devel openssl openssl-devel pcre pcre-devel

#####################################
#编译安装nginx
#####################################
#下载Nginx

cd /data/download/
wget http://nginx.org/download/nginx-1.11.12.tar.gz

# 解压

tar -zxvf nginx-1.11..tar.gz
cd nginx-1.11.

#编译配置

./configure \
--prefix=/data/app/nginx \
--user=www \
--group=www \
--with-pcre \
--with-http_v2_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-http_v2_module \
--with-threads \
--with-stream \
--with-stream_ssl_module

#--prefix=/usr/local/nginx-1.12.0 # 定义安装路径,不写时默认为/usr/local/nginx

#--sbin-path= # 定义应用程序存放路径,不写时默认为<prefix>/sbin/nginx
#--conf-path= # 定义配置文件路径,不写时默认为<prefix>/conf/nginx.conf
#--error-log-path=/var/log/nginx/error.log # 在配置文件中没有指定error log时的错误日志路径,不写时默认为<prefix>/logs/error.log
#--http-log-path=/var/log/nginx/access.log # 在配置文件中没有指定access log时的访问日志路径, 不写时默认为<prefix>/logs/access.log
#--pid-path=/var/run/nginx/nginx.pid # pid文件路径,没指定时默认为<prefix>/logs/nginx.pid
#--lock-path=/var/lock/subsys/nginx # 锁文件路径
#--user=nginx # 在配置文件中没有指定user指定时,worker进程的运行身份,不写时默认为nobody
#--group=nginx # 在配置文件中没有指定user(不是group,配置文件中没有group指令)指定时,worker进程的运行组

#--with-select_module # 启用select方法模型,当找不到epoll时自动启用select
#--without-select_module
#--with-poll_module # 启用poll方法模型,当找不到epoll时自动启用poll
#--without-poll_module

#--with-http_ssl_module # 启用ssl功能
#--with-http_flv_module # 启用flv视频流功能
#--with-http_stub_status_module # 启用nginx状态监控功能,在启动后在浏览器使用root/status显示状态信息
#--with-http_gzip_static_module # 启用gzip压缩功能压缩web服务器响应客户端的响应报文
#--http-client-body-temp-path=/var/tmp/nginx/client # 定义客户端请求报文主体的临时文件存放路径,不写为<prefix>/client_body_temp
#--http-proxy-temp-path=/var/tmp/nginx/proxy # 定义从代理服务器收到的临时文件存放路径,不写为<prefix>/proxy_temp
#--http-fastcgi-temp-path=/var/tmp/nginx/fcgi # 定义从fastcgi服务器收到的临时文件存放路径,不写为<prefix>/fastcgi_temp
#--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi # 定义从uwsgi服务器收到的临时文件存放路径,不写为<prefix>/uwsgi_temp
#--http-scgi-temp-path=/var/tmp/nginx/scgi # 定义从scgi服务器收到的临时文件存放路径,不写为<prefix>/scgi_temp
#--with-pcre # 设置pcre库的路径,yum安装的pcre-devel可以不写路径
#--with-threads # 设置nginx支持多线程

#编译安装

make && make install

#配置nginx 文件

cp /data/app/nginx/conf/nginx.conf /data/app/nginx/conf/nginx.conf.bak

cat > /data/app/nginx/conf/nginx.conf << EOF

user  www www;
worker_processes 1; error_log /data/logs/nginx/nginx_error.log warn;
pid /var/run/nginx.pid; worker_rlimit_nofile 65535; events {
use epoll;
worker_connections 10240;
multi_accept on;
} http {
include mime.types;
default_type application/octet-stream; charset utf8; server_tokens off;
server_name_in_redirect off; server_names_hash_bucket_size 128;
client_header_buffer_size 16k;
large_client_header_buffers 4 16k; client_max_body_size 50m;
client_body_buffer_size 128K; sendfile on;
tcp_nopush on;
keepalive_timeout 60; fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 128k;
fastcgi_buffers 32 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 156k; gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1;
gzip_comp_level 6;
gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml application/xml+rss; log_format snlog '\$remote_addr | \$remote_user | \$time_local | \$request | \$status | '
'\$bytes_sent | \$body_bytes_sent | \$host | \$http_referer | \$http_user_agent | '
'\$upstream_addr | \$gzip_ratio | \$http_x_forwarded_for | \$request_time | \$upstream_response_time'; access_log off; open_file_cache max=65535 inactive=20s;
open_file_cache_valid 30s;
open_file_cache_min_uses 2;
open_file_cache_errors on; proxy_connect_timeout 300;
proxy_send_timeout 300;
proxy_read_timeout 300; proxy_buffering on;
proxy_buffer_size 32k;
proxy_buffers 128 32k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k; upstream unix__tmp_php_cgi_sock {
server unix:/tmp/php-cgi.sock weight=100 max_fails=5 fail_timeout=30;
server unix:/tmp/php-cgi2.sock weight=100 max_fails=5 fail_timeout=30;
server unix:/tmp/php-cgi3.sock weight=100 max_fails=5 fail_timeout=30;
} # 禁止未授权访问
server {
listen 80 default_server;
server_name _; location / {
return 444;
}
access_log off;
} include vhost/*.conf;
}
EOF

#配置多个站点

mkdir -p /data/app/nginx/conf/vhost  
cat > /data/app/nginx/conf/vhost/default.conf << EOF
server {
listen 80;
server_name www.bheng.top m.bheng.top;
index index.html index.htm index.php;
root /data/www/xiaoshuo; location / { if (!-e $request_filename) {
rewrite ^/(.*)$ /index.php?__tp_s=$1 last;
}
} location ~ \.php$
{
index index.php;
try_files $uri =404;
fastcgi_pass unix__tmp_php_cgi_sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
} access_log /data/logs/www/xiaoshuo.log snlog;
}
EOF

#这个先看下nginx是否配置正确

/data/app/nginx/sbin/nginx -t 

#启动

/data/app/nginx/sbin/nginx 

#重启

/data/app/nginx/sbin/nginx -s reload 

#关闭80端口程序

fuser -k 80/tcp

#############################################################
#安装PHP
#php版本下载地址 https://www.php.net/releases/
#############################################################

#安装依赖包

yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel \
freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel

#下载php源码包

cd /data/download/
wget https://www.php.net/distributions/php-7.0.20.tar.gz
tar -zxvf php-7.0..tar.gz
cd php-7.0.

#编译配置 直接看见 Thank you for using PHP。如果报错,基本就是相关依赖未安装完全

./configure --prefix=/data/app/php --enable-fpm --with-fpm-user=www --with-fpm-group=www \
--disable-ipv6 --with-openssl --with-pcre-regex --with-zlib --enable-bcmath --with-curl --enable-exif \
--with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --with-gettext \
--with-mhash --enable-mbstring --with-mcrypt --with-mysqli --enable-opcache \
--enable-pcntl --with-pdo-mysql --enable-sockets --with-iconv-dir --with-libxml-dir --enable-zip \
--enable-mysqlnd --with-mysql

#编译安装

make && make install

#添加 PHP 命令到环境变量

vim /etc/profile

#在文件末尾加上如下两行代码

PATH=$PATH:/data/app/php/bin
export PATH

# 立即生效

source /etc/profile

#查看PHP版本

php -v
> PHP 7.0. (cli) (built: Jul ::) ( NTS )
Copyright (c) - The PHP Group
Zend Engine v3.0.0, Copyright (c) - Zend Technologies

#配置php-fpm

cp php.ini-production /etc/php.ini
cp /data/app/php/etc/php-fpm.conf.default /data/app/php/etc/php-fpm.conf
cp /data/app/php/etc/php-fpm.d/www.conf.default /data/app/php/etc/php-fpm.d/www.conf
cp /data/download/php-7.0./sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
chmod u+x /etc/init.d/php-fpm
chown -R www.www /data/app/php/var
cat > /data/app/php/etc/php-fpm.conf << EOF
[global]
pid = /data/app/php/var/run/php-fpm.pid
error_log = /data/logs/php/php-fpm.err
log_level = notice [www]
listen = /tmp/php-cgi.sock
listen.backlog = 8192
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = static
pm.max_children = 5
pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 40
request_terminate_timeout = 300
request_slowlog_timeout = 10
slowlog = /data/logs/php/phpslow.log [www2]
listen = /tmp/php-cgi2.sock
listen.backlog = 8192
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = static
pm.max_children = 5
pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 40
request_terminate_timeout = 300
request_slowlog_timeout = 10
slowlog = /data/logs/php/phpslow2.log [www3]
listen = /tmp/php-cgi3.sock
listen.backlog = 8192
listen.allowed_clients = 127.0.0.1
listen.owner = www
listen.group = www
listen.mode = 0666
user = www
group = www
pm = static
pm.max_children = 5
pm.start_servers = 20
pm.min_spare_servers = 10
pm.max_spare_servers = 40
request_terminate_timeout = 300
request_slowlog_timeout = 10
slowlog = /data/logs/php/phpslow3.log
EOF

# 添加php-fpm至服务列表并设置开机自启。

chkconfig --add php-fpm
chkconfig --list php-fpm
chkconfig php-fpm on

# 启动php-fpm

/etc/init.d/php-fpm start

#自行选择是否使用下面php.ini 配置

cat > /data/app/php/lib/php.ini << EOF
[userconfig]
environment = ONLINE
gd.jpeg_ignore_warning = 1 [PHP]
engine = On
short_open_tag = On
asp_tags = Off
precision = 14
output_buffering = 4096
zlib.output_compression = Off
implicit_flush = Off
zend.enable_gc = On
expose_php = Off max_execution_time = 30
max_input_vars = 1000
max_input_time = 65 max_input_nesting_level = 32
memory_limit = 128M error_reporting = E_ALL & ~E_NOTICE display_errors = Off
display_startup_errors = Off
log_errors = On
error_log = /tmp/phperror.log variables_order = "GPCS"
request_order = "GP"
post_max_size = 50M register_argc_argv = Off
auto_globals_jit = On default_mimetype = "text/html"
default_charset = "UTF-8" enable_dl = Off file_uploads = On
upload_max_filesize = 50M
max_file_uploads = 20
upload_tmp_dir = /data/phptmp allow_url_fopen = On
allow_url_include = Off default_socket_timeout = 60 extension_dir = "/data/app/php/lib/php/extensions/no-debug-non-zts-20121212/"
zend_extension=opcache.so
extension=memcache.so
extension=redis.so date.timezone = Asia/Shanghai [Session]
session.save_handler = files
;session.save_handler = memcache
;session.save_path = tcp://127.0.0.1:10007
session.use_strict_mode = 0
session.use_cookies = 1
session.use_only_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly =
session.serialize_handler = php
session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0
session.hash_bits_per_character = 5 [opcache]
opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=128
opcache.interned_strings_buffer=4
opcache.max_accelerated_files=2000
opcache.max_wasted_percentage=5
opcache.use_cwd=1
opcache.validate_timestamps=1
opcache.revalidate_freq=2
opcache.revalidate_path=1
opcache.save_comments=0
opcache.load_comments=0
opcache.fast_shutdown=0
opcache.enable_file_override=0 EOF

linux centos7.3安装lnmp,nginx-1.11.12 ,php7.0.2 ,的更多相关文章

  1. centos7 yum 安装lnmp

    centos7 yum 安装lnmp   安装7.2把7.1改成7.2就行 使用第三方扩展epel源安装php7.2 #移除旧版php [root@web02 ~]# yum remove php-m ...

  2. Linux CentOs7 下安装 redis

    Linux CentOs7 下安装 redis 请将以下命令放入linux命令行中运行 如果安装过程前没有安装GCC请先安装  命令如下 $ yum install gcc-c++ $ wget ht ...

  3. centos7 下 安装部署nginx

    centos7 下 安装部署nginx 1.nginx安装依赖于三个包,注意安装顺序 a.SSL功能需要openssl库,直接通过yum安装: #yum install openssl b.gzip模 ...

  4. (转)LINUX CENTOS7下安装PYTHON

    LINUX CENTOS7下安装PYTHON 原文:http://www.cnblogs.com/lclq/p/5620196.html Posted on 2016-06-27 14:58 南宫羽香 ...

  5. Linux CentOS7下安装Zookeeper-3.4.10服务(最新)

    Linux CentOS7下安装Zookeeper-3.4.10服务(最新) 2017年10月27日 01:25:26 极速-蜗牛 阅读数:1933   版权声明:本文为博主原创文章,未经博主允许不得 ...

  6. Linux(CentOS7)下安装jdk1.8

    Linux(CentOS7) 下安装 jdk1.8 操作过程. 一.检查是否自带jdk rpm -qa|grep java 如果存在则用下面命令删除,xxx yyy zzz代表查询出来的自带jdk名称 ...

  7. Windows和Linux(Centos7)下安装Nginx

    安装Nginx 这篇记录只不过做了一个简单总结,如果对这块没什么概念的话可以看一下知乎的这篇文章 https://zhuanlan.zhihu.com/p/83890573 window下安装 win ...

  8. linux centos-7.2-64bit 安装配置启动nginx

    1.安装依赖包yum -y install openssl openssl-develyum install pcre*yum install openssl*yum install zlib yum ...

  9. CentOS7 编译安装LNMP

    (文章来自:http://www.cnblogs.com/i-it/p/3841840.html,请各位到这个网址去看原文的) LNMP(Linux-Nginx-Mysql-PHP),本文在CentO ...

随机推荐

  1. DB 分库分表的基本思想和切分策略

    DB 分库分表的基本思想和切分策略 一.基本思想 Sharding的基本思想就要把一个数据库切分成多个部分放到不同的数据库(server)上,从而缓解单一数据库的性能问题.不太严格的讲,对于海量数据的 ...

  2. IDEA2019 JFormDesigner-6.0.6.2-intellij-idea破解版

    IDEA2019 JFormDesigner-6.0.6.2-intellij-idea破解版 下载链接:百度云 提取码:10ox 下载完后通过idea的本地磁盘安装即可

  3. Php+Redis函数使用总结

    因项目需求,冷落了redis,今天再重新熟悉一下: <?php //连接 $redis = New Redis(); $redis->connect('127.0.0.1','6379', ...

  4. Oracle12C SGA PGA UGA

    SGA和PGA简介 1 sga组成: 2b4p1s(记忆) database buffer cache:包括 default pool,keep pool,recycle pool: redo log ...

  5. P4138 [JOISC2014]挂饰

    P4138 [JOISC2014]挂饰 ◦          N个装在手机上的挂饰.挂饰附有可以挂其他挂件的挂钩.每个挂件要么直接挂在手机上,要么挂在其他挂件的挂钩上.直接挂在手机上的挂件最多有1个. ...

  6. 简易的美图秀秀利用别人的so库

    在实际开发中,有时候时间短,任务量大,可以查看类似的apk,将行apk反编译,通过看源码分析,用里面的JNI代码! 本案例中用了美图秀秀的JNI.java和jni.so链接库 项目中调用别人写的c代码 ...

  7. asp.net core mvc View Component 应用

    ViewComponent 1.View 组件介绍 在ASP.NET CORE MVC中,View组件有点类似于partial views,但是他们更强大,View组件不能使用model bindin ...

  8. (转载)IDEA中对Git的常规操作(合并,提交,新建分支,更新)

    工作中多人使用版本控制软件协作开发,常见的应用场景归纳如下: 假设小组中有两个人,组长小张,组员小袁 场景一:小张创建项目并提交到远程Git仓库 场景二:小袁从远程Git仓库上获取项目源码 场景三:小 ...

  9. vue-cli3的安装使用

    一.安装vue-cli3 1.全局安装vue-cli 使用命令 cnpm install  -g @vue/cli . npm install  -g @vue/cli.yarn global add ...

  10. Web jsp开发学习——终极解决jsp中request和response中文乱码的问题(加个过滤器)

    中文乱码真的很烦人的.而且每次都要写,可麻烦了,而且有时候写了还不一定管用,所以我们可以试试过滤器 1.每个jsp头上当然要写上utf8啦 <%@ page language="jav ...