您的位置:首页 > 运维架构 > Nginx

CentOS6.8编译安装Nginx1.10.2+MySQL5.7.16+PHP7.0.12

2016-11-01 16:10 399 查看
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.gz2. 安装
2.1 MySQL安装
#安装所需依赖yum install gcc gcc-c++ cmakencurses ncurses-devel bison#下载boost http://www.boost.org/users/download/tar zxf boost_1_59_0.tar.gzcp boost_1_59_0 /usr/local/boost#创建运行用户groupadd mysqluseradd -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_cimakemake install#更改权限chown -R mysql /usr/local/mysqlchgrp -R mysql /usr/local/mysql#初始化cd /usr/local/mysql/bin./mysqld --initialize--user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data#拷贝配置文件mv /etc/my.cnf/etc/my.cnf.bakcd /usr/local/mysql/support-filescp my-default.cnf /etc/my.cnf#启动和关闭cd /usr/local/mysql/bin./mysqld_safe --user=mysqlcd /usr/local/mysql/support-files./mysql.server stop#设置开机启动cp support-files/mysql.server /etc/init.d/mysqldchmod 755/etc/init.d/mysqldchkconfig --add mysqldchkconfig --level 345 mysqld on service mysqld startservice mysqld stopservice mysqld restart#修改环境变量vi/etc/profile PATH=/usr/local/mysql/bin:$PATHexport PATHsource/etc/profile#修改root密码cd /usr/local/mysql/bin./mysql -uroot-p mysql>alter user 'root'@'localhost' identified by '123456';mysql>exit;2.2 Nginx安装
安装pcre openssl zlib#安装依赖yum install perl(openssl需要)#安装pcrecd /usr/local/srcmkdir /usr/local/pcretar zxvf pcre-8.39.tar.gzcd pcre-8.39./configure --prefix=/usr/local/pcremakemake install#安装opensslcd /usr/local/srcmkdir /usr/local/openssltar xvf openssl-1.1.0.tar.gzcd openssl-1.1.0./config --prefix=/usr/local/opensslmakemake install#安装zlibcd /usr/local/srcmkdir /usr/local/zlibtar zxvf zlib-1.2.8.tar.gzcd zlib-1.2.8./configure --prefix=/usr/local/zlibmakemake install#安装Nginx#创建运行用户groupadd wwwuseradd -g www www -s /bin/false#编译安装cd /usr/local/srctar zxvf nginx-1.10.2.tar.gzcd 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 makemake install#测试配置文件是否正确 /usr/local/nginx/sbin/nginx -t#启动/usr/local/nginx/sbin/nginx2.3 PHP安装
#安装依赖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 phpuseradd -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=lib64makemake install#拷贝配置文件cp php.ini-development /usr/local/php/etc/php.inicp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.confcp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf cp /usr/local/src/php-7.0.12/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm#启动
/etc/init.d/php-fpmchkconfig --add php-fpmchkconfig php-fpm on#配置Nginx代理PHP实现访问通过上面的操作,nginx和php-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配置即可
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql 用户 下载地址