首页 > 代码库 > Linux编译安装PHP Mysql Nginx
Linux编译安装PHP Mysql Nginx
安装gcc g++等编译器
yum -y install gcc gcc-c++ automake autoconf libtool glibc make
安装一些lnmp依赖的库
yum -y install libmcrypt-devel mhash-devel libxslt-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel e2fsprogs e2fsprogs-devel krb5 krb5-devel libidn libidn-devel openssl openssl-devel
好像centos 6.0 后都yum 安装不了libmcrypt了
不解决这个问题,编译不了php,~~~~安装libmcrypt
tar -zxvf libmcrypt-2.5.7.tar.gz
./configure --prefix=/usr/local/libmcrypt
make && make install
-----------------------------------------------------------------------------------
make[2]: Leaving directory `/usr/local/src/libmcrypt-2.5.7/src‘
Making all in doc
make[2]: Entering directory `/usr/local/src/libmcrypt-2.5.7/doc‘
make[2]: Nothing to be done for `all‘.
make[2]: Leaving directory `/usr/local/src/libmcrypt-2.5.7/doc‘
make[2]: Entering directory `/usr/local/src/libmcrypt-2.5.7‘
make[2]: Leaving directory `/usr/local/src/libmcrypt-2.5.7‘
make[1]: Leaving directory `/usr/local/src/libmcrypt-2.5.7‘
-----------------------------------------------------------------------------
报这个错没关系,只要不是error就行,这个提示的意思是离开当前目录的意思。
安装PHP
下载地址:http://php.net/downloads.php
tar -zxvf php-5.4.21.tar.gzcd php-5.4.21
./configure --prefix=/usr/local/php --enable-fpm --with-mcrypt=/usr/local/libmcrypt --enable-mbstring --disable-pdo --with-curl --disable-debug --disable-rpath --enable-inline-optimization --with-bz2 --with-zlib --enable-sockets --enable-sysvsem --enable-sysvshm --enable-pcntl --enable-mbregex --with-mhash --enable-zip --with-pcre-regex --with-mysql --with-mysqli --with-gd --with-jpeg-dir
若出现报错 参考 http://www.cnblogs.com/wangxusummer/p/4094340.html
make && make install
添加www用户组,添加www用户,并将www用记添加到www用户组
groupadd wwwuseradd -g www www
拷贝php-fpm配置文件
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
更改配制文件
vim etc/php-fpm.conf
25 行前面分号去掉 pid为php-fpm产生的进程号
148 149行,user group 都改为www
pid = run/php-fpm.pid user = www group = www
拷贝php配置文件 到php默认的配置文件路径
cp php.ini-production /usr/local/php/lib/php.ini
ln -s /usr/local/php/bin/php /usr/bin/php
测试
php -r "echo date(‘Y-m-d H:i:s‘);"
若出现时区错误
更改配制文件
vim /usr/local/php/etc/php.ini
919 行,时区改为PRC,就是中华人民共和国。
date.timezone = PRC
安装 nginx
Linux编译安装PHP Mysql Nginx