仓酷云

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 959|回复: 9
打印 上一主题 下一主题

[CentOS(社区)] 来一发构建高功能Web情况(linux/nginx/mysql/php-fastcgi)

[复制链接]
飘灵儿 该用户已被删除
跳转到指定楼层
楼主
发表于 2015-1-14 21:12:08 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
小知识:Linux同时具有字符界面和图形界面。在字符界面用户可以通过键盘输入相应的指令来进行操作。
本文次要是撰写Linux体系中PHPWeb情况的设置,先容在CentOS体系下安装:NginxMySQL、php-FastCGI,文顶用的软件都是停止2011/6/22最新不乱版。收集上关于这类设置良多,设置历程相差不年夜,可是参数有所分歧。入手下手之前先先容一下nginx:
Nginx(enginex)是一款轻量级的Web办事器/反向代办署理办事器及电子邮件(IMAP/POP3)代办署理办事器,并在一个BSD-like协定下刊行。由俄罗斯的步伐计划师IgorSysoev所开辟,最后供***年夜型的出口网站及征采引擎Rambler(俄文:Рамблер)利用。其特性是占据内存少,并发才能强,现实上nginx的并发才能的确在同范例的网页伺服器中体现较好.今朝中国年夜陆利用nginx网站用户有:新浪、网易腾讯,别的出名的微网志Plurk也利用nginx。
上面入手下手叙说具体设置历程:
1、Centos体系安装终了以后,封闭不必要的办事优化体系,安装体系更新和所需软件撑持。
封闭不必要的办事
  1. chkconfig--level3acpidoffchkconfig--level3anacronoffchkconfig--level3apmdoffchkconfig--level3mdmonitoroffchkconfig--level3xinetdoffchkconfig--level3sendmailoffchkconfig--level3rpcgssdoffchkconfig--level3rawdevicesoffchkconfig--level3messagebusoffchkconfig--level3atdoffchkconfig--level3gpmoffchkconfig--level3autofsoffchkconfig--level3cpuspeedoffchkconfig--level3haldaemonoffchkconfig--level3nfslockoffchkconfig--level3portmapoffchkconfig--level3xfsoffchkconfig--level3netfsoffchkconfig--level3smartdoffchkconfig--level3ip6tablesoffchkconfig--level3isdnoffchkconfig--level3rpcidmapdoffchkconfig--level3microcode_ctloff
复制代码
  1. serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop
复制代码
安装体系更新和所需软件撑持


[/code]
  1. yum-yupdateyum-yinstallgccgcc-c++autoconflibjpeglibjpeg-devellibpnglibpng-develfreetypefreetype-devellibxml2libxml2-develzlibzlib-develglibcglibc-develglib2glib2-develbzip2bzip2-develncursesncurses-develcurlcurl-devele2fsprogse2fsprogs-develkrb5krb5-devellibidnlibidn-developensslopenssl-developenldapopenldap-develnss_ldapopenldap-clientsopenldap-serversntprar
复制代码
下载必要用到的软件包(以下地点都是官方下载、也能够本人查找)
  1. 【下载PHP必要的库】wgethttp://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gzwgethttp://ncu.dl.sourceforge.net/project/mcrypt/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gzwgethttp://ncu.dl.sourceforge.net/project/mhash/mhash/0.9.9.9/mhash-0.9.9.9.tar.gzwgethttp://ncu.dl.sourceforge.net/project/mcrypt/MCrypt/2.6.8/mcrypt-2.6.8.tar.gz【下载mysql、php、nginx】wgethttp://mysql.mirrors.hoobly.com/Downloads/MySQL-5.1/mysql-5.1.57.tar.gzwgethttp://us.php.net/distributions/php-5.2.17.tar.gzwgethttp://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gzwgethttp://www.nginx.org/download/nginx-1.0.2.tar.gzwgetftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.12.tar.gz【下载php扩大】wgethttp://pecl.php.net/get/memcache-2.2.6.tgzwgethttp://pecl.php.net/get/PDO_MYSQL-1.0.2.tgzwgethttp://bart.eaccelerator.net/source/0.9.6.1/eaccelerator-0.9.6.1.tar.bz2wgetftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick-6.7.0-8.tar.gzwgethttp://pecl.php.net/get/imagick-3.0.0.tgz
复制代码
2、安装PHP必要的库步伐
  1. tarzxvflibiconv-1.13.1.tar.gzcdlibiconv-1.13.1/&&./configure--prefix=/usr/localmake&&makeinstall&&cd..tarzxvflibmcrypt-2.5.8.tar.gzcdlibmcrypt-2.5.8/&&./configuremake&&makeinstall/sbin/ldconfig&&cdlibltdl/&&./configure--enable-ltdl-installmake&&makeinstall&&cd../..tarzxvfmhash-0.9.9.9.tar.gzcdmhash-0.9.9.9/&&./configuremake&&makeinstall&&cd..ln-s/usr/local/lib/libmcrypt.la/usr/lib/libmcrypt.laln-s/usr/local/lib/libmcrypt.so/usr/lib/libmcrypt.soln-s/usr/local/lib/libmcrypt.so.4/usr/lib/libmcrypt.so.4ln-s/usr/local/lib/libmcrypt.so.4.4.8/usr/lib/libmcrypt.so.4.4.8ln-s/usr/local/lib/libmhash.a/usr/lib/libmhash.aln-s/usr/local/lib/libmhash.la/usr/lib/libmhash.laln-s/usr/local/lib/libmhash.so/usr/lib/libmhash.soln-s/usr/local/lib/libmhash.so.2/usr/lib/libmhash.so.2ln-s/usr/local/lib/libmhash.so.2.0.1/usr/lib/libmhash.so.2.0.1ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
复制代码
tarzxvfmcrypt-2.6.8.tar.gz
cdmcrypt-2.6.8/&&/sbin/ldconfig
./configure&&make&&makeinstall&&cd..
3、编译安装MySQL
  1. tarzxvfmysql-5.1.57.tar.gz&&cdmysql-5.1.57./configure--prefix=/usr/local/webserver/mysql/--enable-assembler--with-extra-charsets=complex--enable-thread-safe-client--with-big-tables--with-readline--with-ssl--with-embedded-server--enable-local-infilemake&&makeinstall&&cd..
复制代码
创立mysql用户组,创立数据库、日记等存储目次并付与权限
  1. mkdir-p/data/mysqldatamkdir-p/data/mysqldata/databasemkdir-p/data/mysqldata/logmkdir-p/data/mysqldata/pidgroupaddmysqluseradd-gmysql-d/data/mysqldata/database-s/sbin/nologinmysqlchgrp-Rmysql/usr/local/webserver/mysql/.chown-Rroot:mysql/usr/local/webserver/mysql/*chown-Rmysql:mysql/data/mysqldata/*
复制代码
修正my.cnf文件参数(参数合用于年夜于2G内存办事器)
  1. [client]port=3306socket=/tmp/mysql.sock[mysqld]user=mysqlport=3306socket=/tmp/mysql.sockbasedir=/usr/local/webserver/mysqldatadir=/data/mysqldata/databaselog-error=/data/mysqldata/log/mysql_error.logpid-file=/data/mysqldata/pid/mysql.pidskip-external-lockingskip-name-resolveback_log=500key_buffer_size=256Mmax_allowed_packet=32Mthread_stack=192Ktable_cache=256sort_buffer_size=4Mread_buffer_size=4Mjoin_buffer_size=4Mread_rnd_buffer_size=8Mmyisam_sort_buffer_size=64Mthread_cache=128thread_cache_size=10query_cache_size=32Mtmp_table_size=128Mmax_connections=5000wait_timeout=60max_connect_errors=6000expire_logs_days=30server-id=1[mysqldump]quickmax_allowed_packet=32M[mysql]no-auto-rehash
复制代码
初始化MySQL办事
  1. /usr/local/webserver/mysql/bin/mysql_install_db--basedir=/usr/local/webserver/mysql--datadir=/data/mysqldata/database--user=mysql
复制代码
启动MySQL办事
  1. serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop0
复制代码
修正root暗码
  1. serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop1
复制代码
4、编译安装PHP(FastCGI形式)
  1. serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop2
复制代码
5、安装PHP扩大模块
  1. serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop3
复制代码
修正php.ini文件
  1. serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop4
复制代码
查找:
  1. serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop5
复制代码
修正为:
  1. serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop6
复制代码
并在此行后增添以下几行,然后保留:
  1. serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop7
复制代码
再查找:
  1. serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop8
复制代码
修正为:
  1. serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop9
复制代码
创立缓存目次,设置eAccelerator减速PHP:
  1. 0
复制代码
将以下参数增加到php.ini文件开端
  1. 1
复制代码
修正php-fpm.conf设置文件
  1. 2
复制代码
假如安装Nginx+PHP用于步伐调试,请将以下的
  1. 3
复制代码
改成
  1. 4
复制代码
以便显现PHP毛病信息,不然,Nginx会报形态为500的空缺毛病页
启动php-cgi历程,监听127.0.0.1的9000端口,历程数为128(假如办事器内存小于3GB,能够只开启64个历程),用户为:www
Ulimit-SHn65535
/usr/local/webserver/php/sbin/php-fpmstart//在www用户创立以后在开启。
注:/usr/local/webserver/php/sbin/php-fpm另有其他参数,包含:start|stop|quit|restart|reload|logrotate,修正php.ini后不重启php-cgi,从头加载设置文件利用reload。
6、编译安装nginx
创立www用户和组,和网站目次,日记目次
  1. 5
复制代码
创立或修正nginx设置文件
catnginx.conf
  1. 6
复制代码
catvhosts.conf
  1. 7
复制代码
catenable_fcgi.conf
  1. 8
复制代码
启动nginx办事
  1. 9
复制代码

小知识:CentOS完全遵守上游供应商的再发行政策,并且以百分之百的软件兼容性为目标。
简单生活 该用户已被删除
沙发
发表于 2015-1-17 07:23:14 | 只看该作者
眼看这个学期的Linux课程已经告一段落了,我觉得有必要写一遍心得体会来总结一下这学期对着门课程的学习。
山那边是海 该用户已被删除
板凳
发表于 2015-1-21 07:47:52 | 只看该作者
把这个问题放在其他Linux社区请求帮助也是一种选择。如果Linux得不到答案,请不要以为我们觉得无法帮助你。有时只是看到你问题的人不知道答案罢了。这时换一个社区是不错的选择。
因胸联盟 该用户已被删除
地板
发表于 2015-1-30 12:27:57 | 只看该作者
和私有操作系统不同,各个Linux的发行版本的技术支持时间都较短,这对于Linux初学者是往往不够的。
金色的骷髅 该用户已被删除
5#
发表于 2015-2-6 11:51:27 | 只看该作者
熟悉系统的基本操作,Linux的图形界面直观,操作简便,多加上机练习就可熟悉操作,在Linux下学习办公软件等常用软件。
分手快乐 该用户已被删除
6#
发表于 2015-2-16 04:30:13 | 只看该作者
对Linux命令熟悉后,你可以开始搭建一个小的Linux网络,这是最好的实践方法。Linux是网络的代名词,Linux网络服务功能非常强大,不论是邮件服务器、Web服务器、DNS服务器等都非常完善。
小妖女 该用户已被删除
7#
发表于 2015-3-4 23:57:23 | 只看该作者
Windows?是图形界面的,Linux类似以前的?DOS,是文本界面的,如果你运行了图形界面程序X-WINDOWS后,Linux?也能显示图形界面,也有开始菜单、桌面、图标等。
灵魂腐蚀 该用户已被删除
8#
发表于 2015-3-11 21:56:02 | 只看该作者
其实老师让写心得我也没怎么找资料应付,自己想到什么就写些什么,所以不免有些凌乱;很少提到编程,因为那些在实验报告里已经说了,这里再写就多余了。
小女巫 该用户已被删除
9#
发表于 2015-3-19 16:14:27 | 只看该作者
其中不乏很多IT精英的心血。我们学透以后更可以做成自己的OS!?
10#
发表于 2015-3-29 14:42:04 | 只看该作者
其实老师让写心得我也没怎么找资料应付,自己想到什么就写些什么,所以不免有些凌乱;很少提到编程,因为那些在实验报告里已经说了,这里再写就多余了。
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|仓酷云 鄂ICP备14007578号-2

GMT+8, 2024-5-7 09:33

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表