nginx php 安装

时间:2019-06-22 05:12来源:计算机教程
.选定源码目录 选定目录 /data/klj/ 网上搜来的教程如下 cd /data/klj/ 复制代码 代码如下: 2.安装PCRE库 cd /data/klj/ wgetftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz tar -zxvf pcre-8.21.ta

.选定源码目录
选定目录 /data/klj/

网上搜来的教程如下

cd /data/klj/

复制代码 代码如下:

2.安装PCRE库
cd /data/klj/
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz
tar -zxvf pcre-8.21.tar.gz
cd pcre-8.21
./configure
make
make install

yum -y install gcc gcc-c automake autoconf libtool glibc make
libmcrypt安装
mkdir /usr/local/source && cd /usr/local/source #创建并进入源文件目录
[root@localhost source ]# wget "http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz?modtime=1171868460&big_mirror=0 #下载libmcrypt
[root@localhost source ]# mv libmcrypt-2.5.7.tar.gz?modtime=1171868460&big_mirror=0 libmcrypt-2.5.7.tar.gz #重命名
tar – –zxvf libmcrypt-2.5.7.tar.gz #解压
cd libmcrypt-2.5.7 #进入解压目录
./configure --prefix=/usr/local/libmcrypt && make && make install #安装

3.安装zlib库
cd /data/klj/
wget http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2.8
./configure
make
make install

因为编译安装libmcrypt一直出错,运行rpm –q libmcrypt 查看安装的rpm包 发现失败

4.安装ssl

所以参考了另一篇安装lnmp的文章

cd /data/klj/
wget http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz
./config
make
make install

复制代码 代码如下:

5.安装nginx

yum -y install gcc gcc-c autoconf 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 openldap openldap-devel nss_ldap openldap-clients openldap-servers libXpm* #下载安装编译工具和依赖包
yum -y update #更新yum
下载安装包
mkdir /tmp/source
cd /tmp/source
wget http://nginx.org/download/nginx-1.7.8.tar.gz #最新
wget http://cn2.php.net/distributions/php-5.4.35.tar.bz2#php5.4稳定版 因为php5.5不支持mysql扩展了,暂时不用最新的
wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.22.tar.gz #mysql5.6
wget http://downloads.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz?r=http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/&ts=1418528625&use_mirror=tcpdiag
mv libmcrypt-2.5.8.tar.gzvnsc5858威尼斯城官网,?r=http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/ libmcrypt-2.5.8.tar.gz #删除多余参数的文件名
wget https://ftp.gnu.org/gnu/libiconv/libiconv-1.14.tar.gz
wget http://downloads.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gz?r=http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/&ts=1418530194&use_mirror=hivelocity
mv mhash-0.9.9.9.tar.gz?r=http://sourceforge.net/projects/mhash/files/mhash/0.9.9.9/ mhash-0.9.9.9.tar.gz #删除多余参数的文件名
wget http://downloads.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz?r=http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/&ts=1418531968&use_mirror=softlayer-dal
mv mcrypt-2.6.8.tar.gz?r=http://sourceforge.net/projects/mcrypt/files/MCrypt/2.6.8/ mcrypt-2.6.8.tar.gz #删除多余参数的文件名
wget http://ftp.gnu.org/gnu/bison/bison-3.0.tar.gz
###暂没有下载 memcache pcre eaccelerator

Nginx 一般有两个版本,分别是稳定版和开发版,您可以根据您的目的来选择这两个版本的其中一个,下面是把 Nginx 安装到 /usr/local/nginx 目录下的详细步骤:

安装libiconv、libmcrypt、(#没安装libltdl)、mhash、(#安装make没效果mcrypt),bison

cd /data/klj/
wget http://nginx.org/download/nginx-1.7.8.tar.gz
tar -zxvf nginx-1.2.8.tar.gz
cd nginx-1.2.8
./configure --with-pcre=/data/klj/pcre-8.21 --with-zlib=/data/klj/zlib-1.2.8 --with-openssl=/data/klj/openssl-1.0.1c --prefix=/usr/local/nginx
make
make install

复制代码 代码如下:

安装php
下载php安装包
wget http://cn2.php.net/get/php-5.6.3.tar.gz/from/this/mirror

  845  tar zxvf libmcrypt-2.5.8.tar.gz
  846  cd libmcrypt-2.5.8
  847  ./configure --prefix=/usr/local/libmcrypt
  848  make && make install
 836  tar zxvf libiconv-1.14.tar.gz
 837  cd libiconv-1.14
 838  ./configure --prefix=/usr/local
 839  make && make install
  850  tar zxvf mhash-0.9.9.9.tar.gz
  851  cd mhash-0.9.9.9
  854  ./configure --prefix=/usr/mhash
  855  make && make install

tar -zxvf php-5.6.3.tar.gz
cd php-5.6.3

安装cmake

./configure --prefix=/data/klj/php --with-config-file-path=/data/klj/php/etc --with-mysql --with-mysqli --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 --enable-pdo --with-pdo-mysql=mysqlnd

复制代码 代码如下:

./configure --prefix=/data/klj/php --with-config-file-path=/data/klj/php/etc --with-mysql --with-mysqli --enable-mbstring --enable-sockets --enable-pcntl --enable-zip --enable-bcmath --with-zlib-dir --with-bz2 --with-freetype-dir --with-gd --with-libxml-dir --with-png-dir --with-jpeg-dir=/usr/local/jpeg --enable-mbstring --with-mcrypt --with-curl --enable-fasecgi --enable-fpm

cd /tmp/
tar zxvf cmake-2.8.3.tar.gz
cd cmake-2.8.3/
./configure --prefix=/usr
gmake
gmake install

 

准备用户、目录

 

复制代码 代码如下:

error 5

groupadd mysql
useradd -g mysql mysql
groupadd www
useradd -g www www
mkdir -p /data/mysql
chown -R mysql:mysql /data/mysql
mkdir -p /data/www
chown -R www:www /data/www

checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... yes
checking for floorf... yes
configure: error: jpeglib.h not found
GD库没有安装
解决办法
yum install libjpeg.x86_64 libpng.x86_64 freetype.x86_64 libjpeg-devel.x86_64 libpng-devel.x86_64 freetype-devel.x86_64 -y

安装mysql

1)去网站 http://www.ijg.org/ 下载源码。我用的版本是jpegsrc.v8d.tar.gz,执行命令:sudo tar -zxvf jpegsrc.v8d.tar.gz -C /usr/src

编译:

(2)进入/usr/src/jpegsrc.v8d目录,sudo方式执行命令:sudo ./configure --prefix=/usr/local/jpeg;make;make install;

复制代码 代码如下:

(3)重新编译php,增加参数--with-jpeg-dir=/usr/local/jpeg

tar zxvf mysql-5.6.22.tar.gz
cd mysql-5.6.22
cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/data/mysql -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_MEMORY_STORAGE_ENGINE=1 -DWITH_MYISAM_STORAGE_ENGINE=1 -DSYSCONFDIR=/usr/local/mysql/etc/ -DWITH_SSL=yes -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_READLINE=on
make && make install
ln -s /usr/local/mysql/lib/lib* /usr/lib/

 

配置:

再次编译,遇到问题:configure: error: mcrypt.h not found. Please reinstall libmcrypt.

复制代码 代码如下:

(1)去网站http://mcrypt.hellug.gr/lib/index.html 的下载源码,我下的版本是libmcrypt-2.5.7.tar.gz;执行命令:sudo tar -zxvf libmcrypt-2.5.7.tar.gz -C /usr/src

/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql/ --user=mysql

(2)进入/usr/src/libmcrypt-2.5.7目录,sudo方式执行命令:./configure prefix=/usr/local/libmcrypt/;make ;make install

自启动

(3)重新编译php,这时增加参数--with-mcrypt=/usr/local/libmcrypt

复制代码 代码如下:

先安装Libmcrypt

cp /opt/mysql/support-files/mysql.server /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
/etc/rc.d/init.d/mysqld start
cd /opt/mysql/
bin/mysql_secure_installation #设置mysql账号密码

#tar -zxvf libmcrypt-2.5.8.tar.gz
#cd libmcrypt-2.5.8
#./configure
#make
#make install 说明:libmcript默认安装在/usr/local

安装php

3.安装mhash

编译:

#tar -zxvf mhash-0.9.9.9.tar.gz
#cd mhash-0.9.9.9
#./configure
#make
#make install
4.安装mcrypt

复制代码 代码如下:

#tar -zxvf mcrypt-2.6.8.tar.gz
#cd mcrypt-2.6.8
#LD_LIBRARY_PATH=/usr/local/lib ./configure
#make
#make install

mkdir /usr/local/php
cd /usr/local/src
tar zxvf php-5.3.5.tar.gz
cd php-5.3.5
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/opt/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 --disable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --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
./configure --prefix=/usr/local/php  --enable-fpm --with-iconv=/usr/local/bin/libiconv --with-mcrypt=/usr/local/bin/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
make && make install
cp php.ini-development /usr/local/php/etc/php.ini #复制配置文件

此安装主要针对Linux系统
首先要下载三个软件,分别是
libmcrypt-2.5.8.tar.gz
下载地址: 

配置php-fpm

编辑:计算机教程 本文来源:nginx php 安装

关键词: