阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 6.4用源代码安装LNMP环境

125次阅读
没有评论

共计 3525 个字符,预计需要花费 9 分钟才能阅读完成。

对于在 Linux 系统中安装 web 服务其实都是差不多的,只是软件的选择不一样,不过在 php-5.2.17 和以前的版本 LNMP 环境和以后安装有一点区别,就是启用 –enable-fastcgi 这个模块。现在我用 php-5.3.27 来搭建 LNMP 环境,对于搭建不成功的网友们希望给我留言,大家一起解决问题,一起进步。

1. 安装 Linux 系统    – 这一步省略

2. 安装 nginx 服务
[root@RedHat1 samba]# tar xvf nginx-1.3.13.tar.gz
[root@redhat1 samba]# cd nginx-1.3.13
[root@redhat1 nginx-1.3.13]# ./configure –prefix=/usr/local/nginx  -user=nginx –group=nginx  –with-http_sub_module –with-http_gunzip_module  –without-http_rewrite_module –without-http_proxy_module –without-http_upstream_ip_hash_module
[root@redhat1 nginx-1.3.13]# make && make install
[root@redhat1 nginx-1.3.13]# echo $?
0
[root@redhat1 nginx-1.3.13]# cd /usr/local/nginx/sbin/
[root@redhat1 sbin]# ./nginx
[root@redhat1 sbin]# netstat -an |grep 80
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                  LISTEN
[root@redhat1 sbin]#

3. 测试 nginx 服务是否正常启动

CentOS 6.4 用源代码安装 LNMP 环境

2. 安装 MySQL 数据库软件
[root@redhat1 samba]# tar xvf mysql-5.1.51.tar.gz
[root@redhat1 samba]# cd mysql-5.1.51
[root@redhat1 mysql-5.1.51]# ./configure –prefix=/usr/local/mysql-5.1
[root@redhat1 mysql-5.1.51]# make && make install
[root@redhat1 mysql-5.1.51]# cd /usr/local/mysql-5.1/bin  – 进入安装 mysql 目录
[root@redhat1 bin]# ./mysqld_safe &    – 启动数据库
[root@redhat1 bin]# netstat -an | grep 3306    – 检查 mysql 是否启动
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                  LISTEN
[root@redhat1 bin]# mysql -u root -p  – 登陆数据库, 密码为空
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 108
Server version: 5.1.51-log Source distribution
Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and Redistribute it under the GPL v2 license
Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.
mysql>

3. 安装 php 软件
[root@redhat1 samba]# tar xvf php-5.3.27.tar.gz
[root@redhat1 samba]# cd php-5.3.27
[root@redhat1 php-5.3.27]# ./configure –prefix=/usr/local/php-5.3.27 –enable-fpm –with-gd –with-mysql=/usr/local/mysql5.1/ –with-mysqli=/usr/local/mysql5.1/bin/mysql_config  –with-png-dir –with-jpeg-dir  –with-zlib  –with-ldap –with-curl –with-snmp –with-freetype-dir
[root@redhat1 php-5.3.27]# make && make install
[root@redhat1 php-5.3.27]# cd /usr/local/php-5.3.27/etc/
[root@redhat1 etc]# cp -a php-fpm.conf.default php-fpm.conf
[root@redhat1 etc]# cp /home/samba/php-5.3.27/php.ini-development  php.ini

4.nginx 和 php 相接合
[root@redhat1 etc]# cd /usr/local/nginx/conf/
[root@redhat1 conf]# vim nginx.conf    – 去掉以下注释
location ~ \.php$ {
root          html;
fastcgi_pass  127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
include        fastcgi_params;
}
[root@redhat1 conf]# vim ../html/index.php    – 创建 php 首页文件
<?php
phpinfo();
?>

5. 启动服务,并测试 
[root@redhat1 conf]# /usr/local/php-5.3.27/sbin/php-fpm
[root@redhat1 conf]# /usr/local/nginx/sbin/nginx
[root@redhat1 conf]# netstat -an |more
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address              Foreign Address            State
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                  LISTEN
tcp        0      0 0.0.0.0:80                  0.0.0.0:*                  LISTEN

CentOS 6.4 用源代码安装 LNMP 环境

相关阅读:

Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置 http://www.linuxidc.com/Linux/2013-06/86250.htm

CentOS 6.4 下的 LNMP 生产环境搭建及安装脚本 http://www.linuxidc.com/Linux/2013-11/92428.htm

生产环境实用之 LNMP 架构的编译安装 +SSL 加密实现 http://www.linuxidc.com/Linux/2013-05/85099.htm

LNMP 全功能编译安装 for CentOS 6.3 笔记 http://www.linuxidc.com/Linux/2013-05/83788.htm

CentOS 6.3 安装 LNMP (PHP 5.4,MyySQL5.6) http://www.linuxidc.com/Linux/2013-04/82069.htm

在部署 LNMP 的时候遇到 Nginx 启动失败的 2 个问题 http://www.linuxidc.com/Linux/2013-03/81120.htm

Ubuntu 安装 Nginx php5-fpm MySQL(LNMP 环境搭建) http://www.linuxidc.com/Linux/2012-10/72458.htm

更多 CentOS 相关信息见 CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计3525字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中