Script-style installation, quick and easy. Copy to write software enlarged font, here the font is too small.
Installs the nginx+php to see individual needs the database to build the position.
Database installation complete database creation and authorization (5.7 way)
5.7 Database initial Password view
Systemctl mysqld Start
[[email protected] ~]# grep "Password"/var/log/mysqld.log
2017-06-04t01:29:39.687228z 1 [Note] A temporary password is generated for [email protected]: b>gou6zfr1i_
Create a library
CREATE DATABASE WordPress;
Create user, because close root remote link
CREATE USER ' wordpress' @ '% ' identified by 'b>gou6zfr1i_';
Authorized user rights and access to the host
GRANT all privileges on wordpress.* to ' WordPress ' @ '% ';
Finally download the wordpress extract to the Nginx directory.--/data
If WordPress cannot be created automatically, modify the configuration file.
CP wp-config-sample.php wp-config.php (edit this file as modified below)
Define (' db_name ', 'WordPress');
/** MySQL Repository User name, please change "username_here" */define (' Db_user ', 'WordPress');
/** MySQL repository Password, please change "password_here" */define (' Db_password ', 'b>gou6zfr1i_');
/** MySQL Server address * / define (' Db_host ', '192.168.1.201');
#!/bin/bash
#By: sadoc.blog.51cto.com
#Date: 2017-06-03
#LNMP一键安装
#系统centos6.9 64 bit
#Kernel: 2.6.32-696.3.1.el6.x86_64
#php版本: PHP 7.1.5
#nginx版本: 1.12.0
#Mysql版本: mysql-community-5.7.18 (64-bit)
#因为数据库在另外一台, so not installed here, installation is very simple.
#mysql官网下载yum包
#wget https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
#mv/etc/my.cnf/etc/my.cnf.bak
#rpm-IVH mysql57-community-release-el7-11.noarch.rpm
#yum Install Mysql-community-server-y
#
. /etc/init.d/functions | | Exit 5
Ping-c 2 www.baidu.com | | Exit 6
Ntpdate time1.aliyun.com && hwclock-w
#
Check_user= ' WhoAmI '
If ["$check _user"! = "root"];then
echo "Plz use root"
Exit 1
Fi
#for nginx PHP
useradd-m-s/sbin/nologin cents
#
packages_1= "Epel-release openssl-devel libxml2-devel curl-devel openjpeg openjpeg-devel geoip-devel"
Packages_2= "Openjpeg-libs libjpeg libpng freetype cmake wget autoconf libjpeg"
Packages_2= "Libpng-devel freetype-devel mcrypt php-mcrypt libmcrypt libmcrypt-devel"
packages_3= "Zlib-devel net-tools libxml2-devel gcc gcc-c++ zip unzip gzip krb5 perl-devel"
packages_4= "Krb5-devel glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl-devel"
packages_5= "perl-extutils-embed automake autoconf libtool libxslt-devel make Gd-devel"
#循环两次安装
Sum=1
while (($sum <=2))
Do
For apps in $Packages _1 $Packages _2 $Packages _3 $Packages _4 $Packages _5
Do
Rpm-qa|grep $app
If [$?! = "0"];then
Yum Install-y $app
Fi
Done
Done
#
Load=/opt/download
nginx_1= "Nginx-1.12.0.tar.gz"
php_1= "Php-7.1.5.tar.gz"
pcre_1= "Pcre-8.40.tar.gz"
openssl_1= "Openssl-1.0.2k.tar.gz"
[-D $Load] | | mkdir $Load-P
CD $Load
[-F "$Nginx _1"] | | wget http://nginx.org/download/nginx-1.12.0.tar.gz >>/dev/null
[-F "$Php _1"] | | wget http://36.248.244.147/files/9030000000294763/cn2.php.net/distributions/php-7.1.5.tar.gz
#我这里的php下载被无耻的长城宽带劫持了.
[-F "$Pcre _1"] | | wget https://ftp.pcre.org/pub/pcre/pcre-8.40.tar.gz
[-F "$Openssl _1"] | | wget https://www.openssl.org/source/openssl-1.0.2k.tar.gz
[-d/data/wordpress] | | Mkdir/data/wordpress-p
For Yasuo in ' ls '
Do
Tar XF $yasuo >>/dev/null 2>&1
Done
#
CD nginx-1.12.0
./configure--prefix=/opt/app/nginx1.12.0 \
--user=cents \
--group=cents \
--with-file-aio \
--with-ipv6 \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--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_degradation_module \
--with-http_slice_module \
--with-http_stub_status_module \
--with-http_perl_module=dynamic \
--with-mail=dynamic \
--with-mail_ssl_module \
--with-pcre=/opt/download/pcre-8.40 \
--WITH-OPENSSL=/OPT/DOWNLOAD/OPENSSL-1.0.2K \
--with-pcre-jit \
--with-stream=dynamic \
--with-stream_ssl_module \
--with-debug
[$? = 0] | | Exit 5
Make && make install && CD $Load
#
CD php-7.1.5
./configure--prefix=/opt/app/php7.1.5 \
--WITH-MYSQL=MYSQLND \
--WITH-MYSQLI=MYSQLND \
--WITH-PDO-MYSQL=MYSQLND \
--WITH-PDO-MYSQLI=MYSQLND \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--WITH-LIBXML-DIR=/USR \
--enable-xml \
--disable-rpath \
--enable-safe-mode \
--enable-bcmath \
--ENABLE-SHMOP \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-curlwrappers \
--enable-mbregex \
--enable-mbstring \
--with-mcrypt \
--WITH-GD \
--ENABLE-GD-NATIVE-TTF \
--WITH-OPENSSL \
--with-mhash \
--ENABLE-PCNTL \
--enable-sockets \
--WITH-XMLRPC \
--enable-zip \
--ENABLE-SOAP \
--enable-short-tags \
--enable-zend-multibyte \
--enable-static--with-xsl \
--ENABLE-FTP \
--ENABLE-FPM \
--with-fpm-user=cents \
--with-fpm-group=cents
[$? = 0] | | Exit 5
Make && make install && CD
#
Ln-s/opt/app/nginx1.12.0/opt/app/nginx >>/dev/null 2>&1
Ln-s/opt/app/php7.1.5/opt/app/php >>/dev/null 2>&1
#Nginx Configuration
\cp/opt/app/nginx/conf/nginx.conf/opt/app/nginx/conf/nginx.conf.bak
Cat >/opt/app/nginx/conf/nginx.conf<< "EOF"
User cents;
Worker_processes 1;
Error_log Logs/error.log warn;
PID Logs/nginx.pid;
Events {
Worker_connections 1024;
}
HTTP {
Include/opt/app/nginx1.12.0/conf/mime.types;
Default_type Application/octet-stream;
Log_format Main ' $remote _addr-$remote _user [$time _local] "$request" '
' $status $body _bytes_sent ' $http _referer '
' "$http _user_agent" "$http _x_forwarded_for";
Access_log Logs/access.log Main;
Sendfile on;
Keepalive_timeout 65;
include/opt/app/nginx/conf.d/*.conf;
}
Eof
#
Mkdir/opt/app/nginx/conf.d-p
Cat >/opt/app/nginx/conf.d/wordpress.conf<< "EOF"
server {
Listen 80;
server_name localhost;
Location/{
root/data/wordpress;
Index index.php index.htm;
}
Location ~ \.php$ {
root/data/wordpress;
Fastcgi_pass Unix:/tmp/php7.1.5-fpm.sock;
Fastcgi_index index.php;
Fastcgi_param script_filename $document _root$fastcgi_script_name;
Include Fastcgi_params;
}
}
Eof
#php配置
Cd/opt/app/php/etc
\CP Php-fpm.conf.default php-fpm.conf
Sed-i "s%;p id = run/php-fpm.pid%pid =/tmp/php-fpm.pid%g" php-fpm.conf
Sed-i "S%;error_log = Log/php-fpm.log%error_log =/var/log/php-fpm.log%g" php-fpm.conf
Cd/opt/app/php/etc/php-fpm.d
\CP Www.conf.default wordpress.conf
Sed-i "S%listen = 127.0.0.1:9000%listen =/tmp/php7.1.5-fpm.sock%g" wordpress.conf
Sed-i "S%;listen.owner = Cents%listen.owner = cents%g" wordpress.conf
Sed-i "S%;listen.group = Cents%listen.group = cents%g" wordpress.conf
Sed-i "S%;listen.mode = 0660%listen.mode = 0660%g" wordpress.conf
#
\cp/opt/download/php-7.1.5/php.ini-production/opt/app/php/etc/php.ini
Cd
#
/opt/app/nginx/sbin/nginx-t &&/opt/app/nginx/sbin/nginx
/opt/app/php/sbin/php-fpm-t &&/OPT/APP/PHP/SBIN/PHP-FPM
#Iptables
Iptables-f
Iptables-x
Iptables-z
Iptables-a input-p TCP--dport 22-s 192.168.1.0/24-j ACCEPT
Iptables--policy OUTPUT ACCEPT
Iptables--policy forward Drop
Iptables--policy FORWARD DROP
Iptables--policy INPUT DROP
Iptables-a input-i lo-j ACCEPT
Iptables-a Outpu-o lo-j ACCEPT
Iptables-a Output-o lo-j ACCEPT
Iptables-a input-p TCP--dport 80-j ACCEPT
Iptables-a input-p TCP--dport 3306-j ACCEPT
Iptables-a input-m State--state established,related-j ACCEPT
Iptables-a output-m State--state established,related-j ACCEPT
Iptables-l-N
Iptables-l-N
/etc/init.d/iptables Save
Sed-i "/selinux/s/enforcing/disabled/g"/etc/sysconfig/selinux
Setenforce 0
CentOS Series compile and install php7+nginx1.12 and build your WordPress blog