设为首页 收藏本站
查看: 873|回复: 0

Cent OS 中LNMP 环境源码搭建

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2015-4-3 08:37:29 | 显示全部楼层 |阅读模式
LNMP代表的就是:Linux系统下Nginx+MySQL+PHP这种网站服务器架构。    Nginx是一个小巧而高效的Linux下的Web服务器软件,是由 Igor Sysoev 为俄罗斯访问量第二的Rambler 站点开发的,已经在一些俄罗斯的大型网站上运行多年,相当的稳定。Nginx性能稳定、功能丰富、运维简单、处理静态文件速度快且消耗系统资源极少。

本案环境与说明:
环境
1
2
3
[iyunv@bright ~]# cat /etc/centos-release && uname -r
CentOS release 6.6 (Final)
2.6.32-504.el6.x86_64



软件版本:
1
2
3
4
mysql-5.7.6-m16-linux-glibc2.5-x86_64.tar.gz
nginx-1.7.8.tar.gz
libmcrypt-2.5.6.tar.gz  
php-5.6.6.tar.gz



文中所用软件下载地址:
http://mirrors.sohu.com/
http://mirrors.cnnic.cn/apache/
ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt

Nginx 安装前的准备
wget http://mirrors.sohu.com/mysql/My ... bc2.5-x86_64.tar.gz
wget http://mirrors.sohu.com/php/php-5.6.6.tar.gz
wget ftp://mcrypt.hellug.gr/pub/crypt ... mcrypt-2.5.6.tar.gz
wget http://mirrors.sohu.com/nginx/nginx-1.7.8.tar.gz

安装MySQL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
[iyunv@bright ~]# useradd -s /sbin/nologin mysql
[iyunv@bright ~]# tar zxvf mysql-5.7.6-m16-linux-glibc2.5-x86_64.tar.gz
[iyunv@bright ~]# cd /usr/local/
[iyunv@bright local]# mv /root/mysql-5.7.6-m16-linux-glibc2.5-x86_64 .
[iyunv@bright local]# ln -s mysql-5.7.6-m16-linux-glibc2.5-x86_64 mysql
[iyunv@bright local]# cd mysql
[iyunv@bright mysql]# mkdir /data/mysql
[iyunv@bright mysql]# chown -R root .
[iyunv@bright mysql]# chown -R mysql /data/mysql
[iyunv@bright mysql]# chgrp -R mysql .
[iyunv@bright mysql]# bin/mysql_install_db --user=mysql --datadir=/data/mysql
[iyunv@bright mysql]# cp support-files/my-default.cnf /etc/my.cnf
cp:是否覆盖"/etc/my.cnf"? y
[iyunv@bright mysql]# cp support-files/mysql.server /etc/init.d/mysqld
[iyunv@bright mysql]# chmod 755 /etc/init.d/mysqld
[iyunv@bright mysql]# vim /etc/init.d/mysqld
basedir=/usr/local/mysql
datadir=/data/mysql
[iyunv@bright mysql]# chkconfig --add mysqld
[iyunv@bright mysql]# chkconfig mysqld on
[iyunv@bright mysql]# service mysqld start
Starting MySQL. SUCCESS!



安装PHP
1.环境配置
1
2
3
4
5
6
7
8
9
rpm -q libxml2-devel libjpeg-turbo libpng-devel freetype-devel gd-devel libmcrypt-devel openssl-devel
libxml2-devel-2.7.6-14.el6_5.2.x86_64
libjpeg-turbo-1.2.1-3.el6_5.x86_64
libpng-devel-1.2.49-1.el6_2.x86_64
freetype-devel-2.3.11-14.el6_3.1.x86_64
package gd-devel is not installed
package libmcrypt-devel is not installed
openssl-devel-1.0.1e-30.el6.x86_64
[iyunv@bright ~]# yum install gd-devel



本案为配置扩展源,libmcrypt-devel使用tar包安装

1
2
3
4
[iyunv@bright ~]# tar zxvf libmcrypt-2.5.6.tar.gz
[iyunv@bright ~]# cd libmcrypt-2.5.6
[iyunv@bright libmcrypt-2.5.6]# ./configure --prefix=/usr/local/libmcrypt
[iyunv@bright libmcrypt-2.5.6]# make && make install



2.安装php

1
2
3
4
5
6
7
8
9
10
11
12
[iyunv@bright src]# tar zxvf php-5.6.6.tar.gz
[iyunv@bright src]# useradd -s /sbin/nologin php-fpm
[iyunv@bright src]# cd php-5.6.6
[iyunv@bright src]# ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt=/usr/local/libmcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --disable-ipv6 --with-curl
[iyunv@bright php-5.6.6]# make && make install
[iyunv@bright php-5.6.6]# cp php.ini-production /usr/local/php/etc/php.ini
[iyunv@bright php-5.6.6]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
[iyunv@bright php-5.6.6]# mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
[iyunv@bright php-5.6.6]# chmod 755 /etc/init.d/php-fpm
[iyunv@bright php-5.6.6]# chkconfig --add php-fpm
[iyunv@bright php-5.6.6]# chkconfig php-fpm on
[iyunv@bright php-5.6.6]# service php-fpm start



安装nginx
1.环境检查
1
2
[iyunv@bright nginx-1.7.8]# rpm -q pcre-devel
pcre-devel-7.8-6.el6.x86_64



2.安装
1
2
3
4
[iyunv@bright src]# tar nginx-1.7.8.tar.gz
[iyunv@bright src]# cd nginx-1.7.8
[iyunv@bright nginx-1.7.8]# ./configure --prefix=/usr/local/nginx --with-pcre
[iyunv@bright nginx-1.7.8]# make && make install



3.启动
1
2
3
4
5
6
[iyunv@bright conf]# /usr/local/nginx/sbin/nginx     #启动服务
[iyunv@bright conf]# ps -aux | grep nginx
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root      11541  0.0  0.0  24304   668 ?        Ss   00:45   0:00 nginx: master process /usr/local/nginx/sbin/nginx
nobody    11542  0.0  0.1  24728  1248 ?        S    00:45   0:00 nginx: worker process      
root      11544  0.0  0.0 103256   840 pts/0    S+   00:45   0:00 grep nginx



4.配置解析php
1
2
3
4
5
6
7
8
9
10
11
12
[iyunv@bright ~]# vi /usr/local/nginx/conf/nginx.conf  #找如下内容并修改fastcgi_param行
        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        location ~ \.php$ {
            root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME  /usr/local/nginx/html$fastcgi_script_name;
            include        fastcgi_params;
        }
[iyunv@bright ~]# /usr/local/nginx/sbin/nginx -s reload



5.测试
1
2
3
4
5
[iyunv@bright ~]# cat /usr/local/nginx/html/1.php
<?php
    phpinfo();
?>
[iyunv@bright ~]# curl localhost/1.php



运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-53379-1-1.html 上篇帖子: LAMP平台的的构建、加速及压力测试 下篇帖子: LAMP平台的部署
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表