LNMP搭建HDwiki

sed -i 's/SELINUX=enabled/SELINUX=disabled/g' /etc/selinux/config

getenforce 0

/etc/init.d/iptables stop

cat /etc/redhat-release 

uname -r

uname -m

#安装nginx

#su -

#chmod 777 /usr/local/src

yum -y install  wget libtool expat-devel pcre-devel zlib-devel openssl openssl-devel pcre 

yum -y install gcc gcc-c++ glibc automake autoconf libtool make 

yum -y install libmcrypt-devel mhash-devel libxslt-devel \

libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel \

zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel \

ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel \

krb5 krb5-devel libidn libidn-devel openssl openssl-devel

#安装pcre

cd /usr/local/src

wget http://sourceforge.net/projects/pcre/files/pcre/8.39/pcre-8.39.tar.gz/download -O  pcre-8.39.tar.gz

tar -zxvf pcre-8.39.tar.gz

cd pcre-8.39

./configure

make && make install

#安装zlib

  cd /usr/local/src

  wget http://zlib.net/zlib-1.2.11.tar.gz

  tar -zxvf zlib-1.2.11.tar.gz

  cd zlib-1.2.11

  ./configure

  make && make install

#安装openssl

cd /usr/local/src

wget https://www.openssl.org/source/openssl-1.1.0b.tar.gz

tar -zxvf openssl-1.1.0b.tar.gz

cd openssl-1.1.0b

./config

make && make install

#安装nginx

 cd /usr/local/src

 wget http://nginx.org/download/nginx-1.10.2.tar.gz

 tar -zxvf nginx-1.10.2.tar.gz

 cd nginx-1.10.2

groupadd -r nginx

useradd -r -g nginx nginx

./configure \

  --prefix=/usr/local/nginx \

  --sbin-path=/usr/local/nginx/sbin/nginx \

  --conf-path=/usr/local/nginx/nginx.conf \

  --pid-path=/usr/local/nginx/nginx.pid \

  --user=nginx \

  --group=nginx \

  --with-http_ssl_module \

  --with-http_flv_module \

 --with-http_mp4_module  \

 --with-http_stub_status_module \

 --with-http_gzip_static_module \

 --http-client-body-temp-path=/var/tmp/nginx/client/ \

 --http-proxy-temp-path=/var/tmp/nginx/proxy/ \

 --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \

 --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \

 --http-scgi-temp-path=/var/tmp/nginx/scgi \

 --with-pcre=/usr/local/src/pcre-8.39 \

 --with-zlib=/usr/local/src/zlib-1.2.11 \

 --with-openssl=/usr/local/src/openssl-1.1.0b \

;

make && make install

 netstat -ano|grep 80

mkdir -p /var/tmp/nginx/client

/usr/local/nginx/sbin/nginx

#搭建MYSQL

useradd -s /sbin/nologin -M mysql

wget http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

tar -zxvf mysql-5.7.17-linux-glibc2.5-x86_64.tar.gz

mv mysql-5.7.17-linux-glibc2.5-x86_64 /usr/local/mysql-5.7.17

ln -s /usr/local/mysql-5.7.17 /usr/local/mysql

#创建数据库文件目录

mkdir -p /data/mysql

chown -R mysql.mysql /data/

#配置启动脚本文件,并加入系统服务,自启动

cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

chmod +x /etc/init.d/mysqld 

chkconfig --add mysqld

chkconfig mysqld on

#配置mysql配置文件

cat > /etc/my.cnf << EOF

[client]

port = 3306

socket = /tmp/mysql.sock

default-character-set = utf8

[mysqld]

port = 3306

socket = /tmp/mysql.sock

basedir = /usr/local/mysql

datadir = /data/mysql

pid-file = /data/mysql/mysql.pid

user = mysql

bind-address = 0.0.0.0

server-id = 1

init-connect = 'SET NAMES utf8'

character-set-server = utf8

#skip-name-resolve

#skip-networking

back_log = 300

max_connections = 1000

max_connect_errors = 6000

open_files_limit = 65535

table_open_cache = 128

max_allowed_packet = 4M

binlog_cache_size = 1M

max_heap_table_size = 8M

tmp_table_size = 16M

read_buffer_size = 2M

read_rnd_buffer_size = 8M

sort_buffer_size = 8M

join_buffer_size = 8M

key_buffer_size = 4M

thread_cache_size = 8

query_cache_type = 1

query_cache_size = 8M

query_cache_limit = 2M

ft_min_word_len = 4

log_bin = mysql-bin

binlog_format = mixed

expire_logs_days = 30

log_error = /data/mysql/mysql-error.log

slow_query_log = 1

long_query_time = 1

slow_query_log_file = /data/mysql/mysql-slow.log

performance_schema = 0

explicit_defaults_for_timestamp

#lower_case_table_names = 1

skip-external-locking

default_storage_engine = InnoDB

#default-storage-engine = MyISAM

innodb_file_per_table = 1

innodb_open_files = 500

innodb_buffer_pool_size = 64M

innodb_write_io_threads = 4

innodb_read_io_threads = 4

innodb_thread_concurrency = 0

innodb_purge_threads = 1

innodb_flush_log_at_trx_commit = 2

innodb_log_buffer_size = 2M

innodb_log_file_size = 32M

innodb_log_files_in_group = 3

innodb_max_dirty_pages_pct = 90

innodb_lock_wait_timeout = 120

bulk_insert_buffer_size = 8M

myisam_sort_buffer_size = 8M

myisam_max_sort_file_size = 10G

myisam_repair_threads = 1

interactive_timeout = 28800

wait_timeout = 28800

[mysqldump]

quick

max_allowed_packet = 16M

[myisamchk]

key_buffer_size = 8M

sort_buffer_size = 8M

read_buffer = 4M

write_buffer = 4M

EOF

#初始化数据库:

/usr/local/mysql/bin/mysqld --initialize-insecure --user=mysql --basedir=/usr/local/mysql --datadir=/data/mysql

#配合环境变量

echo "export PATH=$PATH:/usr/local/mysql/bin" >>/etc/profile

. /etc/profile

#启动MySQL服务 

/etc/init.d/mysqld start

#修改root密码

mysql -uroot

#mysql -uroot -pk8008.com -e "use mysql;update user set authentication_string=password('新密码') where user='root';"

update mysql.user set authentication_string=password("xmrbiyfzx2016") where user='root';

#安装PHP

#安装第三方yum源

wget http://www.atomicorp.com/installers/atomic

sh ./atomic

#使用yum命令安装

yum -y install  libxml libjpeg freetype libpng gd curl libiconv zlib-devel gd-devel curl-devel openssl-devel libxslt-devel 

php-mcrypt libmcrypt libmcrypt-devel mhash mhash-devel libevent libevent-devel libxml2 libxml2-devel bzip2-devel libcurl-

devel libjpeg-devel libpng-devel freetype-devel 

yum -y install zlib

wget http://mirrors.sohu.com/php/php-5.6.30.tar.gz

tar zxvf php-5.6.30.tar.gz

cd php-5.6.30

./configure \

--prefix=/usr/local/php \

--with-config-file-path=/usr/local/php/etc \

--enable-inline-optimization \

--enable-fpm \

--with-mysql=/usr/local/mysql \

--with-mysqli=/usr/local/mysql/bin/mysql_config \

--with-pdo-mysql=/usr/local/mysql \

--with-gettext \

--enable-mbstring \

--with-iconv=/usr/local/libiconv \

--with-mcrypt \

--with-mhash \

--enable-bcmath \

--enable-soap \

--with-libxml-dir \

--enable-sockets \

--with-curl \

--with-zlib \

--enable-zip \

--with-bz2 \

--with-gd \

--with-freetype-dir \

--with-jpeg-dir \

--with-iconv \

--with-png-dir

#--with-openssl \

make

make install

cp php.ini-production /usr/local/php/etc/php.ini

#到此LNMP安装完成!

mkdir /usr/local/nginx/xmrbi.wiki.com

##配置nginx

user  www www; 

pid /var/run/nginx.pid; 

worker_processes auto; 

worker_rlimit_nofile 100000; 

events

{

use epoll;

multi_accept on; 

worker_connections 51200;

}

http { 

server_tokens off; 

sendfile on; 

tcp_nopush on; 

tcp_nodelay on; 

access_log off; 

error_log /var/log/nginx/error.log crit; 

keepalive_timeout 10; 

client_header_timeout 10; 

client_body_timeout 10; 

reset_timedout_connection on; 

send_timeout 10; 

limit_conn_zone $binary_remote_addr zone=addr:5m; 

limit_conn addr 100; 

include /usr/local/nginx/mime.types; 

default_type text/html; 

charset UTF-8; 

gzip on; 

gzip_disable "msie6"; 

gzip_proxied any; 

gzip_min_length 1000; 

gzip_comp_level 6; 

gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss 

text/javascript; 

gzip_disable “MSIE [1-6].(?!.*SV1)”;

open_file_cache max=100000 inactive=20s; 

open_file_cache_valid 30s; 

open_file_cache_min_uses 2; 

open_file_cache_errors on; 

include /usr/local/nginx/conf.d/*.conf; 


server  {

    listen 9001;

    location ~ /nginx_status {

    stub_status on;

    access_log off;

   allow all;

    #deny all;

    }

server {

 server_name xmrbi.wiki.com;

  server_name 172.16.50.51;

  listen 80;

  autoindex off;

  client_max_body_size 15M;

  client_body_buffer_size 128k;

  index index.html index.htm index.php doku.php;

  access_log  /usr/local/nginx/xmrbi.wiki.com/access.log;

  error_log  /usr/local/nginx/xmrbi.wiki.com/error.log;

  root /usr/local/nginx/html/dokuwiki;

  location / {

    try_files $uri $uri/ @dokuwiki;

  }

  location ~ ^/lib.*\.(gif|png|ico|jpg)$ {

    expires 30d;

  }

  location = /robots.txt  { access_log off; log_not_found off; }

  location = /favicon.ico { access_log off; log_not_found off; }

  location ~ /\.          { access_log off; log_not_found off; deny all; }

  location ~ ~$           { access_log off; log_not_found off; deny all; }

  location @dokuwiki {

    rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last;

    rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last;

    rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last;

    rewrite ^/(.*) /doku.php?id=$1 last;

  }

  location ~ \.php$ {

    try_files $uri =404;

     fastcgi_pass   unix:/var/run/php-fpm/xmrbi.wiki.com.sock;

    fastcgi_index  index.php;

    fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;

    include /usr/local/nginx/fastcgi_params;

    fastcgi_param  QUERY_STRING     $query_string;

    fastcgi_param  REQUEST_METHOD   $request_method;

    fastcgi_param  CONTENT_TYPE     $content_type;

    fastcgi_param  CONTENT_LENGTH   $content_length;

    fastcgi_intercept_errors        on;

    fastcgi_ignore_client_abort     off;

    fastcgi_connect_timeout 60;

    fastcgi_send_timeout 180;

    fastcgi_read_timeout 180;

    fastcgi_buffer_size 128k;

    fastcgi_buffers 4 256k;

    fastcgi_busy_buffers_size 256k;

    fastcgi_temp_file_write_size 256k;

  }

  location ~ /(data|conf|bin|inc)/ {

    deny all;

  }

  location ~ /\.ht {

    deny  all;

  }

}

}

##php高并发nginx优化http://www.cnblogs.com/dawnlee/p/5142724.html

cd /usr/local/php/etc

cp php-fpm.conf.default php-fpm.conf

##vi php-fpm.conf

listen = /var/run/php-fpm/xmrbi.wiki.com.sock

listen.backlog = 65535

listen.owner = www

listen.group = www

listen.mode = 0660

###################

chmod 777 -R /usr/local/nginx/html/dokuwiki

/usr/local/php/sbin/php-fpm

/usr/local/nginx/sbin/nginx -s reload 

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,324评论 5 476
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,303评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,192评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,555评论 1 273
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,569评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,566评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,927评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,583评论 0 257
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,827评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,590评论 2 320
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,669评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,365评论 4 318
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,941评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,928评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,159评论 1 259
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 42,880评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,399评论 2 342

推荐阅读更多精彩内容

  • 系统环境 所需软件官方下载地址: 一、 安装开发包环境: 二、 关闭iptables和Selinux(生产...
    莫名其妙的一生阅读 1,286评论 0 4
  • 更改ip和dnsVi /etc/sysconfig/network-scripts/ifcfg-eth0vi /...
    Xwei_阅读 1,796评论 0 3
  • 一、MemCache简介 session MemCache是一个自由、源码开放、高性能、分布式的分布式内存对象缓存...
    李伟铭MIng阅读 3,781评论 2 13
  • 有时候会想如果这辈子都遇不到自己喜欢的,那怎么办 孤独终老吗 还是听从父母安排相亲 如果让我和一个毫无心动感觉的人...
    985464阅读 428评论 0 1
  • 今天是大雪节气,太阳到达黄经255度。《月令七十二候集解》说:“大雪,十一月节,至此而雪盛也。”小雪封地,...
    金色麦子阅读 310评论 0 0