nginx+apache+php5.docx
- 文档编号:7403091
- 上传时间:2023-01-23
- 格式:DOCX
- 页数:17
- 大小:21.73KB
nginx+apache+php5.docx
《nginx+apache+php5.docx》由会员分享,可在线阅读,更多相关《nginx+apache+php5.docx(17页珍藏版)》请在冰豆网上搜索。
nginx+apache+php5
Nginx+php5+apapche
首先安装nginx+php5
LANG=C//此处定义编译语言为C
yum-yinstallgccgcc-c++autoconflibjpeglibjpeg-devellibpnglibpng-devellibeventfreetypefreetype-devellibxml2libxml2-develzlibzlib-develglibcglibc-develglib2glib2-develbzip2bzip2-develncursesncurses-develcurlcurl-develssse2fsprogse2fsprogs-develkrb5krb5-devellibidnlibidn-developensslopenssl-developenldapopenldap-develnss_ldapopenldap-clientsopenldap-servers//此处升级库文件
tarzxvflibiconv-1.13.1.tar.gz
cdlibiconv-1.13.1/
./configure--prefix=/usr/local
make
makeinstall
//安装lib库
tarzxvflibmcrypt-2.5.8.tar.gz
cdlibmcrypt-2.5.8/
./configure
make
makeinstall
/sbin/ldconfig
cdlibltdl/
./configure--enable-ltdl-install
make
makeinstall
//安装lib库
tarxvfmhash-0.9.9.9.tar
cdmhash-0.9.9.9/
./configure
make
makeinstall
ln-s/usr/local/lib/libmcrypt.la/usr/lib/libmcrypt.la
ln-s/usr/local/lib/libmcrypt.so/usr/lib/libmcrypt.so
ln-s/usr/local/lib/libmcrypt.so.4/usr/lib/libmcrypt.so.4
ln-s/usr/local/lib/libmcrypt.so.4.4.8/usr/lib/libmcrypt.so.4.4.8
ln-s/usr/local/lib/libmhash.a/usr/lib/libmhash.a
ln-s/usr/local/lib/libmhash.la/usr/lib/libmhash.la
ln-s/usr/local/lib/libmhash.so/usr/lib/libmhash.so
ln-s/usr/local/lib/libmhash.so.2/usr/lib/libmhash.so.2
ln-s/usr/local/lib/libmhash.so.2.0.1/usr/lib/libmhash.so.2.0.1
//超链接库文件,编译PHP时需要这些库文件
tarzxvfmcrypt-2.6.8.tar.gz
cdmcrypt-2.6.8/
/sbin/ldconfig
./configure
make
makeinstall
tarzxfphp-5.2.14.tar.gz
gzip-cdphp-5.2.14-fpm-0.5.14.diff.gz|patch-dphp-5.2.14-p1
cdphp-5.2.14/
./configure--prefix=/usr/local/php--with-config-file-path=/usr/local/php/etc--with-iconv-dir=/usr/local--with-freetype-dir--with-jpeg-dir--with-png-dir--with-zlib--with-libxml-dir=/usr--enable-xml--disable-rpath--enable-discard-path--enable-safe-mode--enable-bcmath--enable-shmop--enable-sysvsem--enable-inline-optimization--with-curl--with-curlwrappers--enable-mbregex--enable-fastcgi--enable-fpm--enable-force-cgi-redirect--enable-mbstring--with-mcrypt--with-gd--enable-gd-native-ttf--with-openssl--with-mhash--enable-pcntl--enable-sockets
makeZEND_EXTRA_LIBS='-liconv'
makeinstall
cpphp.ini-dist/usr/local/php/etc/php.ini
//编译PHP
tarzxvfmemcache-2.2.6.tgz
cdmemcache-2.2.6/
/usr/local/php/bin/phpize
./configure--with-php-config=/usr/local/php/bin/php-config
make
makeinstall
tarjxvfeaccelerator-0.9.6.1.tar.bz2
cdeaccelerator-0.9.6.1/
/usr/local/php/bin/phpize
./configure--enable-eaccelerator=shared--with-php-config=/usr/local/php/bin/php-config
make
makeinstall
//编译php5扩展模块
Sed-i's#extension_dir="./"#extension_dir="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/"\nextension="memcache.so"\n#'/usr/local/php/etc/php.ini
sed-i's#output_buffering=Off#output_buffering=On#'/usr/local/php/etc/php.ini
//修改php.ini配置
mkdir-p/usr/local/eaccelerator_cache
vi/usr/local/php/etc/php.ini
#按shift+g键跳到配置文件的最末尾,加上以下配置信息:
[eaccelerator]
zend_extension="/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="128"
eaccelerator.cache_dir="/usr/local/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="300"
eaccelerator.shm_prune_period="120"
eaccelerator.shm_only="0"
press="1"
press_level="9"
//配置eAccelerator加速PHP
创建www用户和组
/usr/sbin/groupaddwww
/usr/sbin/useradd-gwwwwww-s/sbin/nologin
创建php-fpm配置文件(php-fpm是为PHP打的一个FastCGI管理补丁,可以平滑变更php.ini配置而无需重启php-cgi):
在/usr/local/php/etc/目录中创建php-fpm.conf文件:
rm-f/usr/local/php/etc/php-fpm.conf
vi/usr/local/php/etc/php-fpm.conf
加入以下内容:
xmlversion="1.0"?
>
Allrelativepathsinthisconfigarerelativetophp'sinstallprefix
Pidfile
Errorlogfile
Loglevel
WhenthisamountofphpprocessesexitedwithSIGSEGVorSIGBUS...
...inalessthanthisintervaloftime,agracefulrestartwillbeinitiated.
Usefultoworkaroundaccidentalcurruptionsinaccelerator'ssharedmemory.
Timelimitonwaitingchild'sreactiononsignalsfrommaster
Setto'no'todebugfpm
Nameofpool.Usedinlogsandstats.
Addresstoacceptfastcgirequestson.
Validsyntaxis'ip.ad.re.ss:
port'orjust'port'or'/path/to/unix/socket'
9000
Setlisten
(2)backlog
Setpermissionsforunixsocket,ifoneused.
InLinuxread/writepermissionsmustbesetinordertoallowconnectionsfromwebserver.
ManyBSD-derrivedsystemsallowconnectionsregardlessofpermissions.
Additionalphp.inidefines,specifictothispoolofworkers.
Unixuserofprocesses
Unixgroupofprocesses
Processmanagersettings
Setsstyleofcontrolingworkerprocesscount.
Validvaluesare'static'and'apache-like'
Setsthelimitonthenumberofsimultaneousrequeststhatwillbeserved.
EquivalenttoApacheMaxClientsdirective.
EquivalenttoPHP_FCGI_CHILDRENenvironmentinoriginalphp.fcgi
Usedwithanypm_style.
Settingsgroupfor'apache-like'pmstyle
Setsthenumberofserverprocessescreatedonstartup.
Usedonlywhen'apache-like'pm_styleisselected
Setsthedesiredminimumnumberofidleserverprocesses.
Usedonlywhen'apache-like'pm_styleisselected
Setsthedesiredmaximumnumberofidleserverprocesses.
Usedonlywhen'apache-like'pm_styleisselected
Thetimeout(inseconds)forservingasinglerequestafterwhichtheworkerprocesswillbeterminated
Shouldbeusedwhen'max_execution_time'inioptiondoesnotstopscriptexecutionforsomereason
'0s'means'off'
Thetimeout(inseconds)forservingofsinglerequestafterwhichaphpbacktracewillbedumpedtoslow.logfile
'0s'means'off'
Thelogfileforslowrequests
Setopenfiledescrlimit
Setmaxcoresizerlimit
Chroottothisdirectoryatthestart,absolutepath
Chdirtothisdirectoryatthestart,absolutepath
Redirectworkers'stdoutandstderrintomainerrorlog.
Ifnotset,theywillberedirectedto/dev/null,accordingtoFastCGIspecs
Howmuchrequestseachprocessshouldexecutebeforerespawn.
Usefultoworkaroundmemoryleaksin3rdpartylibraries.
Forendlessrequestprocessingpleasespecify0
EquivalenttoPHP_FCGI_MAX_REQUESTS
Commaseparatedlistofipv4addressesofFastCGIclientsthatallowedtoconnect.
EquivalenttoFCGI_WEB_SERVER_ADDRSenvironmentinoriginalphp.fcgi(5.2.2+)
MakessenseonlywithAF_INETlisteningsocket.
PassenvironmentvariableslikeLD_LIBRARY_PATH
All$VARIABLEsaretakenfromcurrentenvironment
/usr/bin:
/bin
启动php-cgi进程,监听127.0.0.1的9000端口,进程数为200(如果服务器内存小于3GB,可以只开启64个进程),用户为www:
ulimit-SHn51200
/usr/local/php/sbin/php-fpmstart
usr/local/php/sbin/php-fpm还有其他参数,
包括:
start|stop|quit|restart|reload|logrotate,
修改php.ini后不重启php-cgi,重新加载配置文件使用reload。
rpm-qa|greppcre
cp/lib/libpcre.so.0/
rpm-e--nodeps`rpm-qa|greppcre`
tarzxvfpcre-8.10.tar.gz
cdpcre-8.10
cp/libpcre.so.0/lib/
./configure
make&&makeinstall
删除系统自带的pcre库,重新安装Nginx所需的pcre库
tarzxvfnginx-0.8.53.tar.gz
cdnginx-0.8.53/
./configure--user=www--group=www--prefix=/usr/local/nginx--with-http_stub_status_module--with-http_ssl_module
make&&makeinstall
//安装nginx
mkdir-p/usr/local/nginx/logs
chmod+w/usr/local/nginx/logs
chown-Rwww:
www/usr/local/nginx/logs
//创建Nginx日志目录
在/usr/local/nginx/conf/目录中创建nginx.conf文件
rm-f/usr/local/nginx/conf/nginx.conf
vi/usr/local/nginx/conf/nginx.conf
输入以下内容:
userwwwwww;
w
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- nginx apache php5