源码编译安装LNMP环境及配置基于域名访问的多虚拟主机
实验环境及软件版本:
CentOS版本: 6.6(2.6.32.-504.el6.x86_64)
nginx版本: nginx-1.6.2
mysql版本: Mysql-5.6.23
php版本: php-5.6.3
一、关闭防火墙:service iptables stop
chkconfig iptables off
二、关闭selinux: sed -i 's/SELINUX=disabled/SELINUX=enforcing/g' /etc/selinux/config
init 6 重启系统一定要!
三、nginx安装
1.安装准备
a.mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
b.wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
c. pcre:yum -y install pcre pcre-devel
d. openssl:yum -y install openssl openssl-devel
2.安装nginx
a.tar xf nginx-1.6.2.tar.gz
b.cd nginx-1.6.2, useradd nginx -s /sbin/nologin -M
c. ./configure --prefix=/application/nginx-1.6.2 --with-http_stub_status_module --with-http_ssl_module --user=nginx --group=nginx
d.[root@LNMP nginx-1.6.2]# echo $?
0 代表编译没有任何错误
e.make
f.make install
g.[root@LNMP nginx-1.6.2]# echo $?
0 代表编译没有任何错误
h.cd -,ln -s /application/nginx-1.6.2 /application/nginx
i.编辑nginx.conf
cd /application/nginx/conf
vi nginx.conf
修改第2行的用户名,用户组名为:nginx nginx,保存退出.
3.启动nginx
[root@LNMP tools]# /application/nginx/sbin/nginx -t
nginx: the configuration file /application/nginx-1.6.2/conf/nginx.conf syntax is ok
nginx: configuration file /application/nginx-1.6.2/conf/nginx.conf test is successful
出现以上提示,代表nginx安装配置,语法等没错!
[root@LNMP tools]# /application/nginx/sbin/nginx
[root@LNMP tools]# netstat -lntup|grep nginx
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 3685/nginx
[root@LNMP tools]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
nginx 3685 root 6u IPv4 13603 0t0 TCP *:http (LISTEN)
nginx 3686 nginx 6u IPv4 13603 0t0 TCP *:http (LISTEN)
出现以上提示,代表nginx已成功运行!
[root@LNMP tools]# curl 192.168.0.111
curl后如果有内容,就代表nginx运行正常!
四、源码安装Mysql-5.6.23
请移步:http://linuxzkq.blog.51cto.com/9379412/1584642,这里不在描述
五、php安装
1.安装依赖:
yum install zlib libxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-devel freetype-devel libpng-devel gd-devel curl-devel -y
#确保devel安装上X software development
2.tar zxf libiconv-1.14.tar.gz
cd libiconv-1.14
./configure --prefix=/usr/local/libiconv
make
make install
3.libmcrypt
wget http://downloads.sourceforge.net/mcrypt/libmcrypt-2.5.8.tar.gz
tar zxf libmcrypt-2.5.8.tar.gz
cd libmcrypt-2.5.8
./configure
make
make install
4. libltdl
cd libltdl/
./configure --enable-ltdl-install
make
make install
5.mhash
wget http://downloads.sourceforge.net/mhash/mhash-0.9.9.9.tar.gz
tar zxf mhash-0.9.9.9.tar.gz
cd mhash-0.9.9.9/
./configure
make
make install
rm -f /usr/lib64/libmcrypt.*
rm -f /usr/lib64/libmhash*
ln -s /usr/local/lib64/libmcrypt.la /usr/lib64/libmcrypt.la
ln -s /usr/local/lib64/libmcrypt.so /usr/lib64/libmcrypt.so
ln -s /usr/local/lib64/libmcrypt.so.4 /usr/lib64/libmcrypt.so.4
ln -s /usr/local/lib64/libmcrypt.so.4.4.8 /usr/lib64/libmcrypt.so.4.4.8
ln -s /usr/local/lib64/libmhash.a /usr/lib64/libmhash.a
ln -s /usr/local/lib64/libmhash.la /usr/lib64/libmhash.la
ln -s /usr/local/lib64/libmhash.so /usr/lib64/libmhash.so
ln -s /usr/local/lib64/libmhash.so.2 /usr/lib64/libmhash.so.2
ln -s /usr/local/lib64/libmhash.so.2.0.1 /usr/lib64/libmhash.so.2.0.1
ln -s /usr/local/bin/libmcrypt-config /usr/bin/libmcrypt-config
6.mcrypt
centos6.5/6.6 x86_64
wget http://downloads.sourceforge.net/mcrypt/mcrypt-2.6.8.tar.gz
tar zxf mcrypt-2.6.8.tar.gz
cd mcrypt-2.6.8/
./configure LD_LIBRARY_PATH=/usr/local/lib
make
make install
cd ../
7.php安装
tar xf php-5.6.3.tar.gz
cd php-5.6.3
./configure \
--prefix=/application/php-5.6.3 \
--with-mysql=/application/mysql \
--with-iconv-dir=/usr/local/libiconv \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-zlib \
--with-libxml-dir=/usr \
--enable-xml \
--disable-rpath \
--enable-safe-mode \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--with-curl \
--with-curlwrappers \
--enable-mbregex \
--enable-fpm \
--enable-mbstring \
--with-mcrypt \
--with-gd \
--enable-gd-native-ttf \
--with-openssl \
--with-mhash \
--enable-pcntl \
--enable-sockets \
--with-xmlrpc \
--enable-zip \
--enable-soap \
--enable-short-tags \
--enable-zend-multibyte \
--enable-static \
--with-xsl \
--with-fpm-user=nginx \
--with-fpm-group=nginx \
--enable-ftp
出现错误:Don't know how to define struct flock on this system, set --enable-opcache=no
这是安装php 5.5时的错误,同样适用5.6.3
解决办法如下:
编辑 /etc/ld.so.conf 加入/usr/local/lib
再执行 ldconfig即可
出现错误:提示没有安装libxslt,请安装libxslt
yum -y install libxslt*
出现警告:configure: WARNING: unrecognized options: --enable-safe-mode, --with-curlwrappers, --enable-zend-multibyte
上面的警告提示是说:上面的参数已经去除了,说明上述这些参数废弃了,php-5.6.3 已经去掉了该选项,编译时可以 #./configure --help | grep “safe-mode” 查看一下,没有信息输出,表示已经不支持!
出现错误:make: *** [sapi/cli/php] Error 1
解决方法:make ZEND_EXTRA_LIBS='-liconv'
ln -s /application/mysql/lib/libmysqlclient.so.18 /usr/lib64/
make install
ln -s /application/php-5.6.3/ /application/php
cp php.ini-production /application/php/lib/php.ini
8.整合nginx和php
cd /application/php/etc/
mv php-fpm.conf.default php-fpm.conf
编辑php-fpm.conf
cd /application/php/etc
vi php-fpm.conf
修改里面的用户名,用户组名为:nginx nginx(user=nobody group=nobody改成user=nginx group=nginx),保存退出.
重点注意:php-fpm.conf文件里面的用户名,用户组名一定要和nginx.conf文件里面的用户名,用户组名统一,否则会出错!
/application/php/sbin/php-fpm -t
/application/php/sbin/php-fpm
[root@LNMP ~]# netstat -lntup|grep php-fpm
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 14801/php-fpm ==============成功标志==================
9.加入开机自启动
cat >>/etc/rc.local<<EOF
/etc/init.d/mysqld start
/application/php/sbin/php-fpm
/application/nginx/sbin/nginx
EOF
六.定义虚拟机:
1. cd /application/nginx/conf
mkdir vhost
cd vhost
加入以下内容:
server {
listen 80;
server_name www.etiantian.org;
root /web/www;
index index.php index.html index.htm;
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
保存退出,其他两个虚拟主机定义和以上类同,不再叙述.
编辑nginx.conf:
vi nginx.conf
在http模块里面的第一个server标签前加入include vhost/*.conf开启nginx的虚拟机功能
在根目录创建虚拟机根目录:mkdir /web/{bbs,blog,www}
给nginx授权读取执行虚拟机根目录的权限:chown -R nginx:root /web
2. 测试LNMP是否成功:
cd /web/www
vi phpinfo.php
<?php
phpinfo();
?>
保存退出,给予虚拟机读取运行phpinfo.php文件的权限
chown -R nginx:root /web
在windows客户端的hosts文件里做好IP和域名的映射,访问www.etiantian.org后,如果出现PHP紫色 的配置界面,访问正常;如不正常,现给出以下排障方法 及步骤:
windows浏览器访问:
排错三步曲:
1)ping 192.168.0.111 物理网络通不通
2)telnet 192.168.0.111 80 浏览器到web服务通不通
3)服务器本地curl 192.168.0.111 web服务开没开
希望能给大家有所帮助,通过我分享的笔记,如有遗漏之处欢迎拍砖!
源码编译安装LNMP环境及配置基于域名访问的多虚拟主机的更多相关文章
- 源码编译安装LAMP环境及配置基于域名访问的多虚拟主机
实验环境及软件版本: CentOS版本: 6.6(2.6.32.-504.el6.x86_64) apache版本: apache2.2.27 mysql版本: Mysql-5.6.23 php版本 ...
- 源码编译安装lnmp环境
一.源码编译安装步骤 首先说明源码安装的好处 速度快,可自定义路径 主要有三步:1.配置 进入源码安装包 ./configure --prefix=/uer/local/nginx 可指定参数 ...
- centos6源码编译安装lnmp环境
操作系统 版本 64位 CentOS-6.6 10.0.0.20 安装环境所需依赖包 yum -y install gcc automake autoconf libtool make gcc- ...
- 源码编译安装lnmp环境(nginx-1.14.2 + mysql-5.6.43 + php-5.6.30 )------踩了无数坑,重装了十几次服务器才会的,不容易啊!
和LAMP不同的是,LNMP中的N指的是Nginx(类似于Apache的一种web服务软件),并且php是作为一个独立服务存在的,这个服务叫做php-fpm,Nginx直接处理静态请求,动态请求会转发 ...
- WordPress安装篇(5):源码编译安装LNMP并部署WordPress
与YUM方式安装相比,源码编译安装方式更灵活,安装过程中能自定义功能和参数,特别是在批量部署服务器又要求软件版本及配置一致时,源码编译安装的优势很明显.本文介绍如何通过源码编译方式安装Nginx1.1 ...
- 源码编译搭建LNMP环境
LNMP源码编译 1.LNMP介绍 LNMP=Linux Nginx Mysql PHP Nginx ("engine x") 是一个高性能的 HTTP 和 反向代理 服务器.Ng ...
- 源码编译安装 PHP5.5.0,解决curl_exec访问HTTPS返回502错误的问题(修改PATH路径)
最近碰到一个奇怪的问题, PHP使用 curl_exec 访问 HTTPS 网页时, 返回502错误, 访问HTTP网页时没有问题, 用 echo phpinfo() ; 查看, 支持op ...
- 年终福利,PHP7+Apache2.4+MySQL5.6 源码编译安装,环境配置,搭建你自己的LAMP环境
PHP7 都出来了,你还在玩PHP5吗? MySQL5.6 早都出来了,你还在玩MySql5.2吗? Apache2.4 早都出来了,你还在玩Apache2.2吗? 笔者不才,愿意亲自搭建环境,供搭建 ...
- centos7源码编译安装LNMP+ZABBIX4.0LTS(1)——nginx
环境:192.168.117.132--zabbix server192.168.117.133--zabbix proxy 安装路径为/zabbix 安装nginx 1.安装包下载http://ng ...
随机推荐
- Index Generation
Index Generation Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 230 Accepted: 89 Des ...
- Inaccurate values for “Currently allocated space” and “Available free space” in the Shrink File dialog for TEMPDB only
转载自:http://blogs.msdn.com/b/ialonso/archive/2012/10/08/inaccurate-values-for-currently-allocated-spa ...
- 如何用拉姆达表达式(Lambda Expressions) 书写左链接查询
在C#中,如果要实现两个列表的左链接查询,我们的一般用法就是用的linq表达式就是 List<Pet> pets = }, }, } }; List<Pet2> pets2 = ...
- Adobe Edge Animate –Edge Commons强势来袭,Edge团队开发成为现实
Adobe Edge Animate –Edge Commons强势来袭,Edge团队开发成为现实 版权声明: 本文版权属于 北京联友天下科技发展有限公司. 转载的时候请注明版权和原文地址. Edge ...
- iOS开发者如何提高自己的水平(转)
阅读. 把一大堆的知识塞进脑子里.随着时间流逝,终归有一些会留在脑海里.我觉得有些东西读起来还挺有意思,那么也能算作一种愉快的消遣. 分析. 多去熟悉并了解一些工具,从高层的到底层的,不要害怕去使用他 ...
- css禁止双击dom节点被选中user-select:none
css禁止dom节点被选中: 当某个dom节点在快速重复点击的时候出现这个节点被选中,有时候其实并不希望出现这种情况,比如我们使用一个span或者a标签做为按钮dom元素的时候,快速双击这个按钮,就 ...
- Ionic条码扫描
http://m.blog.csdn.net/article/details?id=45843819
- jQuery选择器解释和说明
jQuery选择器的意义在于快速的找出特定的DOM元素,然后添加相应的行为. 基本选择器 //选择 id为 one 的元素 $('#btn1').click(function(){ $('#one') ...
- C# 4 dynamic 动态对象 动态类型转换
public class User { //使用省缺参数,一般不需要再为多态做各种静态重载了 public User( string name = "anonym", string ...
- Android之手机屏幕的获取
屏幕区域的获取: activity.getWindowManager().getDefaultDisplay(); 应用区域的获取: Rect outRect = new Rect(); activi ...