一、准备工作

上pkgs.org下载rmpforge。rpmforge是一个第三方yum源。

选择相应的版本下载安装。

// 安装成功后,清空yum list 并 重新获取

[root@pangou Desktop]# yum clean all

Loaded plugins: fastestmirror, refresh-packagekit, security

Cleaning repos: base extras rpmforge updates

Cleaning up Everything

Cleaning up list of fastest mirrors

[root@pangou Desktop]# yum -y list

Loaded plugins: fastestmirror, refresh-packagekit, security

Determining fastest mirrors

// ......

卸载已存在的apache服务和php

[root@pangou Desktop]# yum remove httpd php*

安装development Tools

[root@pangou Desktop]# yum -y groupinstall "Development Tools"

二、安装nginx

创建nginx目录,下载nginx,并解压缩

[root@pangou Downloads]# mkdir nginx

[root@pangou Downloads]# cd nginx/

[root@pangou nginx]# pwd

/root/Downloads/nginx

[root@pangou nginx]# wget http://nginx.org/download/nginx-1.4.0.tar.gz

--2013-04-30 23:13:44-- http://nginx.org/download/nginx-1.4.0.tar.gz

Resolving nginx.org... 206.251.255.63

Connecting to nginx.org|206.251.255.63|:80... connected.

HTTP request sent, awaiting response... 200 OK

Length: 773451 (755K) [application/octet-stream]

Saving to: “nginx-1.4.0.tar.gz”

100%[================================================================>] 773,451 184K/s in 4.5s

2013-04-30 23:13:48 (166 KB/s) - “nginx-1.4.0.tar.gz” saved [773451/773451]

[root@pangou nginx]# ls

nginx-1.4.0.tar.gz

[root@pangou nginx]# tar -zxvf nginx-1.4.0.tar.gz

[root@pangou nginx]# ls

nginx-1.4.0 nginx-1.4.0.tar.gz

编译安装nginx

// 编译 安装路径/opt/nginx

[root@pangou nginx-1.4.0]# ./configure --prefix=/opt/nginx/

编译中如出现报错如:

./configure: error: the HTTP rewrite module requires the PCRE library.

You can either disable the module by using --without-http_rewrite_module

option, or install the PCRE library into the system, or build the PCRE library

statically from the source with nginx by using --with-pcre= option.

就是用yum自行结局依赖关系

[root@pangou nginx-1.4.0]# yum install pcre pcre-devel

然后重新上面的编译

// 编译 安装路径/opt/nginx

[root@pangou nginx-1.4.0]# ./configure --prefix=/opt/nginx/

// 编译成功后

[root@pangou nginx-1.4.0]# make && make install

// 最后安装完成

启动nginx服务

[root@pangou nginx]# cd /opt/nginx/sbin/

[root@pangou sbin]# ./nginx

访问127.0.0.1

服务启动成功。

三、安装php

创建文件夹php,下载php,并解压缩

[root@pangou nginx-1.4.0]# cd /root/Downloads/

[root@pangou Downloads]# mkdir php

[root@pangou Downloads]# cd php/

[root@pangou php]# pwd

/root/Downloads/php

// 下载

[root@pangou php]# wget http://cn2.php.net/get/php-5.4.14.tar.gz/from/this/mirror

// 解压

[root@pangou php]# tar -zxvf php-5.4.14.tar.gz

安装依赖包

[root@pangou php]# yum install -y libxml2-devel libjpeg-devel libpng-devel freetype-devel openssl-devel libcurl-devel libmcrypt-devel

编译php

[root@pangou php]# ls

php-5.4.14 php-5.4.14.tar.gz

[root@pangou php]# cd php-5.4.14

[root@pangou php-5.4.14]# pwd

/root/Downloads/php/php-5.4.14

[root@pangou php-5.4.14]# ls

acinclude.m4 CREDITS ltmain.sh NEWS README.MAILINGLIST_RULES README.TESTING stamp-h.in

aclocal.m4 ext main pear README.namespaces README.TESTING2 stub.c

build EXTENSIONS makedist php5.spec.in README.NEW-OUTPUT-API README.UNIX-BUILD-SYSTEM svnclean.bat

buildconf footer Makefile.frag php.gif README.PARAMETER_PARSING_API README.WIN32-BUILD-SYSTEM tests

buildconf.bat generated_lists Makefile.gcov php.ini-development README.PHP4-TO-PHP5-THIN-CHANGES run-tests.php TSRM

CODING_STANDARDS genfiles Makefile.global php.ini-production README.REDIST.BINS sapi UPGRADING

config.guess header makerpm README.EXTENSIONS README.RELEASE_PROCESS scripts UPGRADING.INTERNALS

config.sub INSTALL missing README.EXT_SKEL README.SELF-CONTAINED-EXTENSIONS server-tests-config.php vcsclean

configure install-sh mkinstalldirs README.GIT-RULES README.STREAMS server-tests.php win32

configure.in LICENSE netware README.input_filter README.SUBMITTING_PATCH snapshot Zend

[root@pangou php-5.4.14]# ./configure --prefix=/opt/php --with-config-file-path=/opt/php/etc --with-mysql=/usr/ --with-mysqli=/usr/bin/mysql_config --with-iconv-dir --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-discard-path --enable-magic-quotes --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 --enable-ftp --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magic

// 编译时间可能有点长。。。

// 编译成功后,安装

[root@pangou php-5.4.14]# make && make install

// 安装时间也比较长

安装成功后,php的位置就应该在/opt/php目录下,接下去就是配置

// 复制配置文件到配置目录下

[root@pangou php-5.4.14]# cp /root/Downloads/php/php-5.4.14/php.ini-production /opt/php/etc/php.ini

[root@pangou php-5.4.14]# cp /opt/php/etc/php-fpm.conf.default /opt/php/etc/php-fpm.conf

[root@pangou php-5.4.14]# cd /opt/php/etc/

[root@pangou etc]# ls

php-fpm.conf php-fpm.conf.default php.ini

// 然后配置nginx的配置文件,让其可以运行php

[root@pangou etc]# cd /opt/nginx/conf/

[root@pangou conf]# ls

fastcgi.conf fastcgi_params koi-utf mime.types nginx.conf scgi_params uwsgi_params win-utf

fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default scgi_params.default uwsgi_params.default

[root@pangou conf]# vim nginx.conf

1、去掉 #user nobody; 的#号, 变成 user nobody;

2、去掉

#location ~ \.php$ {

# root html;

# fastcgi_pass 127.0.0.1:9000;

# fastcgi_index index.php;

# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

# include fastcgi_params;

#}

之前的#号,

并修改

fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

[/cfastcgi_param SCRIPT_FILENAME /opt/nginx/html$fastcgi_script_name;

ode]

最终修改后的内容为:

[code]

location ~ \.php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME /opt/nginx/html$fastcgi_script_name;

include fastcgi_params;

}

重启nginx服务,并开启php-fpm

[root@pangou ~]# /opt/nginx/sbin/nginx

[root@pangou ~]# /opt/php/sbin/php-fpm

// 创建phpinfo文件

[root@pangou ~]# vim /opt/nginx/html/phpinfo.php

内容为

phpinfo();

?>

访问http://127.0.0.1/phpinfo.php

安装成功。mysql,mysqli等扩展都有。

这边有一点偷懒,并没有编译安装mysql,而是使用yum安装的mysql。

centos系统php环境配置,CentOS 6.4系统下编译安装LNMP和配置PHP环境具体步骤相关推荐

  1. centos 6 mysql 5.7.13 编译安装_Centos 6.5系统下编译安装PHP 7.0.13的方法

    PHP7.0正式版也出来了,今天编译安装了一下,写下安装步骤,我是在centos6.6 环境中编译的,下面是详细的安装步骤 环境依赖 yum install gcc gcc-c++ libxml2 l ...

  2. centos 编译mysql5.6_centos下编译安装MySQL5.6

    ,虚拟机centos6.5mini 网络适配器"桥接模式" 继续上一次的Apache编译后,编译安装MySQL5.6 MySQL5.6和以前的版本不同之处在于用cmake就行编译, ...

  3. linux nginx编译安装mysql_Centos7下编译安装配置Nginx+PHP+MySql环境

    序言 这次玩次狠得.除了编译器使用yum安装,其他全部手动编译.哼~ 看似就Nginx.PHP.MySql三个东东,但是它们太尼玛依赖别人了. 没办法,想用它们就得老老实实给它们提供想要的东西. 首先 ...

  4. CentOS 7.6编译安装LNMP

    一.前期准备 1.服务器以最小化方式安装CentOS 7.6 2.配置本地源及安装epel源 #cd /etc/yum.repos.d #vi CentOS-Base.repo 增加enable=1 ...

  5. CentOS 6下编译安装Nginx

    CentOS 6下编译安装Nginx  By:老宁 一.准备make环境  yum -y install gcc gcc-c++ automake autoconf libtool make 二.准备 ...

  6. nginx 怎么重新编译安装mysql,centos 下 编译安装 nginx + mysql + php 服务

    centos 下编译安装nginx + mysql + php 服务 1.安装nginx 1.1.安装依赖包 yum install wget make gcc gcc-c++ pcre-devel ...

  7. 在 CentOS 5.4 下编译安装MySQL时

    在 CentOS 5.4 下编译安装MySQL时 在 CentOS 5.4 下编译安装MySQL时出错: /bin/rm: cannot remove `libtoolt': No such file ...

  8. CentOS6.9编译安装LNMP环境

    CentOS6.9编译安装LNMP环境 今天尝试一下用编译的方式来搭建lnmp运行环境.所有软件都采用当前最新版本,除了CentOS.这是由于目前企业大多数应该都还在使用CentOS6的缘故,并且Ce ...

  9. 凯歌Java百家号_centos7下静默安装oracle11G图解配置 1

    前言: 本文是<centos7下静默安装oracle11G图解配置>中第一篇.因linux下安装Oracle太过繁琐,如果写在一篇文章中,太长了.本文主要讲解安装前环境配置. Centos ...

最新文章

  1. 腾讯机器人实验室首曝光 攻坚“通用人工智能”
  2. Juniper SRX IPsec *** base route CLI
  3. python sys模块 输入输出 错误流
  4. 搜狐的财报背后:视频“吸血”,游戏与搜索“供血”,能否再成就张朝阳的理想主义?
  5. jvm 参数_6个提高性能的JVM参数
  6. AVEVA软件编程是C语言么,AVEVA PDMS 三维文字工具
  7. python中tmp什么意思_python中temp是什么意思-问答-阿里云开发者社区-阿里云
  8. 解析 PowerJob 的序列化方案
  9. MySql_SQLyog快捷键
  10. UIKit 框架之UIAlertController
  11. IntelliJ IDEA 必备的快捷键大全
  12. 显示文件内容时显示行号命令nl
  13. 世界500强榜单出炉:中国公司首进三强 沃尔玛居首
  14. 【CLR】程序集查找与GAC
  15. /usr/bin/ld cannot find -lGL
  16. 无线网ppp服务器失败怎么办,【妙招】不能上网怎么办,史上最全宽带故障简单处理办法!...
  17. 618年中大促 ,全场6折起!限量周边8件套!
  18. cas66-71-7|1,10-菲啰啉有机配体/ 1,10-Phen/邻菲啰啉/邻二氮杂菲
  19. Node.js知识点整理之----Buffer类
  20. 没学历的IT人生没那么悲催,献给程序员们

热门文章

  1. build.gradle里dependencies标签页的实现原理
  2. SAP UI5 web Component里的条件渲染机制
  3. 如何让Excel里显示的数字避免通过科学计数法来显示
  4. Where is number of opportunities not displayed message poped up
  5. SAP UI5 subscribe event实现原理
  6. SAP S/4HANA product search generated SQL statement的生产原理介绍
  7. SAP external long material id的奥妙
  8. use SAP web IDE to commit change to git
  9. 如何找到SAP S4销售订单的字段tkomk是在哪里填充的
  10. web service security profile的设计