Rumah >pembangunan bahagian belakang >tutorial php >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):
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部分
MySql
1. 直接将解压后的目录移至/usr/local/mysql
2. 进入/usr/local/mysql目录,执行以下一系列命令(来源于Mysql官网文档:http://dev.mysql.com/doc/refman/5.6/en/binary-installation.html):
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
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-dir=/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-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear --with-zlib --enable-pdo --with-pdo-mysql
4. 编译安装(在上一步配置过程中无报错的情况下才开始此步骤):
# make && make install