码迷,mamicode.com
首页 > 其他好文 > 详细

nginx配置

时间:2016-09-05 23:31:23      阅读:234      评论:0      收藏:0      [点我收藏+]

标签:

CentOS 6部署PHP开发环境

适用环境:

CentOS 6.5 32bit

Linux + Nginx + Mysql + PHP

版本与时间:(截至此帖发帖日期2014-10-14,所有版本皆为最新版本)

Nginx-1.7.6

Mysql-5.6.21

PHP-5.6.1

一、下载:

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

mysql:http://dev.mysql.com/downloads/mysql/  (选择Linux - Generic版本的Linux - Generic (glibc 2.5) (x86, 32-bit), Compressed

php:http://php.net/downloads.php#v5.6.1

 

二、安装(忽略解压过程,安装完后默认路径在/usr/local/xxx):

<1> Nginx

1. 安装依赖包:# yum -y install pcre-devel zlib-devel

2. 配置安装:

# ./configure

# make && make install

3. 建立软链接:# ln -s /usr/local/nginx/sbin/nginx /usr/local/bin/

4. 进入/usr/local/nginx/conf目录,建立虚拟主机配置目录,并将此目录导入到nginx.conf中

# mkdir vhost

# vim ./nginx.conf (在最后大括号前添加一行并保存退出: include vhost/*.conf; )

5. 可在vhost目录内新建虚拟主机配置文件,以.conf结尾,内容可参考nginx.conf中的server部分

<2>MySql

1. 直接将解压后的目录移至/usr/local/mysql

2. 进入/usr/local/mysql目录,执行以下一系列命令(来源于Mysql官网文档:http://dev.mysql.com/doc/refman/5.6/en/binary-installation.html):

 

shell> groupadd mysql
shell> useradd -r -g mysql mysql
shell> cd /usr/local
shell> tar zxvf /path/to/mysql-VERSION-OS.tar.gz
shell> ln -s full-path-to-mysql-VERSION-OS mysql
shell> cd mysql
shell> chown -R mysql .
shell> chgrp -R mysql .
shell> scripts/mysql_install_db --user=mysql
shell> chown -R root .
shell> chown -R mysql data
shell> bin/mysqld_safe --user=mysql &
# Next command is optional
shell> cp support-files/mysql.server /etc/init.d/mysql.server

 

3. 配置my.cnf

a. # vim /etc/my.cnf

b. 修改几项(在[mysqld]下):

datadir=/usr/local/mysql/data

socket=/tmp/mysql.sock

character-set-server=utf8

collation-server=utf8_general_ci

c.保存退出,并重启mysql

 

<3>php

1. 安装依赖包:# yum -y install libxml2-devel openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel openldap-devel libmcrypt-devel

2. 建立软链接(解决PHP5.6编译时报Don‘t know how to define struct flock on this system, set --enable-opcache=no的错误):

# sudo ln -s /usr/local/mysql/lib/libmysqlclient.so /usr/lib/
# sudo ln -s /usr/local/mysql/lib/libmysqlclient.so.18 /usr/lib/libmysqlclient.so.18

3. 配置:

# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-zlib --enable-pdo --with-pdo-mysql --enable-opcache

4. 编译安装(在上一步配置过程中无报错的情况下才开始此步骤):

# make && make install

5. 复制启动文件和配置文件

# cp <PHP解压缩目录下>/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

# cp <PHP解压缩目录下>/php.ini-production /usr/local/php/etc/php.ini

# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

# chmod a+x /etc/init.d/php-fpm

最后就可以使用命令来启动PHP了:service php-fpm start

nginx配置

标签:

原文地址:http://www.cnblogs.com/maoaji/p/5843884.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!