搭建完全分离式LNMP平台的简单案例.docx_第1页
搭建完全分离式LNMP平台的简单案例.docx_第2页
搭建完全分离式LNMP平台的简单案例.docx_第3页
搭建完全分离式LNMP平台的简单案例.docx_第4页
搭建完全分离式LNMP平台的简单案例.docx_第5页
已阅读5页,还剩4页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

网址:edu.51CTO.com搭建完全分离式LNMP平台的简单案例案例拓扑图安装配置nginx服务器编译安装nginx时,需要事先安装 开发包组Development Tools和Server Platform Development,同时还需专门安装pcre-devel包。1. #yum-ygroupinstallDevelopmentTools 2. #yum-ygroupinstallServerPlatformDevelopment 3. #yum-yinstallpcre-devel首先添加nginx用户组和nginx用户1. #groupadd-rnginx 2. #useradd-gnginx-rnginx创建编译安装是所需要的目录1. #mkdir-pv/var/tmp/nginx/client编译安装nginx1. #tarxfnginx-1.4.7.tar.gz 2. #cdnginx-1.4.7 3. #./configure 4. -prefix=/usr/local/nginx 5. -sbin-path=/usr/local/nginx/sbin/nginx 6. -conf-path=/etc/nginx/nginx.conf 7. -error-log-path=/var/log/nginx/error.log 8. -http-log-path=/var/log/nginx/access.log 9. -pid-path=/var/run/nginx/nginx.pid 10. -lock-path=/var/lock/nginx.lock 11. -user=nginx 12. -group=nginx 13. -with-http_ssl_module 14. -with-http_flv_module 15. -with-http_stub_status_module 16. -with-http_gzip_static_module 17. -http-client-body-temp-path=/var/tmp/nginx/client/ 18. -http-proxy-temp-path=/var/tmp/nginx/proxy/ 19. -http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ 20. -http-uwsgi-temp-path=/var/tmp/nginx/uwsgi 21. -http-scgi-temp-path=/var/tmp/nginx/scgi 22. -with-pcre 23. #make&makeinstall为nginx提供SysV init脚本1. #vim/etc/rc.d/init.d/nginx1. #!/bin/sh 2. # 3. #nginx-thisscriptstartsandstopsthenginxdaemon 4. # 5. #chkconfig:-8515 6. #description:NginxisanHTTP(S)server,HTTP(S)reverse 7. #proxyandIMAP/POP3proxyserver 8. #processname:nginx 9. #config:/etc/nginx/nginx.conf 10. #config:/etc/sysconfig/nginx 11. #pidfile:/var/run/nginx.pid 12. 13. #Sourcefunctionlibrary. 14. ./etc/rc.d/init.d/functions 15. 16. #Sourcenetworkingconfiguration. 17. ./etc/sysconfig/network 18. 19. #Checkthatnetworkingisup. 20. $NETWORKING=no&exit0 21. 22. nginx=/usr/local/nginx/sbin/nginx23. prog=$(basename$nginx) 24. 25. NGINX_CONF_FILE=/etc/nginx/nginx.conf26. 27. -f/etc/sysconfig/nginx&./etc/sysconfig/nginx 28. 29. lockfile=/var/lock/subsys/nginx 30. 31. make_dirs() 32. #makerequireddirectories 33. user=nginx-V2&1|grepconfigurearguments:|seds/*-user=(*).*/1/g- 34. options=$nginx-V2&1|grepconfigurearguments: 35. foroptin$options;do 36. ifecho$opt|grep.*-temp-path;then 37. value=echo$opt|cut-d=-f2 38. if!-d$value;then 39. #echocreating$value 40. mkdir-p$value&chown-R$user$value 41. fi 42. fi 43. done 44. 45. 46. start() 47. -x$nginx|exit5 48. -f$NGINX_CONF_FILE|exit6 49. make_dirs 50. echo-n$Starting$prog: 51. daemon$nginx-c$NGINX_CONF_FILE 52. retval=$? 53. echo 54. $retval-eq0&touch$lockfile 55. return$retval 56. 57. 58. stop() 59. echo-n$Stopping$prog: 60. killproc$prog-QUIT 61. retval=$? 62. echo 63. $retval-eq0&rm-f$lockfile 64. return$retval 65. 66. 67. restart() 68. configtest|return$? 69. stop 70. sleep1 71. start 72. 73. 74. reload() 75. configtest|return$? 76. echo-n$Reloading$prog: 77. killproc$nginx-HUP 78. RETVAL=$? 79. echo 80. 81. 82. force_reload() 83. restart 84. 85. 86. configtest() 87. $nginx-t-c$NGINX_CONF_FILE 88. 89. 90. rh_status() 91. status$prog 92. 93. 94. rh_status_q() 95. rh_status/dev/null2&1 96. 97. 98. case$1in 99. start) 100. rh_status_q&exit0 101. $1 102. ; 103. stop) 104. rh_status_q|exit0 105. $1 106. ; 107. restart|configtest) 108. $1 109. ; 110. reload) 111. rh_status_q|exit7 112. $1 113. ; 114. force-reload) 115. force_reload 116. ; 117. status) 118. rh_status 119. ; 120. condrestart|try-restart) 121. rh_status_q|exit0 122. ; 123. *) 124. echo$Usage:$0start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest 125. exit2 126. esac为此脚本赋予执行权限1. #chmod+x/etc/rc.d/init.d/nginx将nginx服务添加至服务管理列表,并让其开机自动启动1. #chkconfig-addnginx 2. #chkconfignginxon编辑配置文件/etc/nginx/nginx.conf,在server段内添加如下内容1. location.php$ 2. fastcgi_pass0:9000; 3. fastcgi_indexindex.php; 4. fastcgi_paramSCRIPT_FILENAME/var/www/html$fastcgi_script_name; 5. includefastcgi_params; 6. 启动nginx服务1. #vim/etc/init.d/nginxstart测试nginx是否工作起来,在浏览器中键入0,可以得到如下页面安装PHP服务器编译安装php1. #tarxfphp-5.4.26.tar.bz2 2. #cdphp-5.4.26 3. #./configure-prefix=/usr/local/php5-with-mysql=mysqlnd-with-pdo-mysql=mysqlnd-with-mysqli=mysqlnd-with-openssl-enable-mbstring-with-freetype-dir-with-jpeg-dir-with-png-dir-with-zlib-with-libxml-dir=/usr-enable-xml-enable-sockets-enable-fpm-with-mcrypt-with-config-file-path=/etc-with-config-file-scan-dir=/etc/php.d-with-bz2 4. #make&makeinstall为php提供配置文件1. #cpphp.ini-production/etc/php.ini配置php-fpm1. #cpsapi/fpm/init.d.php-fpm/etc/rc.d/init.d/php-fpm 2. #chmod+x/etc/rc.d/init.d/php-fpm 3. #chkconfig-addphp-fpm 4. #chkconfigphp-fpmon 5. #cp/usr/local/php5/etc/php-fpm.conf.default/usr/local/php5/etc/php-fpm.conf编辑配置文件/usr/local/php5/etc/php-fpm.conf,将以下选项修改为相对应的值1. pm.max_children=50 2. pm.start_servers=5 3. pm.min_spare_servers=2 4. pm.max_spare_servers=8 5. pid=/usr/local/php5/var/run/php-fpm.pid在/var/www/html目录下提供测试页面index.php,其内容为1. hello,nginx 2. 启动php-fpm服务1. #/etc/init.d/php-fpmstart测试nginx服务器与php服务器是否能够建立通信,在浏览器中键入0/index.php,可以得到如下页面页面中显示Failure.,是因为后端的数据库还没有进行相应的配置安装MariaDB服务器编译安装mariadb-5.5.361. #tarxfmariadb-5.5.36-linux-x86_64.tar.gz-C/usr/local 2. #cd/usr/local/ 3. #ln-svmariadb-5.5.36-linux-x86_64/mysql 4. #mkdir-pv/mysql/data 5. #groupadd-rmysql 6. #useradd-gmysql-s/sbin/nologin-M-d/mysql/data-rmysql 7. #chown-Rmysql:mysql/mysql 8. #chown-Rmysql:mysql/mysql/data为数据库提供配置文件:1. #cdmysql 2. #mkdir/etc/mysql 3. #chown-Rroot.mysql./* 4. #cpsupport-files/f/etc/mysql/f 5. 修改文件/etc/mysql/f文件内容,在thread_concurrency=8行下添加一行: 6. datadir=/mysql/data为数据库提供SysV启动脚本,并设置为开机启动:1. #cpsupport-files/mysql.serv

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论