nginx+apache+php5.docx
《nginx+apache+php5.docx》由会员分享,可在线阅读,更多相关《nginx+apache+php5.docx(17页珍藏版)》请在冰豆网上搜索。
![nginx+apache+php5.docx](https://file1.bdocx.com/fileroot1/2023-1/23/3fd49bf3-7c08-4468-bd46-7d4cb509742e/3fd49bf3-7c08-4468-bd46-7d4cb509742e1.gif)
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
/usr/local/php/logs/php-fpm.pid
Errorlogfile
/usr/local/php/logs/php-fpm-error.log
Loglevel
notice
WhenthisamountofphpprocessesexitedwithSIGSEGVorSIGBUS...
10
...inalessthanthisintervaloftime,agracefulrestartwillbeinitiated.
Usefultoworkaroundaccidentalcurruptionsinaccelerator'ssharedmemory.
1m
Timelimitonwaitingchild'sreactiononsignalsfrommaster
5s
Setto'no'todebugfpm
yes
Nameofpool.Usedinlogsandstats.
default
Addresstoacceptfastcgirequestson.
Validsyntaxis'ip.ad.re.ss:
port'orjust'port'or'/path/to/unix/socket'
127.0.0.1:
9000
Setlisten
(2)backlog
-1
Setpermissionsforunixsocket,ifoneused.
InLinuxread/writepermissionsmustbesetinordertoallowconnectionsfromwebserver.
ManyBSD-derrivedsystemsallowconnectionsregardlessofpermissions.
0666
Additionalphp.inidefines,specifictothispoolofworkers.
/usr/sbin/sendmail-t-i
1
Unixuserofprocesses
www
Unixgroupofprocesses
www
Processmanagersettings
Setsstyleofcontrolingworkerprocesscount.
Validvaluesare'static'and'apache-like'
static
Setsthelimitonthenumberofsimultaneousrequeststhatwillbeserved.
EquivalenttoApacheMaxClientsdirective.
EquivalenttoPHP_FCGI_CHILDRENenvironmentinoriginalphp.fcgi
Usedwithanypm_style.
128
Settingsgroupfor'apache-like'pmstyle
Setsthenumberofserverprocessescreatedonstartup.
Usedonlywhen'apache-like'pm_styleisselected
20
Setsthedesiredminimumnumberofidleserverprocesses.
Usedonlywhen'apache-like'pm_styleisselected
5
Setsthedesiredmaximumnumberofidleserverprocesses.
Usedonlywhen'apache-like'pm_styleisselected
35
Thetimeout(inseconds)forservingasinglerequestafterwhichtheworkerprocesswillbeterminated
Shouldbeusedwhen'max_execution_time'inioptiondoesnotstopscriptexecutionforsomereason
'0s'means'off'
0s
Thetimeout(inseconds)forservingofsinglerequestafterwhichaphpbacktracewillbedumpedtoslow.logfile
'0s'means'off'
0s
Thelogfileforslowrequests
logs/slow.log
Setopenfiledescrlimit
51200
Setmaxcoresizerlimit
0
Chroottothisdirectoryatthestart,absolutepath
Chdirtothisdirectoryatthestart,absolutepath
Redirectworkers'stdoutandstderrintomainerrorlog.
Ifnotset,theywillberedirectedto/dev/null,accordingtoFastCGIspecs
yes
Howmuchrequestseachprocessshouldexecutebeforerespawn.
Usefultoworkaroundmemoryleaksin3rdpartylibraries.
Forendlessrequestprocessingpleasespecify0
EquivalenttoPHP_FCGI_MAX_REQUESTS
500
Commaseparatedlistofipv4addressesofFastCGIclientsthatallowedtoconnect.
EquivalenttoFCGI_WEB_SERVER_ADDRSenvironmentinoriginalphp.fcgi(5.2.2+)
MakessenseonlywithAF_INETlisteningsocket.
127.0.0.1
PassenvironmentvariableslikeLD_LIBRARY_PATH
All$VARIABLEsaretakenfromcurrentenvironment
$HOSTNAME
/usr/local/bin:
/usr/bin:
/bin
/tmp
/tmp
/tmp
$OSTYPE
$MACHTYPE
2
启动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