日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

lnmp环境搭建 php7,lnmp环境搭建(centos6.9+mysql5.7+php7.1+nginx1.10)

發布時間:2025/3/15 数据库 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 lnmp环境搭建 php7,lnmp环境搭建(centos6.9+mysql5.7+php7.1+nginx1.10) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

安裝前準備:CentOS 6.9 64位 最小化安裝

yum install -y make gcc gcc-c++ perl zlib-devel libaio libpng libpng-devel libjpeg-devel pcre-devel

yum install -y libXpm-devel openssl openssl-devel libxml2-devel bzip2-devel.x86_64 libjpeg-turbo-devel

yum install -y freetype freetype-devel libtool cmake ncurses-devel bison re2c curl-devel wget

rpm -ivh "http://mirrors.sohu.com/fedora-epel/epel-release-latest-6.noarch.rpm"

yum install -y libmcrypt-devel re2c

1、安裝MySql

mysql的安裝請參考LAMP環境搭建(centos6.9+apache2.4+mysql5.7+php7.1)和里面的安裝方法同樣。php

2、php安裝

下載php安裝包并解壓進入html

cd /usr/local/src

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

tar zxvf php-7.1.3.tar.gz

cd php-7.1.3

編譯mysql

./configure \

--prefix=/usr/local/php \

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

--enable-fpm \

--with-fpm-user=nobody \

--with-fpm-group=nobody \

--with-mysql-sock=/tmp/mysql.sock \

--enable-mysqlnd \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

--with-libxml-dir \

--with-gd \

--with-jpeg-dir \

--with-png-dir \

--with-freetype-dir \

--with-iconv-dir \

--with-zlib-dir \

--with-bz2 \

--with-openssl \

--with-mcrypt \

--enable-soap \

--enable-gd-native-ttf \

--enable-mbstring \

--enable-sockets \

--enable-exif \

--disable-ipv6

安裝nginx

make && make install

復制配置文件c++

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

cp /usr/local/src/php-7.1.3/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

cp -v /usr/local/php/etc/{php-fpm.conf.default,php-fpm.conf}

cp -v /usr/local/php/etc/php-fpm.d/{www.conf.default,www.conf}

vi /usr/local/php/etc/php-fpm.d/www.conf 修改 (若是user和group在編譯參數里設置了,這里就不用修改了)sql

user = nobody

group = nobody

修改php.ini

vi /usr/local/php/etc/php.iniapache

date.timezone = Asia/Chongqing

受權添加進服務并啟動centos

chmod 755 /etc/init.d/php-fpm

chkconfig --add php-fpm

chkconfig php-fpm on

service php-fpm start

3、安裝nginx

下載nginx安裝包解壓并進入目錄api

cd /usr/local/src

yum install -y pcre-devel

wget http://mirrors.sohu.com/nginx/nginx-1.10.3.tar.gz

tar zxvf nginx-1.10.3.tar.gz

cd nginx-1.10.3

編譯并安裝php7

./configure --prefix=/usr/local/nginx --with-pcre

make && make install

vi /etc/init.d/nginx

把nginx腳本(在最下面復制nginx啟動腳本)保存為 /etc/init.d/nginx,找到下面三行

nginx="/usr/sbin/nginx"

pidfile="/var/run/${prog}.pid"

NGINX_CONF_FILE="/etc/nginx/nginx.conf"

修改成:

nginx="/usr/local/nginx/sbin/nginx"

pidfile="/usr/local/nginx/logs/${prog}.pid"

NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf"

保存后,執行如下命令設置開機啟動以及啟動服務

chmod +x /etc/init.d/nginx

chkconfig --add nginx

chkconfig nginx on

/etc/init.d/nginx start

5、配置解析php

vi /usr/local/nginx/conf/nginx.conf

找到

location / {

root html;

index index.html index.htm;

}

改為

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 /scripts$fastcgi_script_name;

# include fastcgi_params;

#}

改為

location ~ \.php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;

include fastcgi_params;

}

測試nginx配置文件是否正確

/usr/local/nginx/sbin/nginx -t

從新加載配置文件

/etc/init.d/nginx reload

測試解析php

vi /usr/local/nginx/html/1.php

寫入:

echo "php解析正常";

echo phpinfo();

?>

保存后,繼續測試:

curl localhost/1.php

查看結果已經能夠成功解析。 ngnix啟動腳本

#!/bin/sh

#

# nginx - this script starts and stops the nginx daemon

#

# chkconfig: - 85 15

# description: Nginx is an HTTP(S) server, HTTP(S) reverse \

# proxy and IMAP/POP3 proxy server

# processname: nginx

# config: /etc/nginx/nginx.conf

# config: /etc/sysconfig/nginx

# pidfile: /var/run/nginx.pid

# Source function library.

. /etc/rc.d/init.d/functions

# Source networking configuration.

. /etc/sysconfig/network

# Check that networking is up.

[ "$NETWORKING" = "no" ] && exit 0

nginx="/usr/sbin/nginx"

prog=$(basename $nginx)

sysconfig="/etc/sysconfig/$prog"

lockfile="/var/lock/subsys/nginx"

pidfile="/var/run/${prog}.pid"

NGINX_CONF_FILE="/etc/nginx/nginx.conf"

[ -f $sysconfig ] && . $sysconfig

start() {

[ -x $nginx ] || exit 5

[ -f $NGINX_CONF_FILE ] || exit 6

echo -n $"Starting $prog: "

daemon $nginx -c $NGINX_CONF_FILE

retval=$?

echo

[ $retval -eq 0 ] && touch $lockfile

return $retval

}

stop() {

echo -n $"Stopping $prog: "

killproc -p $pidfile $prog

retval=$?

echo

[ $retval -eq 0 ] && rm -f $lockfile

return $retval

}

restart() {

configtest_q || return 6

stop

start

}

reload() {

configtest_q || return 6

echo -n $"Reloading $prog: "

killproc -p $pidfile $prog -HUP

echo

}

configtest() {

$nginx -t -c $NGINX_CONF_FILE

}

configtest_q() {

$nginx -t -q -c $NGINX_CONF_FILE

}

rh_status() {

status $prog

}

rh_status_q() {

rh_status >/dev/null 2>&1

}

# Upgrade the binary with no downtime.

upgrade() {

local oldbin_pidfile="${pidfile}.oldbin"

configtest_q || return 6

echo -n $"Upgrading $prog: "

killproc -p $pidfile $prog -USR2

retval=$?

sleep 1

if [[ -f ${oldbin_pidfile} && -f ${pidfile} ]]; then

killproc -p $oldbin_pidfile $prog -QUIT

success $"$prog online upgrade"

echo

return 0

else

failure $"$prog online upgrade"

echo

return 1

fi

}

# Tell nginx to reopen logs

reopen_logs() {

configtest_q || return 6

echo -n $"Reopening $prog logs: "

killproc -p $pidfile $prog -USR1

retval=$?

echo

return $retval

}

case "$1" in

start)

rh_status_q && exit 0

$1

;;

stop)

rh_status_q || exit 0

$1

;;

restart|configtest|reopen_logs)

$1

;;

force-reload|upgrade)

rh_status_q || exit 7

upgrade

;;

reload)

rh_status_q || exit 7

$1

;;

status|status_q)

rh_$1

;;

condrestart|try-restart)

rh_status_q || exit 7

restart

;;

*)

echo $"Usage: $0 {start|stop|reload|configtest|status|force-reload|upgrade|restart|reopen_logs}"

exit 2

esac

總結

以上是生活随笔為你收集整理的lnmp环境搭建 php7,lnmp环境搭建(centos6.9+mysql5.7+php7.1+nginx1.10)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。