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命令只能 ...
随机推荐
- javascript:类数组 -- 对象
在javascript中,对象与数组都是这门语言的原生规范中的基本数据类型,处于并列的位置. 类数组:本质是一个对象,只是这个 对象 的属性有点特殊,模拟出数组的一些特性. 一般来说,如果我们有一个 ...
- 【读书笔记】iOS-自定义视图的创建
静态创建自定义视图就是以拖动的方法来创建. 动态创建自定义视图可以理解为使用代码来创建自定义视图. 参考资料:<iOS7开发快速入门>
- 树莓派 MPG视频硬件解码破解 Raspberry Pi Patch for MPEG-2, VC-1 license
Enable the Pi's hardware decoding of MPEG-2 and VC-1 MPEG2 patents have expired If you have start.e ...
- 【CLR Via C#】15 枚举类型与位类型
1.基础 枚举类型(enumerated types)定义了一组“符号名称/值”配对. 枚举类型是值类型,每个枚举类型都是从System.Enum派生的,而System.Enum又是从System.V ...
- Unity Profiler GPU Usage(GPU使用情况)
一般情况下性能瓶颈都在CPU上,这儿也列举下几个常见的GPU耗时函数吧. 1 Render.Mesh 绘制网格面(没批处理的面) 2 Batch.DrawStatic 静态批处理 3 Batch.Dr ...
- Django ModelForm类生成表单
1. 定义ModelForm类 #froms.py from django import forms from app01.modles import User class UserModelForm ...
- Win10命令行激活 & 电脑组装
系统激活: 1. 管理员身份运行 cmd 2. slmgr.vbs /upk ...
- guid是否为空的判断
Guid类型的变量不会为空,初始化没有赋值的GUID应该是00000000-0000-0000-0000-000000000000 . 正确的判断应该是if(Guid testId== Guid.Em ...
- Oracle EBS FTP显示无法与某IP 连接
首先 用root用户登录 如果可以登录 那么应该是权限的问题 这里选择 方法二:修改 /etc/sudoers 文件,找到下面一行,在root下面添加一行,如下所示: ## Allow root to ...
- SQL 时间戳转换为日期
, '1970-01-01 00:00:00') 其中Timestamp为10位的时间戳,+8*3600是获取中国北京时间(东八区)