虚拟机之 LNMP
2016-01-17 11:35
295 查看
LNMP就是Linuxnginxmysqlphp
[b]一、mysql[/b]
下载安装mysql转至LAMP(点击“LAMP”即可跳转)
也可以从快照跳转至mysql安装ok
[b]二、php[/b]
下载同上,
1.安装
把lamp的错误解决方法yum安装完之后,新的错误解决方法
错误1
错误2
makeinstall之前,如果已经安装过在php,同样指定的目录位/usr/local/php,可以把原来的删掉,or,挪个位置。
2.配置文件,启动脚本
拍摄快照:备注LNMPphp安装ok
php安装成功
[b]三、nginx[/b]
1.下载
[b]一、mysql[/b]
下载安装mysql转至
也可以从快照跳转至mysql安装ok
[b]二、php[/b]
下载同上,
1.安装
cd/usr/local/src/
tarzxvfphp-5.6.9.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:noacceptableCcompilerfoundin$PATH 配置:错误:不接受C编译器中发现路径 解决 yuminstallgcc-y
错误2
configure:error:Pleasereinstallthelibcurldistribution- easy.hshouldbein<curl-dir>/include/curl/ 配置:错误:请重新安装libcurl分布- 一件容易的事。在<curl-dir>/h应该包括/卷/ 解决 yum-yinstallcurl-devel
echo$? make echo$? makeinstall echo$?
makeinstall之前,如果已经安装过在php,同样指定的目录位/usr/local/php,可以把原来的删掉,or,挪个位置。
2.配置文件,启动脚本
cpphp.ini-production/usr/local/php/etc/php.ini 配置文件
cpsapi/fpm/init.d.php-fpm/etc/init.d/php-fpm 启动脚本
chmod755!$ 执行权限
chkconfig--addphp-fpm chkconfigphp-fpmon 开机启动
cd/usr/local/php/etc/ mvphp-fpm.conf.defaultphp-fpm.conf 配置文件
useradd-s/sbin/nologin-Mphp-fpm 用户,编译的时候指定的usergroup
servicephp-fpmstart 启动
拍摄快照:备注LNMPphp安装ok
php安装成功
[b]三、nginx[/b]
1.下载
cd/usr/local/src/
wget'target='_blank'>http://mirrors.sohu.com/nginx/nginx-1.9.8.tar.gz[/code]
2.安装tarzxvfnginx-1.9.8.tar.gz./configure--prefix=/usr/local/nginx--with-pcre
pcre正则
错误1./configure:error:theHTTPrewritemodulerequiresthePCRElibrary. 。/配置:错误:HTTP重写模块需要PCRE库。 解决 yum-yinstallpcre-develecho$? make echo$? makeinstall echo$?
3.启动/usr/local/nginx/sbin/nginx
shell脚本安装vimnginx_install.sh#!/bin/bash cd/usr/local/src/ yuminstallwget-y wgethttp://mirrors.sohu.com/nginx/nginx-1.9.8.tar.gztarzxvfnginx-1.9.8.tar.gz yum-yinstallpcre-devel yuminstall-yzlib-devel yum-yinstallgcc cdnginx-1.9.8 ./configure--prefix=/usr/local/nginx--with-pcre make&&makeinstall
nginx安装ok
[b]四、关联php和nginx[/b]
php和nginx不能联系到一起,需要手动修改配置文件。
1.nginxvim/usr/local/nginx/conf/nginx.conf找到 #location~\.php${ #roothtml; #fastcgi_pass127.0.0.1:9000; #fastcgi_indexindex.php; #fastcgi_paramSCRIPT_FILENAME/scripts$fastcgi_script_name; #includefastcgi_params; #} 改为
location~\.php${
roothtml;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME/usr/local/nginx/html$fastcgi_script_name;
includefastcgi_params;
}
2.防火墙vim/etc/selinux/config
找到
SELINUX=enforcing
改为
SELINUX=disabledsetenforce0iptables-Fserviceiptablessave
详细说明见LAMP四、php8-9小节
3.浏览器访问192.168.1.116Welcometonginx!
Ifyouseethispage,thenginxwebserverissuccessfullyinstalledandworking.Furtherconfigurationisrequired.
Foronlinedocumentationandsupportpleaserefertonginx.org.
Commercialsupportisavailableatnginx.com.
Thankyouforusingnginx.
4.测试解析phpvim/usr/local/nginx/html/info.php<?php phpinfo(); ?>http://192.168.1.116/info.php
[b]php解析ok[/b]
[b]五、nginx启动脚本[/b]
nginx启动重启非常不方便,手动写一个nginx启动脚本。
1.启动脚本vim/etc/init.d/nginx#!/bin/bash
#chkconfig:-3021
#description:httpservice.
#SourceFunctionLibrary
./etc/init.d/functions
#NginxSettings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
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
return0
}
case"$1"in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo$"Usage:$0{start|stop|reload|restart|configtest}"
RETVAL=1
esac
exit$RETVALchmod755!$chkconfig--addnginx
chkconfignginxon
2.配置文件
默认的配置文件不完美,手动写一个,
全局的配置,删掉原来的东西vim/usr/local/nginx/conf/nginx.confusernobodynobody;
worker_processes2;
error_log/usr/local/nginx/logs/nginx_error.logcrit;
pid/usr/local/nginx/logs/nginx.pid;
worker_rlimit_nofile51200;
events
{
useepoll;
worker_connections6000;
}
http
{
includemime.types;
default_typeapplication/octet-stream;
server_names_hash_bucket_size3526;
server_names_hash_max_size4096;
log_formatcombined_realip'$remote_addr$http_x_forwarded_for[$time_local]'
'$host"$request_uri"$status'
'"$http_referer""$http_user_agent"';
sendfileon;
tcp_nopushon;
keepalive_timeout30;
client_header_timeout3m;
client_body_timeout3m;
send_timeout3m;
connection_pool_size256;
client_header_buffer_size1k;
large_client_header_buffers84k;
request_pool_size4k;
output_buffers432k;
postpone_output1460;
client_max_body_size10m;
client_body_buffer_size256k;
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_errorson;
tcp_nodelayon;
gzipon;
gzip_min_length1k;
gzip_buffers48k;
gzip_comp_level5;
gzip_http_version1.1;
gzip_typestext/plainapplication/x-javascripttext/csstext/htmapplication/xml;
includevhosts/*.conf;
}
虚拟主机的配置cd/usr/local/nginx/conf/mkdirvhostscdvhosts/server
{
listen80default_server;
server_namelocalhost;
indexindex.htmlindex.htmindex.php;
root/tmp/1233;
}
##不管主机访问什么域名都会走这个配置,限制访问403mkdir/tmp/1233/usr/local/nginx/sbin/nginx-t
检查配置文件/etc/init.d/nginxreload
重新加载curl-x127.0.0.1:80www.qq.com
测试默认虚拟主机配置,写什么域名都是403vimvhosts2.confserver
{
listen80;
server_name111.com;
indexindex.htmlindex.htmindex.php;
root/data/www;
location~\.php${
includefastcgi_params;
#fastcgi_passunix:/tmp/php-fcgi.sock;
fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
fastcgi_paramSCRIPT_FILENAME/data/www$fastcgi_script_name;
}
}server_name111.com指定域名root/data/wwwroot的目录fastcgi_pass127.0.0.1:9000;两种形式sockt和ip+端口。如果502,那就是因为这个socket文件的权限不能让nginx用户读到,办法是在php-fpm.conf配置文件中指定一下socket文件的权限:listen.mode=644fastcgi_paramSCRIPT_FILENAME/data/www$fastcgi_script_name;也要指定路径/usr/local/nginx/sbin/nginx-t/etc/init.d/nginxreload
相关文章推荐
- springmvc学习之安装spring tool suite
- Property和attribute的区别【转】
- 技术泡妹子二:篡改百度首页,惊呆女神
- zend studio 一直试用的方法
- JavaScript 语法
- kali 安装eclipse启动不了的问题
- jQuery选择器小结
- 浅谈vocaloid3基础操作
- urxvt的粘贴复制快捷键
- 用户权限集中管理--用户行为日志审计管理方案
- LVS NA模型
- Android解决HAXM安装的问题
- FreeMarker 的 List 的使用
- Vijos p1892 树上的最大匹配 树形DP+计数 被卡常我有特殊技巧heheda
- 人民日报读书笔记-2015年3月份
- 设计模式一:设计模式简介
- [置顶] 编程珠玑:n元一维向量左旋移i个位置
- [Leetcode]32. Longest Valid Parentheses @python
- Volley 源码解析
- 使用360浏览器访问字体逆时针旋转90度的问题