extension
笔记本键盘失灵-怎么群发短信给所有人
2023年4月6日发(作者:win10怎么样)构建高性能Web环境(linux/nginx/mysql/php-fastcgi)
一、Centos系统安装完毕之后,关闭不需要的服务优化系统,安装系统更新和所需软件支持。
关闭不需要的服务
chkconfig--level3acpidoff
chkconfig--level3anacronoff
chkconfig--level3apmdoff
chkconfig--level3mdmonitoroff
chkconfig--level3xinetdoff
chkconfig--level3sendmailoff
chkconfig--level3rpcgssdoff
chkconfig--level3rawdevicesoff
chkconfig--level3messagebusoff
chkconfig--level3atdoff
chkconfig--level3gpmoff
chkconfig--level3autofsoff
chkconfig--level3cpuspeedoff
chkconfig--level3haldaemonoff
chkconfig--level3nfslockoff
chkconfig--level3portmapoff
chkconfig--level3xfsoff
chkconfig--level3netfsoff
chkconfig--level3smartdoff
chkconfig--level3ip6tablesoff
chkconfig--level3isdnoff
chkconfig--level3rpcidmapdoff
chkconfig--level3microcode_ctloff
serviceacpidstop
serviceanacronstop
serviceapmdstop
servicemdmonitorstop
servicexinetdstop
servicesendmailstop
servicerpcgssdstop
servicerawdevicesstop
servicemessagebusstop
serviceatdstop
servicegpmstop
serviceautofsstop
servicecpuspeedstop
servicehaldaemonstop
servicenfslockstop
serviceportmapstop
servicexfsstop
servicenetfsstop
servicesmartdstop
serviceip6tablesstop
serviceisdnstop
servicerpcidmapdstop
servicemicrocode_ctlstop
安装系统更新和所需软件支持
yum-yupdate
yum-yinstallgccgcc-c++autoconflibjpeglibjpeg-devellibpnglibpng-develfreetypefreetype-devel
libxml2libxml2-develzlibzlib-develglibcglibc-develglib2glib2-develbzip2bzip2-develncurses
ncurses-develcurlcurl-devele2fsprogse2fsprogs-develkrb5krb5-devellibidnlibidn-developenssl
openssl-developenldapopenldap-develnss_ldapopenldap-clientsopenldap-serversntprar
下载需要用到的软件包(以下地址都是官方下载、也可以自己查找)
【下载PHP需要的库】
wget/pub/gnu/libiconv/
wget/project/mcrypt/Libmcrypt/2.5.8/
wget/project/mhash/mhash/0.9.9.9/
wget/project/mcrypt/MCrypt/2.6.8/
【下载mysql、php、nginx】
wget/Downloads/MySQL-5.1/
wget/distributions/
wget/downloads/
wget/download/
wgetftp:///pub/software/programming/pcre/
【下载php扩展】
wget/get/
wget/get/PDO_
wget/source/0.9.6.1/2
wgetftp:///pub/ImageMagick/
wget/get/
二、安装PHP需要的库程序
cdlibiconv-1.13.1/&&./configure--prefix=/usr/local
make&&makeinstall&&cd..
cdlibmcrypt-2.5.8/&&./configure
make&&makeinstall
/sbin/ldconfig&&cdlibltdl/&&./configure--enable-ltdl-install
make&&makeinstall&&cd../..
cdmhash-0.9.9.9/&&./configure
make&&makeinstall&&cd..
ln-s/usr/local/lib//usr/lib/
ln-s/usr/local/lib//usr/lib/
ln-s/usr/local/lib/.4/usr/lib/.4
ln-s/usr/local/lib/.4.4.8/usr/lib/.4.4.8
ln-s/usr/local/lib/libmhash.a/usr/lib/libmhash.a
ln-s/usr/local/lib//usr/lib/
ln-s/usr/local/lib//usr/lib/
ln-s/usr/local/lib/.2/usr/lib/.2
ln-s/usr/local/lib/.2.0.1/usr/lib/.2.0.1
ln-s/usr/local/bin/libmcrypt-config/usr/bin/libmcrypt-config
cdmcrypt-2.6.8/&&/sbin/ldconfig
./configure&&make&&makeinstall&&cd..
三、编译安装MySQL
&&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-infile
make&&makeinstall&&cd..
创建mysql用户组,创建数据库、日志等存储目录并赋予权限
mkdir-p/data/mysqldata
mkdir-p/data/mysqldata/database
mkdir-p/data/mysqldata/log
mkdir-p/data/mysqldata/pid
groupaddmysql
useradd-gmysql-d/data/mysqldata/database-s/sbin/nologinmysql
chgrp-Rmysql/usr/local/webserver/mysql/.
chown-Rroot:mysql/usr/local/webserver/mysql/*
chown-Rmysql:mysql/data/mysqldata/*
修改文件参数(参数适用于大于2G内存服务器)
[client]
port=3306
socket=/tmp/
[mysqld]
user=mysql
port=3306
socket=/tmp/
basedir=/usr/local/webserver/mysql
datadir=/data/mysqldata/database
log-error=/data/mysqldata/log/mysql_
pid-file=/data/mysqldata/pid/
skip-external-locking
skip-name-resolve
back_log=500
key_buffer_size=256M
max_allowed_packet=32M
thread_stack=192K
table_cache=256
sort_buffer_size=4M
read_buffer_size=4M
join_buffer_size=4M
read_rnd_buffer_size=8M
myisam_sort_buffer_size=64M
thread_cache=128
thread_cache_size=10
query_cache_size=32M
tmp_table_size=128M
max_connections=5000
wait_timeout=60
max_connect_errors=6000
expire_logs_days=30
server-id=1
[mysqldump]
quick
max_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服务
/usr/local/webserver/mysql/bin/mysqld_safe--user=mysql&//启动服务
/usr/local/webserver/mysql/bin/mysqladmin-uroot-pshutdown//停止服务
修改root密码
/usr/local/webserver/mysql/bin/mysqladmin-urootpassword‘yourpassword’
四、编译安装PHP(FastCGI模式)
|patch-dphp-5.2.17-p1
cdphp-5.2.17/
./buildconf--force
./configure--prefix=/usr/local/webserver/php
--with-config-file-path=/usr/local/webserver/php/etc
--with-mysql=/usr/local/webserver/mysql
--with-mysqli=/usr/local/webserver/mysql/bin/mysql_config
--with-gd
--with-jpeg-dir
--with-iconv-dir=/usr/local
--with-libxml-dir=/usr
--with-zlib
--with-png-dir
--with-curl
--with-ldap
--with-xmlrpc
--with-openssl
--with-mhash
--with-mcrypt
--with-freetype-dir
--with-ldap-sasl
--with-curlwrappers
--enable-xml
--enable-shared
--enable-discard-path
--enable-safe-mode
--enable-bcmath
--enable-shmop
--enable-sysvsem
--enable-inline-optimization
--enable-mbregex
--enable-fastcgi
--enable-fpm
--enable-force-cgi-redirect
--enable-mbstring=all
--enable-gd-native-ttf
--enable-pcntl
--enable-sockets
--enable-zip
--enable-soap
makeZEND_EXTRA_LIBS='-liconv'
makeinstall&&cd..
五、安装PHP扩展模块
cdmemcache-2.2.6/
/usr/local/webserver/php/bin/phpize
./configure--with-php-config=/usr/local/webserver/php/bin/php-config
make&&makeinstall&&cd..
tarzxvfPDO_
cdPDO_MYSQL-1.0.2/
/usr/local/webserver/php/bin/phpize
./configure
--with-php-config=/usr/local/webserver/php/bin/php-config
--with-pdo-mysql=/usr/local/webserver/mysql
make&&makeinstall&&cd..
2
cdeaccelerator-0.9.6.1/
/usr/local/webserver/php/bin/phpize
./configure--enable-eaccelerator=shared
--with-php-config=/usr/local/webserver/php/bin/php-config
make&&makeinstall&&cd..
cdImageMagick-6.7.0-8/
./configure&&make&&makeinstall&&cd..
cdimagick-3.0.0/
/usr/local/webserver/php/bin/phpize
./configure--with-php-config=/usr/local/webserver/php/bin/php-config
make&&makeinstall&&cd..
修改文件
vim/usr/local/webserver/php/etc/
查找:
extension_dir="./"
修改为:
extension_dir="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/"
并在此行后增加以下几行,然后保存:
extension=""
extension="pdo_"
extension=""
再查找:output_buffering=Off
修改为:output_buffering=On
创建缓存目录,配置eAccelerator加速PHP:
mkdir-p/usr/local/webserver/eaccelerator_cache
将以下参数添加到文件末尾
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts
-20060613/"
_size="64"
_dir="/usr/local/webserver/eaccelerator_cache"
="1"
zer="1"
_mtime="1"
="0"
=""
_max="0"
_ttl="3600"
_prune_period="3600"
_only="0"
ss="1"
ss_level="9"
修改配置文件
vim/usr/local/webserver/php/etc/
如果安装Nginx+PHP用于程序调试,请将以下的
0
改为
1
以便显示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-cgi,重新加载配置文件使用reload。
六、编译安装nginx
创建www用户和组,以及网站目录,日志目录
groupaddwww
useradd-gwww-s/sbin/nologinwww
mkdir-p/data/wsdata/wwwroot
mkdir-p/data/wsdata/wwwroot/error
echo"404">/data/wsdata/wwwroot/error/
echo"serveristoobusy">/data/wsdata/wwwroot/error/
chmod+w/data/wsdata/wwwroot
mkdir-p/data/wslogs/wwwroot
chmod777/data/wslogs/wwwroot
chown-Rwww:www/data/wsdata/wwwroot
&&cdpcre-8.12/
./configure&&make&&makeinstall&&cd..
&&cdnginx-1.0.2/
./configure
--user=www
--group=www
--prefix=/usr/local/webserver/nginx
--with-http_stub_status_module
--with-http_ssl_module
--with-http_flv_module
--with-cc-opt='-O3'
--with-cpu-opt=opteron
--with-http_gzip_static_module
make&&makeinstall&&cd..
创建或修改nginx配置文件
#useroptions
userwwwwww;
#CPUCoreoptions
worker_processes4;
#nginxProcessoptions
pid/usr/local/webserver/nginx/;
#[debug|info|notice|warn|error|crit]
error_log/wslogs/nginx_t;
#Specifiesthevalueformaximumfiledescriptorsthatcanbeopenedbythis
process.
worker_rlimit_nofile51200;
events{
useepoll;
#maxclient=worker_processes*worker_connections/cpu_number
worker_connections51200;
}
http{
;
default_typeapplication/octet-stream;
#charsetgb2312;
#Generaloptions
server_names_hash_bucket_size128;
client_header_buffer_size32k;
large_client_header_buffers432k;
ignore_invalid_headerson;
recursive_error_pageson;
server_name_in_redirectoff;
sendfileon;
#timeouts
keepalive_timeout60;
#TCPoptions
tcp_nopushon;
tcp_nodelayon;
#fastcgioptions
fastcgi_connect_timeout300;
fastcgi_send_timeout300;
fastcgi_read_timeout300;
fastcgi_buffer_size64k;
fastcgi_buffers464k;
fastcgi_busy_buffers_size128k;
fastcgi_temp_file_write_size128k;
fastcgi_intercept_errorson;
#sizelimits
client_max_body_size300m;
client_body_buffer_size256k;
#gzipcompression
gzipon;
gzip_min_length1k;
gzip_buffers416k;
gzip_http_version1.1;
gzip_comp_level2;
gzip_typestext/plaintext/cssapplication/x-javascriptapplication/xml;
gzip_varyon;
#limit_zonecrawler$binary_remote_addr10m;
#virtualhostsoptions
;
}
server{
listen80;
server_;
access_log/data/wslogs/linuxde_www_bined;
;
root/data/wsdata/wwwroot/linuxde/www;
#error_page404=./error/;
#error_page5=./error/;
#重定向到
if($host!~"^$"){
rewrite^(.*)$1permanent;
}
location~.*.(php|php5)?${
#fastcgi_passunix:/tmp/;
fastcgi_pass127.0.0.1:9000;
fastcgi_;
includeenable_;
}
location~.*.(gif|jpg|jpeg|png|bmp|swf)${
access_logoff;
expires30d;
}
location~.*.(js|css)${
access_logoff;
expires1d;
}
#wordpress伪静态
location/{
if(-f$request_filename/){
rewrite(.*)$1/eak;
}
if(-f$request_filename/){
rewrite(.*)$1/;
}
if(!-f$request_filename){
rewrite(.*)/;
}
}
}
catenable_
#PHPPATH_INFObugs
if($request_filename~*(.*).php){
set$php_url$1;
}
if(!-e$php_){
return403;
}
fastcgi_paramGATEWAY_INTERFACECGI/1.1;
fastcgi_paramSERVER_SOFTWAREnginx;
fastcgi_paramQUERY_STRING$query_string;
fastcgi_paramREQUEST_METHOD$request_method;
fastcgi_paramCONTENT_TYPE$content_type;
fastcgi_paramCONTENT_LENGTH$content_length;
fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
fastcgi_paramSCRIPT_NAME$fastcgi_script_name;
fastcgi_paramREQUEST_URI$request_uri;
fastcgi_paramDOCUMENT_URI$document_uri;
fastcgi_paramDOCUMENT_ROOT$document_root;
fastcgi_paramSERVER_PROTOCOL$server_protocol;
fastcgi_paramREMOTE_ADDR$remote_addr;
fastcgi_paramREMOTE_PORT$remote_port;
fastcgi_paramSERVER_ADDR$server_addr;
fastcgi_paramSERVER_PORT$server_port;
fastcgi_paramSERVER_NAME$server_name;
#fortest
fastcgi_paramHTTP_ACCEPT_ENCODINGgzip,deflate;
#PHPonly,requiredifPHPwasbuiltwith--enable-force-cgi-redirect
fastcgi_paramREDIRECT_STATUS200;
启动nginx服务
/usr/local/webserver/nginx/sbin/nginx-t//检测配置文件是否正确
/usr/local/webserver/nginx/sbin/nginx//启动nginx
extension_dir