LNMP搭建 源码包
LNMP源码包搭建
linux CentOS-6.5-x86_64-bin-DVD1
nginx 版本1.8.0 下载地址:http://nginx.org/en/download.html
mysql 版本5.0.56
php 版本5.6.15
nginx、 mysql 、php对应版本的源码包可以在这里下载:http://pan.baidu.com/s/1sjMOcYL
这些源码包都上传或下载到该目录下: /usr/local/
1.安装nginx
安装之前先安装下各种依赖
# yum -y install zlib-devel pcre-devel openssl-devel gcc
# cd /usr/local
# tar -xf nginx-1.8.0.tar.gz
# cd nginx-1.8.0
# ./configure --prefix=/usr/local/nginx --with-openssl=/usr/include/openssl --with-pcre --with-http_stub_status_module
# make && make install
启动nginx
# /usr/local/nginx/sbin/nginx
查看是否启动
# ps aux | grep nginx
2.安装mysql (注:mysql5.6或者高版本mysql需要cmake编译安装)
安装之前先安装下依赖
# yum -y install ncurses-devel gcc-c++
# useradd -M -s /sbin/nologin mysql
# cd /usr/local
# tar -xf mysql-5.0.56.tar.gz
# cd mysql-5.0.56
# ./configure --prefix=/usr/local/mysql --without-debug --with-extra-charsets=utf8,gbk --enable-assembler --with-mysqld-ldflags=-all-static --with-client-ldflags=-all-static --with-unix-socket-path=/tmp/mysql.sock --with-ssl
# make && make install
#编译的时间比较漫长。。
# cp /usr/local/mysql-5.0.56/support-files/my-medium.cnf /etc/my.cnf
# cp /usr/local/mysql-5.0.56/support-files/mysql.server /etc/init.d/mysqld
# chmod +x /etc/init.d/mysqld
# ln -s /usr/local/mysql/bin/* /usr/local/bin/
# ln -s /usr/local/mysql/lib/mysql/lib* /usr/lib/
# mysql_install_db --user=mysql (mysql 5.6 install表 # /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &)
# chown -R root:mysql /usr/local/mysql/
# chown -R mysql:mysql /usr/local/mysql/var/
# service mysqld start
# mysql
3. 安装php
先安装各种依赖
# yum -y install libxml2 libxml2-devel curl-devel libpng-devel openldap-devel
# cd /usr/local
# tar -xf php-5.6.15.tar.gz
# cd php-5.6.15
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-zlib --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --with-curl --with-curlwrappers --enable-fpm --enable-fastcgi --with-mcrypt --with-gd --with-openssl --with-mhash --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc -enable-zip --enable-soap -enable-mbstring
========================================
可能遇到错误:Cannot find ldap libraries in /usr/lib.
这样解决: # cp -frp /usr/lib64/libldap* /usr/lib/
==========================================
可能遇到错误:configure: error: mcrypt.h not found. Please reinstall libmcrypt
这样解决:
# yum -y install wget
# cd /usr/local
# wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/attic/libmcrypt/libmcrypt-2.5.7.tar.gz
# tar -xf libmcrypt-2.5.7.tar.gz
# cd libmcrypt-2.5.7
# ./configure
# make && make install
================================================
可能遇到错误:configure: error: Don’t know how to define struct flock on this system, set –enable-opcache=no
这样解决: # export LD_LIBRARY_PATH=/lib/:/usr/lib/:/usr/local/lib
===================================================
如果遇到以上问题,解决后,继续
# cd /usr/local/php-5.6.15
# ./configure --prefix=/usr/local/php --with-mysql=/usr/local/mysql/ --with-zlib --enable-xml --disable-rpath --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --with-curl --with-curlwrappers --enable-fpm --enable-fastcgi --with-mcrypt --with-gd --with-openssl --with-mhash --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc -enable-zip --enable-soap -enable-mbstring
# make && make install
编译的时间比较漫长。。
php安装完成
php全局执行命令
# ln -s /usr/local/php/bin/php /usr/bin/
php的配置文件(注意php配置文件原来在源码包里面
# cp /usr/local/php-5.6.15/php.ini-development /usr/local/php/lib/php.ini
php-fpm的配置文件,暂先不改内容:
# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
==================================
解决php命令不是环境变量
这样解决:
第一种方法: # ln -s /usr/local/php/bin/php /usr/bin/ 顺便提示写,软链接的源文件需要从根目录的头开始,比如/usr/local/php/bin/php要写全。
第二种方法:
修改/etc/profile文件,在文件末尾加上如下两行代码
PATH=$PATH:/usr/local/php/bin
export PATH
保存退出后,执行 # source /etc/profile
=======================================
现在lnmp基本搭建完成。
启动php-fpm,这个就是nginx和php进行通信用
# /usr/local/php/sbin/php-fpm
默认开启9000端口,可以通过查看是否已开启
# netstat -anp | grep 9000
配置nginx,编辑nginx配置文件
# vi /usr/local/nginx/conf/nginx.conf
主要修改一下内容:
server {
listen 80;
server_name www.lnmp.com; #这里随意起一个域名,然后在访问的机器上配置下自己的hosts
location / {
root /data/www; #网站的目录
index index.php index.html index.htm;
}
location ~ \.php$ {
root /data/www;
fastcgi_pass 127.0.0.1:9000; # 这个9000端口就是php-fpm的使用端口
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name; #这个地方注意下$document_root...
include fastcgi_params;
}
}
改完配置后,启动nginx
# /usr/local/nginx/sbin/nginx
如果报错说已经开启了。。
可以这样解决:
# pkill -9 nginx
然后再启动。
=====
有些安装软件的过程中使用了root,可能出现没权限的报错。最好用一个非root帐号,比如一个work帐号
例如nginx、php都可以搞成work工作。启动nginx如果用80帐号,work权限不够,可以sudo一下。
chown -R work:work /usr/local/php/
chown -R work:work /usr/local/nginx/
=====
可以在/data/www写一个测试内容
# mkdir -p /data/www
# cd /data/www
# vi index.php
比如这样
<?php
phpinfo();
?>
这样就可以访问http://www.lnmp.com了~
如果访问不了,有可能linux上有防火墙限制。可以关闭下
# service iptables stop
再访问下试试哈哈~
恭喜成功!!~~
-----------------------yum安装LNMP--------------
yum install -y nginx
yum install -y mysql mysql-server mysql-devel
yum install -y php php-fpm php-mysql php-gd php-mbstring php-mcrypt
LNMP搭建 源码包的更多相关文章
- Lnmp环境源码包编辑安装
最近做了一个小工具可以方便的部署LNMP环境,有兴趣的同学可以尝试下: 这是一个集成的shell脚本,脚本将会自动安装好LNMP环境相关软件: 使用步骤 1.下载脚本源码到本地 git clone h ...
- CentOS 7.0源码包搭建LNMP方法分享(实际环境下)
CentOS 7.0编译安装Nginx1.6.0+MySQL5.6.19+PHP5.5.14 一.配置防火墙,开启80端口.3306端口 CentOS 7.0默认使用的是firewall作为防火墙,这 ...
- LNMP架构源码搭建(centos7)
第一步:安装nginx 1.上传或下载nginx,并解压 yum -y install lrzsz rz .tar.gz 2.搭建nginx安装环境 yum -y install gcc-c++ zl ...
- LAMP 环境搭建之源码包编译安装
mysql用的二进制包安装. Apache php 用的源码包 mysql版本5.5.46 Apache版本2.4.7 PHP版本:5.5 mysql安装部分参考了阿铭linux的内容. 这是 ...
- nginx + mysql + php相关源码包及安装
nginx + mysql + php安装 引言 完整的搭建一个nginx+php-fpm+mysql的服务器,一直是我向做的,不过一致没有完成过,这次工作需要,终于安装成功了 我列出了我遇到的一些问 ...
- 烂泥:Linux源码包制作RPM包之Apache
本文由秀依林枫提供友情赞助,首发于烂泥行天下 公司服务器比较多,需要把apache源码包制作成rpm包,然后放到公司内网yum源上进行下载安装.apache的rpm包安装方式比源码安装方式比较快,这能 ...
- LAMP环境 源码包安装
linux的学习很早就开始了,大学的时候的时候有有学过unix,后来每年都有去看看linux,因为在小城市的缘故,很少会实际工作中用到,基本都是智慧云之类的,同事也说,你学起来也用不上,IT生态不好, ...
- hadoop2.6.0汇总:新增功能最新编译 32位、64位安装、源码包、API下载及部署文档
相关内容: hadoop2.5.2汇总:新增功能最新编译 32位.64位安装.源码包.API.eclipse插件下载Hadoop2.5 Eclipse插件制作.连接集群视频.及hadoop-eclip ...
- Linux系列教程(十三)——Linux软件包管理之源码包、脚本安装包
上篇博客我们讲解了网络yum源和光盘yum源的搭建步骤,然后详细介绍了相关的yum命令,yum 最重要是解决了软件包依赖性问题.在安装软件时,我们使用yum命令将会简单方便很多.我们知道yum命令只能 ...
随机推荐
- CSS十大选择器
CSS十大选择器: 1.id选择器 # 2.class选择器 句号 . 3.标签选择器 标签名称 4.相邻选择器 加号 + 5.后代选择器 空格 6.子元素选择器 大于号 > 7.多元素 ...
- JS代理模式实现图片预加载
---恢复内容开始--- 刚刚说了懒加载,现在我们来搞搞预加载吧 预加载的核心: 图片等静态资源在使用前提前请求. 资源后续使用可以直接从缓存中加载,提升用户体验. 几个误区: 预加载不是为了减少页面 ...
- vm virtualBox下 centos7 Linux系统 与本地 window 系统 网络连接 配置
由于要模拟生产环境开发,所以要在自己的电脑上安装虚拟机,这里做一下记录. centos与本机网络连接 1. 环境 虚拟机 VirtualBox-5.2.0-118431-Win Linux镜像 Cen ...
- 13 款惊艳的 Node.js 框架——第1部分
[编者按]本文作者为 Peter Wayner,主要介绍13款至精至简的 Node.js 框架,帮助你简化高速网站.丰富 API 以及实时应用的开发流程.本文系国内 ITOM 管理平台 OneAPM ...
- redie config 详解
# redis 配置文件示例 # 当你需要为某个配置项指定内存大小的时候,必须要带上单位,# 通常的格式就是 1k 5gb 4m 等酱紫:## 1k => 1000 bytes# 1kb =&g ...
- 安装 Scala
0. 说明 Scala 安装(Windows) & Scala 安装(Linux) 1. Scala 安装(Windows) 1.0 下载 Scala 下载地址 1.1 运行 Scala ...
- ndroid动态创建按钮并添加事件
public class MyActivity extends Activity { /** * Called when the activity is first created. */ @Over ...
- COM动态添加删除成员,类似JavaScript中调用的对象
在JavaScript中调用对象时,可动态添加删除成员如: var obj=new Object; obj.member1='aaaaa'; obj.fun1=function() { alert(' ...
- October 16th 2017 Week 42nd Monday
The more decisions that you are forced to make alone, the more you are aware of your freedom to choo ...
- DevExpress10、RichEditControl
1.概述 传统.NET界面也有一个RichTextBox控件,一个富文本控件,可存储图片文字,有自己的文件格式RTF. 在DevExpress控件组里面也有一个同等的控件,RichEditContro ...