Centos系列编译安装php7+nginx1.12及搭建自己的wordpress博客

脚本方式安装,快速简单.复制到编写软件放大字体,这里字体太小.

安装完nginx+php看个人需要数据库搭建位置.

数据库安装完成创建数据库及授权(5.7方式)

5.7数据库初始密码查看

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 DATABASE wordpress;

创建用户,因为关闭root远程链接

CREATE USER ‘wordpress‘@‘%‘ IDENTIFIED BY ‘b>gOU6ZFr1i_‘;

授权用户权限并且能够访问的主机

GRANT ALL PRIVILEGES ON wordpress.* TO ‘wordpress‘@‘%‘;

最后下载wordpress解压 到nginx目录下即可.--/data

若是wordpress无法自动创建请修改配置文件.

cp wp-config-sample.php wp-config.php(编辑此文件如下修改)

define(‘DB_NAME‘, ‘wordpress‘);

/** MySQL 數據庫使用者名稱,請更改 "username_here" */define(‘DB_USER‘, ‘wordpress‘);

/** MySQL 數據庫密碼,請更改 "password_here" */define(‘DB_PASSWORD‘, ‘b>gOU6ZFr1i_‘);

/** MySQL 伺服器位址 */define(‘DB_HOST‘, ‘192.168.1.201‘);

#!/bin/bash

#By:sadoc.blog.51cto.com

#Date:2017-06-03

#LNMP一键安装

#系统centos6.9 64位

#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位)

#因为数据库在另外一台,所以这里不安装,安装很简单.

#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 app 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 配置

\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%;pid = 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

时间: 2024-09-30 05:27:01

Centos系列编译安装php7+nginx1.12及搭建自己的wordpress博客的相关文章

CentOS 7.2 下编译安装PHP7.0.10+MySQL5.7.14+Nginx1.10.1的方法

这篇文章主要介绍了CentOS 7.2 mini版本下编译安装PHP7.0.10+MySQL5.7.14+Nginx1.10.1的方法,非常不错,具有参考借鉴价值,需要的朋友可以参考下一.安装前的准备工作 1.yum update #更新系统 2.yum install gcc gcc-c++ autoconf automake cmake bison m4 libxml2 libxml2-devel libcurl-devel libjpeg-devel libpng-devel libicu

centos 6.5 编译安装了 Nginx1.6.0+MySQL5.6.19+PHP5.5.14

centos 6.5 编译安装了 Nginx1.6.0+MySQL5.6.19+PHP5.5.14--------------------------------------------------------------------------------------------- 安装包:http://pan.baidu.com/s/1jG8iose SecureCRT下载地址:http://pan.baidu.com/s/1kTtnfKV FlashFXP下载地址:http://pan.b

centos下编译安装LNMP环境

自PHP-5.3.3起,PHP-FPM加入到了PHP核心,编译时加上--enable-fpm即可提供支持. PHP-FPM以守护进程在后台运行,Nginx响应请求后,自行处理静态请求,PHP请求则经过fastcgi_pass交由PHP-FPM处理,处理完毕后返回. Nginx和PHP-FPM的组合,是一种稳定.高效的PHP运行方式,效率要比传统的Apache和mod_php高出不少. 二.依赖环境 yum -y install gcc gcc-c++ make cmake automake au

编译安装PHP7并安装Redis扩展Swoole扩展

在编译php7的机器上已经有编译安装过php5.3以上的版本,从而依赖库都有了 本php7是编译成fpm-php 使用的, 如果是apache那么编译参数应该为 1 --with-apxs2=/usr/local/apache/bin/apxs 编译安装php7 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 4

编译安装配置nginx1.6以及其一些基本配置等

实验环境: centos 6.6 [该节点IP为172.16.3.101] 配置好的yum源[可以把yum源指向搜狐或者阿里的镜像站点,也可以是自己的光盘] 编译安装配置nginx1.6 # 安装之前最好先把如下包组安装上 [[email protected] httpd-2.2.29]# yum grouplist | grep -i 'develop'    Additional Development    Development tools    Server Platform Deve

CentOS7.3编译安装MariaDB10.2.12

在CentOS7.3编译安装MariaDB10.2.12详细教程 1. 删除CentOS7.3默认数据库配置文件 查看默认数据库配置文件 [[email protected] ~]# find -H /etc/ | grep my.c /etc/pki/tls/certs/make-dummy-cert /etc/pki/tls/certs/renew-dummy-cert /etc/my.cnf.d /etc/my.cnf.d/mysql-clients.cnf /etc/my.cnf 删除默

centos 下编译安装mysql5.1与mysql5.5

mysql5.1.60编译安装 1.tar -zxvf mysql* 2../configure 之前要make clean ./configure --prefix=/home/shk/mysql-5.1.60 \ --enable-local-infile \ --with-unix-socket-path=/home/shk/mysql-5.1.60/var/mysql.sock \ --with-tcp-port=5506 \ --enable-thread-safe-client \

编译安装php5.6.12

一.系统环境说明 本次实验基于CentOS6.8_x64 (6.x均可),编译安装php5.6.12 包含以下四个扩展模块(包): libmcrypt-2.5.8.tar.gz ;php-redis.tar.gz;jpegsrc.v8d.tar.gz ;zendopcache-7.0.5.tar.gz 可自行到对应官方网站 下载最新软件包,本例软件包版本如上所列,如需要本例软件压缩包php5.6.12.tar.gz请到以下百度网盘地址中获取 ,压缩包中包含以上安装包,并附自动安装脚本和php-f

Centos6.8源码编译安装PHP7

一.下载源码包 打开php官网http://php.net/点击导航栏的Downloads进入下载页面:http://php.net/downloads.php下载想要安装的版本,这里下载最新版的php-7.1.8 的源码包. 下载环境源码包wget https://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.15.tar.gz   可以选择版本,这里下载最新版libiconv-1.15.tar.gz 二.解压源码包并安装环境包 1 tar zxvf libi