|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
小知识:Linux同时具有字符界面和图形界面。在字符界面用户可以通过键盘输入相应的指令来进行操作。
本文次要是撰写Linux体系中PHPWeb情况的设置,先容在CentOS体系下安装:Nginx、MySQL、php-FastCGI,文顶用的软件都是停止2011/6/22最新不乱版。收集上关于这类设置良多,设置历程相差不年夜,可是参数有所分歧。入手下手之前先先容一下nginx:Nginx(enginex)是一款轻量级的Web办事器/反向代办署理办事器及电子邮件(IMAP/POP3)代办署理办事器,并在一个BSD-like协定下刊行。由俄罗斯的步伐计划师IgorSysoev所开辟,最后供***年夜型的出口网站及征采引擎Rambler(俄文:Рамблер)利用。其特性是占据内存少,并发才能强,现实上nginx的并发才能的确在同范例的网页伺服器中体现较好.今朝中国年夜陆利用nginx网站用户有:新浪、网易、腾讯,别的出名的微网志Plurk也利用nginx。 上面入手下手叙说具体设置历程:
1、Centos体系安装终了以后,封闭不必要的办事优化体系,安装体系更新和所需软件撑持。
封闭不必要的办事- 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
复制代码- serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop
复制代码 安装体系更新和所需软件撑持
[/code]- yum-yupdateyum-yinstallgccgcc-c++autoconflibjpeglibjpeg-devellibpnglibpng-develfreetypefreetype-devellibxml2libxml2-develzlibzlib-develglibcglibc-develglib2glib2-develbzip2bzip2-develncursesncurses-develcurlcurl-devele2fsprogse2fsprogs-develkrb5krb5-devellibidnlibidn-developensslopenssl-developenldapopenldap-develnss_ldapopenldap-clientsopenldap-serversntprar
复制代码 下载必要用到的软件包(以下地点都是官方下载、也能够本人查找)- 【下载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必要的库步伐- 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- 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用户组,创立数据库、日记等存储目次并付与权限- 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内存办事器)- [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办事- /usr/local/webserver/mysql/bin/mysql_install_db--basedir=/usr/local/webserver/mysql--datadir=/data/mysqldata/database--user=mysql
复制代码 启动MySQL办事- serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop0
复制代码 修正root暗码- serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop1
复制代码 4、编译安装PHP(FastCGI形式)- serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop2
复制代码 5、安装PHP扩大模块- serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop3
复制代码 修正php.ini文件- serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop4
复制代码 查找:- serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop5
复制代码 修正为:- serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop6
复制代码 并在此行后增添以下几行,然后保留:- serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop7
复制代码 再查找:- serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop8
复制代码 修正为:- serviceacpidstopserviceanacronstopserviceapmdstopservicemdmonitorstopservicexinetdstopservicesendmailstopservicerpcgssdstopservicerawdevicesstopservicemessagebusstopserviceatdstopservicegpmstopserviceautofsstopservicecpuspeedstopservicehaldaemonstopservicenfslockstopserviceportmapstopservicexfsstopservicenetfsstopservicesmartdstopserviceip6tablesstopserviceisdnstopservicerpcidmapdstopservicemicrocode_ctlstop9
复制代码 创立缓存目次,设置eAccelerator减速PHP:将以下参数增加到php.ini文件开端修正php-fpm.conf设置文件假如安装Nginx+PHP用于步伐调试,请将以下的改成以便显现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用户和组,和网站目次,日记目次创立或修正nginx设置文件
catnginx.confcatvhosts.confcatenable_fcgi.conf启动nginx办事
小知识:CentOS完全遵守上游供应商的再发行政策,并且以百分之百的软件兼容性为目标。 |
|