LNMP就是Linux nginx mysql php

一、mysql

下载安装mysql转至 LAMP (点击“LAMP”即可跳转)

也可以从快照跳转至mysql安装ok

二、php

下载同上,

1.安装

cd /usr/local/src/
tar zxvf php-5.6..tar.gz
./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 --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --enable-zend-multibyte --disable-ipv6 --with-pear --with-curl --with-openssl

把lamp的错误解决方法yum安装完之后,新的错误解决方法

错误1

configure: error: no acceptable C compiler found in $PATH
配置:错误:不接受C编译器中发现路径
解决
yum install gcc -y

错误2

configure: error: Please reinstall the libcurl distribution -
easy.h should be in <curl-dir>/include/curl/
配置:错误:请重新安装libcurl分布-
一件容易的事。在< curl-dir > / h应该包括/卷/
解决
yum -y install curl-devel
echo $?
make
echo $?
make install
echo $?

make install 之前,如果已经安装过在php,同样指定的目录位/usr/local/php,可以把原来的删掉,or,挪个位置。

2.配置文件,启动脚本

cp php.ini-production /usr/local/php/etc/php.ini
配置文件
cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
启动脚本
chmod 755 !$
执行权限
chkconfig --add php-fpm
chkconfig php-fpm on
开机启动
cd /usr/local/php/etc/
mv php-fpm.conf.default php-fpm.conf
配置文件
useradd -s /sbin/nologin -M php-fpm
用户,编译的时候指定的user group
service php-fpm start
启动

拍摄快照:备注LNMP php安装ok

php安装成功                                                                                  

三、nginx

1.下载

cd /usr/local/src/
wget http://mirrors.sohu.com/nginx/nginx-1.9.8.tar.gz

2.安装

tar zxvf nginx-1.9..tar.gz
 ./configure --prefix=/usr/local/nginx --with-pcre

pcre 正则

错误1

./configure: error: the HTTP rewrite module requires the PCRE library.
。/配置:错误:HTTP重写模块需要PCRE库。
解决
yum -y install pcre-devel
echo $?
make
echo $?
make install
echo $?

3.启动

/usr/local/nginx/sbin/nginx

shell脚本安装

vim nginx_install.sh
#! /bin/bash
cd /usr/local/src/
yum install wget -y
wget http://mirrors.sohu.com/nginx/nginx-1.9.8.tar.gz
tar zxvf nginx-1.9..tar.gz
yum -y install pcre-devel
yum install -y zlib-devel
yum -y install gcc
cd nginx-1.9.
./configure --prefix=/usr/local/nginx --with-pcre
make && make install

nginx安装ok                                                                               

四、关联php和nginx

php和nginx不能联系到一起,需要手动修改配置文件。

1.nginx

vim /usr/local/nginx/conf/nginx.conf
找到
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
改为

location ~ \.php$ {
              root html;
              fastcgi_pass 127.0.0.1:9000;
              fastcgi_index index.php;
              fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
              include fastcgi_params;
         }

 

2.防火墙

vim /etc/selinux/config
找到
SELINUX=enforcing
改为
SELINUX=disabled
setenforce 
iptables -F
 service iptables save

详细说明见LAMP 四、php 8-9小节

3.浏览器访问

192.168.1.116
Welcome to nginx!
If you see this page, the nginx web server is successfully installed and working. Further configuration is required.
For online documentation and support please refer to nginx.org.
Commercial support is available at nginx.com.
Thank you for using nginx.

4.测试解析php

vim /usr/local/nginx/html/info.php
<?php
phpinfo();
?>
http://192.168.1.116/info.php

php解析ok                                                                                  

五、nginx启动脚本

nginx启动重启非常不方便,手动写一个nginx启动脚本。

1.启动脚本

vim /etc/init.d/nginx
#!/bin/bash
# chkconfig: -
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=
prog="Nginx" start() {
echo -n $"Starting $prog: "
mkdir -p /dev/shm/nginx_temp
daemon $NGINX_SBIN -c $NGINX_CONF
RETVAL=$?
echo
return $RETVAL
} stop() {
echo -n $"Stopping $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -TERM
rm -rf /dev/shm/nginx_temp
RETVAL=$?
echo
return $RETVAL
} reload(){
echo -n $"Reloading $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
} restart(){
stop
start
} configtest(){
$NGINX_SBIN -c $NGINX_CONF -t
return
} case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|configtest}"
RETVAL=
esac exit $RETVAL
chmod  !$
chkconfig --add nginx
chkconfig nginx on

2.配置文件

默认的配置文件不完美,手动写一个,

全局的配置,删掉原来的东西

vim /usr/local/nginx/conf/nginx.conf
user nobody nobody;
worker_processes ;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile ; events
{
use epoll;
worker_connections ;
} http
{
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size ;
server_names_hash_max_size ;
log_format combined_realip '$remote_addr $http_x_forwarded_for [$time_local]'
'$host "$request_uri" $status'
'"$http_referer" "$http_user_agent"';
sendfile on;
tcp_nopush on;
keepalive_timeout ;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
connection_pool_size ;
client_header_buffer_size 1k;
large_client_header_buffers 4k;
request_pool_size 4k;
output_buffers 32k;
postpone_output ;
client_max_body_size 10m;
client_body_buffer_size 256k;
client_body_temp_path /usr/local/nginx/client_body_temp;
proxy_temp_path /usr/local/nginx/proxy_temp;
fastcgi_temp_path /usr/local/nginx/fastcgi_temp;
fastcgi_intercept_errors on;
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
gzip_buffers 8k;
gzip_comp_level ;
gzip_http_version 1.1;
gzip_types text/plain application/x-javascript text/css text/htm application/xml;
include vhosts/*.conf;
}

虚拟主机的配置

 cd /usr/local/nginx/conf/
mkdir  vhosts
cd vhosts/
server
{
listen default_server;
server_name localhost;
index index.html index.htm index.php;
root /tmp/; } ##不管主机访问什么域名都会走这个配置,限制访问403
 mkdir /tmp/
/usr/local/nginx/sbin/nginx -t
检查配置文件
/etc/init.d/nginx reload
重新加载
 curl -x127.0.0.: www.qq.com
测试默认虚拟主机配置,写什么域名都是
 vim vhosts2.conf
server
{
listen ;
server_name .com;
index index.html index.htm index.php;
root /data/www; location ~ \.php$ {
include fastcgi_params;
# fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
} }
server_name 111.com 指定域名
root /data/www root的目录
fastcgi_pass 127.0.0.1:9000;两种形式sockt和ip+端口。如果502,那就是因为这个socket文件的权限不能让nginx用户读到,办法是在php-fpm.conf配置文件中指定一下socket文件的权限: listen.mode=644
fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name; 也要指定路径
/usr/local/nginx/sbin/nginx -t
/etc/init.d/nginx reload

虚拟机之 LNMP的更多相关文章

  1. Win10 VirtualBox虚拟机搭建lnmp环境

    之前用的是vagrant+VirtualBox搭建的环境,因为是windows系统动不动就报错,打不开环境,所以还是老老实实换了虚拟机哎.... 版本: VirtualBox 5.1.34   xsh ...

  2. VM虚拟机 Centos7 lnmp环境 配置域名问题 windows浏览器访问的问题

    CentOS7  ip地址为 192.168.0.155 搭有 LNMP集成环境 执行 lnmp vhost add 配置服务器 指定目录的域名 mark.com 这时windows 机器的 浏览器想 ...

  3. 关于本地代码挂载到vm虚拟环境下运行

    第一步: 首先你得装个 VM 虚拟机  然后新建一个Linux虚拟环境(建议CentOS镜像)(PS:至于安装此处就省略.....) 第二步:启动虚拟机配置 lnmp (这里我们可以使用 lnmp的 ...

  4. LNMP虚拟机开发环境配置--vagrant+virtualbox+ubuntu14.04

    工作一直用的是别人打包好的虚拟机开发环境,感觉确实很酷.所以准备自己配个开发环境,为之后自己开发一些有趣的东西做准备. ok,开始~~~ 一.安装软件 vagrant和virtualbox 此处需注意 ...

  5. CentOS7 LNMP+phpmyadmin环境搭建(一、虚拟机及centos7安装)

    前一阵子配公司的服务器的时候,发现网上好多教程杂乱无章,然后便根据网上已有资料自己整理了一个lnmp环境的安装教程.因为懒,已经好久没写过博客了.趁着这次公司招新人,把之前整理的文档又整理了一次,顺便 ...

  6. WIN10 vagrant和virtualbox虚拟机和一键搭建lnmp环境配置thinkphp虚拟主机

    版本:win10系统 virtualbox:5.1.26 vagrant :1.9.7 centos 7.0 xshell/git 首先下载好对应版本的软件 配置vagrant和virtualbox ...

  7. lnmp手动新建虚拟机

    1.在home/wwwroot/zhongjie   新建zhongjie文件夹 2.在usr/local/nginx/conf/vhost/zhongjie.conf    新建配置文件zhongj ...

  8. VMware虚拟机基于contos 7 搭建lnmp环境全过程

    这个环境也整了几次了,由于本人比较懒,没有记住.找资料很麻烦,就自己动手咯 1.下载VMware虚拟机   (有注册码)     地址:http://www.zdfans.com/5928.html ...

  9. 本地虚拟机LNMP环境安装

      首先上传源码包到linux中(本人上传到根目录中),随意上传能找到即可 一.配置YUM源(如果已经配好就不许要重新配置) 挂载光驱要挂载到/mnt下  Mount /dev/cdrom /mnt ...

随机推荐

  1. Linux下用c语言实现whereis.

    简单的一个whereis的实现,代码如下: #include <stdio.h> #include <errno.h> #include <dirent.h> #i ...

  2. WordCounter Python实现

    <!doctype html>博客.md p:first-child, #write > ul:first-child, #write > ol:first-child, #w ...

  3. SpringMVC中WebDataBinder的应用及原理

     Controller方法的参数类型可以是基本类型,也可以是封装后的普通Java类型.若这个普通Java类型没有声明任何注解,则意味着它的每一个属性都需要到Request中去查找对应的请求参数.众所周 ...

  4. Dockerfile 模版

    最近一直在用docker,总结了一个靠谱的模版,分享给大家. From ubuntu:14.04 MAINTAINER pidong.li@genetronhealth.com RUN echo de ...

  5. ubuntu与windows共享文件

    一.通过vmmare tool工具共享文件 Ubuntu系列10.04.11.04.12.04等虚拟机中安装VMware Tools参考下面两篇文章. http://www.linuxidc.com/ ...

  6. Android 进阶9:进程通信之 AIDL 解析

    读完本文你将了解: AIDL AIDL 生成文件分析 Stub Proxy AIDL 生成的内容小结 AIDL 的使用回顾 服务端 客户端 小结 手动写个 Binder 首先是定义跨进程接口实现 II ...

  7. shfileoperation 删除文件 FileDelete(CString strName)

    From:http://blog.csdn.net/lvwx369/article/details/41440883 注意:其中namePath 为全局变量 Cstring namePath; BOO ...

  8. 【Android】Android 学习记录贴

    官网 教程学习笔记 Genymotion 安卓虚拟器太慢,用Genymotion(装载eclipse的插件) 利用Genymotion运行Android应用程序 1.首先,点击 来启动或者创建您要使用 ...

  9. win2003从组策略关闭端口(445/135/137/138/139/3389等)教程

    一些恶劣的病毒会从某些端口入侵计算机,因此关闭某些用不到的而又具有高风险的端口就显得很有必要,是服务器管理员要做的基本的安全防范.本文将介绍win2003系统在组策略关闭某一个端口的教程,文章以关闭4 ...

  10. Block Towers (思维实现)

    个人心得:这题没怎么看,题意难懂.后面比完再看的时候发现很好做但是怎么卡时间是个问题. 题意:就是有m个可以用2层积木的,n个可以用三层积木的,但是他们不允许重复所以可以无限添加. 比如 3 2 一开 ...