CentOS   发布时间:2022-04-02  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了CentOS6.8编译安装Nginx1.10.2+MySQL5.7.16+PHP7.0.12大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

1.    下载 #MySQL下载地http://dev.mysql.com/downloads/mysql/ #Nginx下载地http://nginx.org/en/download.html #php下载地http://php.net/downloads.php 使用WinSCP把下载好的压缩包上传到/usr/local/src目录 mysql-5.7.16.tar.gz ngi
@H_618_7@

1.下载

#MysqL下载地

http://dev.mysql.com/downloads/mysql/

#Nginx下载地

http://nginx.org/en/download.html

#PHP下载地

http://php.net/downloads.php

使用WinSCP把下载好的压缩包上传/usr/local/src目录

MysqL-5.7.16.tar.gz Nginx-1.10.2.tar.gz PHP-7.0.12.tar.gz

2.安装

2.1MysqL安装

#安装所需依赖

yum install gcc gcc-c++ cmakencurses ncurses-devel bison

#下载boost http://www.boost.org/users/download/

tar zxf boost_1_59_0.tar.gz

cp boost_1_59_0 /usr/local/boost

#创建运行用户

groupadd MysqL

useradd -r -g MysqL -s /bin/falseMysqL

#编译安装

cmake .-DCMAKE_INSTall_PREFIX=/usr/local/MysqL \

-DMysqL_DATADIR=/usr/local/MysqL/data \

-DDOWNLOAD_BOOST=1 \

-DWITH_BOOST=/usr/local/boost \

-DDEFAULT_CHARSET=utf8mb4 \

-DDEFAULT_COLLATION=utf8mb4_unicode_ci

@H_963_15@make

@H_963_15@make install

#更改权限

chown -R MysqL /usr/local/MysqL

chgrp -R MysqL /usr/local/MysqL

#初始化

cd /usr/local/MysqL/bin

./MysqLd --initialize--user=MysqL --basedir=/usr/local/MysqL --datadir=/usr/local/MysqL/data

#拷贝配置文件

@H_963_15@mv /etc/my.cnf/etc/my.cnf.bak

cd /usr/local/MysqL/support-files

cp my-default.cnf /etc/my.cnf

#启动和关闭

cd /usr/local/MysqL/bin

./MysqLd_safe --user=MysqL

cd /usr/local/MysqL/support-files

./MysqL.server stop

#设置开机启动

cp support-files/MysqL.server /etc/init.d/MysqLd

chmod 755/etc/init.d/MysqLd

chkconfig --add MysqLd

chkconfig --level 345 MysqLd on

service MysqLd start

service MysqLd stop

service MysqLd restart

#修改环境变量

vi/etc/profile

PATH=/usr/local/MysqL/bin:$PATH

export PATH

source/etc/profile

#修改root密码

cd /usr/local/MysqL/bin

./MysqL -uroot-p

MysqL>alter user 'root'@'localhost' identified by '123456';

MysqL>exit;

2.2Nginx安装

安装pcre openssl zlib

#安装依赖

yum install perl(openssl需要)

#安装pcre

cd /usr/local/src

@H_963_15@mkdir /usr/local/pcre

tar zxvf pcre-8.39.tar.gz

cd pcre-8.39

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

@H_963_15@make

@H_963_15@make install

#安装openssl

cd /usr/local/src

@H_963_15@mkdir /usr/local/openssl

tar xvf openssl-1.1.0.tar.gz

cd openssl-1.1.0

./config --prefix=/usr/local/openssl

@H_963_15@make

@H_963_15@make install

#安装zlib

cd /usr/local/src

@H_963_15@mkdir /usr/local/zlib

tar zxvf zlib-1.2.8.tar.gz

cd zlib-1.2.8

./configure --prefix=/usr/local/zlib

@H_963_15@make

@H_963_15@make install

#安装Nginx

#创建运行用户

groupadd www

useradd -g www www -s /bin/false

#编译安装

cd /usr/local/src

tar zxvf Nginx-1.10.2.tar.gz

cd Nginx-1.10.2

./configure --prefix=/usr/local/Nginx --user=www--group=www --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-openssl=/usr/local/src/openssl-1.1.0 --with-zlib=/usr/local/src/zlib-1.2.8 --with-pcre=/usr/local/src/pcre-8.39

@H_639_501@make

@H_963_15@make install

#测试配置文件是否正确

/usr/local/Nginx/sbin/Nginx -t

#启动

/usr/local/Nginx/sbin/Nginx

2.3PHP安装

#安装依赖

yum install libxml2 libxml2-devel curl-devel openjpeg openjpeg-devel openjpeg-libs libjpeg libpng freetype libjpeg-devel libpng-devel freetype-devel mcrypt PHP-mcrypt libmcrypt libmcrypt-devel bzip2 bzip2-devel

#创建运行用户

groupadd -r PHP

useradd -r -g PHP -s /bin/flase PHP

#编译安装

./configure --prefix=/usr/local/PHP --with-mcrypt=/usr/include --with-mhash --with-openssl --enable-MysqLnd --with-MysqLi=MysqLnd --with-pdo-MysqL=MysqLnd --with-gd --with-iconv --with-zlib --enable-zip --enable-inline-optimization --disable-debug --disable-rpath --enable-shared --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-mbregex --enable-mbString --enable-ftp --enable-gd-native-ttf --enable-pcntl --enable-sockets --with-xmlrpc --enable-soap --without-pear --with-gettext --enable-session --with-curl --with-jpeg-dir --with-freetype-dir --enable-opcache --enable-fpm --with-fpm-user=www --with-fpm-group=www --without-gdbm --disable-fileinfo --with-bz2 --enable-maintainer-zts --with-libdir=lib64

@H_963_15@make

@H_963_15@make install

#拷贝配置文件

cp PHP.ini-development /usr/local/PHP/etc/PHP.ini

cp /usr/local/PHP/etc/PHP-fpm.conf.default /usr/local/PHP/etc/PHP-fpm.conf

cp /usr/local/PHP/etc/PHP-fpm.d/www.conf.default /usr/local/PHP/etc/PHP-fpm.d/www.conf

cp -R /usr/local/src/PHP-7.0.12/sapi/fpm/PHP-fpm /etc/init.d/PHP-fpm

#启动@H_35_607@
/etc/init.d/PHP-fpm

chkconfig --add PHP-fpm

chkconfig PHP-fpm on

#配置Nginx代理PHP实现访问

通过上面的操作NginxPHP-fpm服务都被我们跑起来了,但是PHP-fpm走的是127.0.0.1:9000,外网是无法访问的,而且我们也不可能直接通过PHP-fpm给外网提供服务,我们用Nginx去代理9000端口执行PHP

实际上这个过程只需要对Nginx进行配置即可,fpm已经在后台运行了,我们需要在Nginx配置文件增加代理的规则,即可让用户在访问80端口,请求PHP的时候,交由后端的fpm去执行,并返回结果。

vi /usr/local/Nginx/conf/Nginx.conf

把前面的#注释符号去掉,把script改为$document_root最终如下:

LOCATIOn ~ \.PHP$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.PHP;

fastcgi_param SCRIPT_FILename /$document_root$fastcgi_script_name;

include fastcgi_params;

}

这样就OK了,重新载入Nginx配置即可

大佬总结

以上是大佬教程为你收集整理的CentOS6.8编译安装Nginx1.10.2+MySQL5.7.16+PHP7.0.12全部内容,希望文章能够帮你解决CentOS6.8编译安装Nginx1.10.2+MySQL5.7.16+PHP7.0.12所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。