Centos yum 安装nginx+php+mysql
2013-06-28 17:02
459 查看
yum-yinstallyum-fastestmirror
yum-yupdate
yum-yinstallpatchmakegccgcc-c++gcc-g77flexbison
yum-yinstalllibtoollibtool-libskernel-develautoconf
yum-yinstalllibjpeglibjpeg-devellibpnglibpng-devel
yum-yinstallfreetypefreetype-devellibxml2libxml2-develzlibzlib-devel
yum-yinstallglib2glib2-develbzip2diff*
yum-yinstallbzip2-develncursesncurses-develcurlcurl-devele2fsprogs
yum-yinstalle2fsprogs-develkrb5krb5-devellibidnlibidn-devel
yum-yinstallopensslopenssl-develvim-minimal
64位替换i386为x86_64
yum-yinstallmysqlmysql-servermysql-devel
yum-yinstallphpphp-mysqlphp-cgiphp-mbstringphp-gdphp-fastcgiphp-pearphp-pear-DBphp-fpmphp-cliphp-pdophp-mcryptphp-tidyphp-xmlphp-xmlrpcphp-pecl-memcachephp-eaccelerator
yum-yinstallnginx(如果无法安装,执行rpm-Uvhftp://ftp.univie.ac.at/systems/linux/fedora/epel/beta/6/i386/epel-release-6-5.noarch.rpm)
所有的配置文件都在/etc目录
chkconfigmysqldon
chkconfigphp-fpmon
chkconfignginxon
servicemysqldstart
mysqladmin-urootpassword123456
创建www用户和组,以及主机需要的目录,日志目录
groupaddwww
useradd-gwwwwww
mkdir-p/home/www
chmod+w/home/www
mkdir-p/home/www/logs
chmod777/home/www/logs
chown-Rwww:www/home/www
第一个www为文件拥有者名称,第二个www为所属群组。
vi/etc/nginx/nginx.conf
pid/usr/local/nginx/logs/nginx.pid;
#Specifiesthevalueformaximumfiledescriptorsthatcanbeopenedbythisprocess.
worker_rlimit_nofile51200;
events{
useepoll;
worker_connections51200;
}
http{
includemime.types;
default_typeapplication/octet-stream;
#charsegb2312;#默认编码,可以不设置
server_names_hash_bucket_size128;
client_header_buffer_size16k;
large_client_header_buffers416k;
client_max_body_size8m;
sendfileon;
tcp_nopushon;
keepalive_timeout60;
tcp_nodelayon;
fastcgi_connect_timeout300;
fastcgi_send_timeout300;
fastcgi_read_timeout300;
fastcgi_buffer_size64k;
fastcgi_buffers464k;
fastcgi_busy_buffers_size128k;
fastcgi_temp_file_write_size128k;
gzipon;
gzip_min_length1k;
gzip_buffers416k;
gzip_http_version1.0;
gzip_comp_level5;
gzip_typestext/plaintext/javascriptapplication/x-javascripttext/cssapplication/xml;
gzip_varyon;
#limit_zonecrawler$binary_remote_addr10m;
server{
listen80;
server_namelocalhost;
root/home/www;
location/status{
stub_statuson;
access_logoff;
}
location/{
#这里是把所有不存在的文件和目录,全都转到index.php处理
try_files$uri$uri//index.php?q=$uri&$args;
}
#这里分开放到server.conf是为了再开server的时候方便,统一调用,放到/etc/nginx/目录下
includeserver.conf;
log_formataccess'$remote_addr-$remote_user[$time_local]"$request"'
'$status$body_bytes_sent"$http_referer"'
'"$http_user_agent"$http_x_forwarded_for';
access_log/home/www/logs/access.logaccess;
}
vi/etc/nginx/server.conf
location~.*\.(sqlite|sq3)${
denyall;
}
location~.*\.php${
fastcgi_passunix:/tmp/php-cgi.sock;
#fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
includefcgi.conf;
}
location~.*\.(gif|jpg|jpeg|png|bmp|swf|ico)${
expires30d;
access_logoff;
}
location~.*\.(js|css)?${
expires30d;
access_logoff;
}
/sbin/iptables-IINPUT-ptcp--dport80-jACCEPT
开放80端口
servicephp-fpmstart
servicenginxstart
OK!
nginx测试
/usr/local/nginx/sbin/nginx-t
nginx平滑重启命令
/usr/local/nginx/sbin/nginx-sreload
yum-yupdate
yum-yinstallpatchmakegccgcc-c++gcc-g77flexbison
yum-yinstalllibtoollibtool-libskernel-develautoconf
yum-yinstalllibjpeglibjpeg-devellibpnglibpng-devel
yum-yinstallfreetypefreetype-devellibxml2libxml2-develzlibzlib-devel
yum-yinstallglib2glib2-develbzip2diff*
yum-yinstallbzip2-develncursesncurses-develcurlcurl-devele2fsprogs
yum-yinstalle2fsprogs-develkrb5krb5-devellibidnlibidn-devel
yum-yinstallopensslopenssl-develvim-minimal
64位替换i386为x86_64
yum-yinstallmysqlmysql-servermysql-devel
yum-yinstallphpphp-mysqlphp-cgiphp-mbstringphp-gdphp-fastcgiphp-pearphp-pear-DBphp-fpmphp-cliphp-pdophp-mcryptphp-tidyphp-xmlphp-xmlrpcphp-pecl-memcachephp-eaccelerator
yum-yinstallnginx(如果无法安装,执行rpm-Uvh
所有的配置文件都在/etc目录
chkconfigmysqldon
chkconfigphp-fpmon
chkconfignginxon
servicemysqldstart
mysqladmin-urootpassword123456
创建www用户和组,以及主机需要的目录,日志目录
groupaddwww
useradd-gwwwwww
mkdir-p/home/www
chmod+w/home/www
mkdir-p/home/www/logs
chmod777/home/www/logs
chown-Rwww:www/home/www
第一个www为文件拥有者名称,第二个www为所属群组。
vi/etc/nginx/nginx.conf
userwwwwww;
worker_processes2;#这里根据你的CPU和内存配置,设置2到10都OK
error_log/home/www/logs/nginx_error.logcrit;
pid/usr/local/nginx/logs/nginx.pid;
#Specifiesthevalueformaximumfiledescriptorsthatcanbeopenedbythisprocess.
worker_rlimit_nofile51200;
events{
useepoll;
worker_connections51200;
}
http{
includemime.types;
default_typeapplication/octet-stream;
#charsegb2312;#默认编码,可以不设置
server_names_hash_bucket_size128;
client_header_buffer_size16k;
large_client_header_buffers416k;
client_max_body_size8m;
sendfileon;
tcp_nopushon;
keepalive_timeout60;
tcp_nodelayon;
fastcgi_connect_timeout300;
fastcgi_send_timeout300;
fastcgi_read_timeout300;
fastcgi_buffer_size64k;
fastcgi_buffers464k;
fastcgi_busy_buffers_size128k;
fastcgi_temp_file_write_size128k;
gzipon;
gzip_min_length1k;
gzip_buffers416k;
gzip_http_version1.0;
gzip_comp_level5;
gzip_typestext/plaintext/javascriptapplication/x-javascripttext/cssapplication/xml;
gzip_varyon;
#limit_zonecrawler$binary_remote_addr10m;
server{
listen80;
server_namelocalhost;
root/home/www;
location/status{
stub_statuson;
access_logoff;
}
location/{
#这里是把所有不存在的文件和目录,全都转到index.php处理
try_files$uri$uri//index.php?q=$uri&$args;
}
#这里分开放到server.conf是为了再开server的时候方便,统一调用,放到/etc/nginx/目录下
includeserver.conf;
log_formataccess'$remote_addr-$remote_user[$time_local]"$request"'
'$status$body_bytes_sent"$http_referer"'
'"$http_user_agent"$http_x_forwarded_for';
access_log/home/www/logs/access.logaccess;
}
/etc/nginx/conf.d/default.conf
server{
listen80;
server_nameyourdomain.com;
root/home/www/yourdomain;
if($host!~*yourdomain\.com$){
return444;
}
location/{
try_files$uri$uri//index.php?q=$uri&$args;
}
includeserver.conf;#这里复用了,这段就省了
access_log/home/www/logs/yourdomain.com_access.logaccess;
}
}
vi/etc/nginx/server.conf
indexindex.htmlindex.htmindex.php;
#limit_conncrawler20;
location~/\.ht{
denyall;
}
location~.*\.(sqlite|sq3)${
denyall;
}
location~.*\.php${
fastcgi_passunix:/tmp/php-cgi.sock;
#fastcgi_pass127.0.0.1:9000;
fastcgi_indexindex.php;
includefcgi.conf;
}
location~.*\.(gif|jpg|jpeg|png|bmp|swf|ico)${
expires30d;
access_logoff;
}
location~.*\.(js|css)?${
expires30d;
access_logoff;
}
/sbin/iptables-IINPUT-ptcp--dport80-jACCEPT
开放80端口
servicephp-fpmstart
servicenginxstart
OK!
nginx测试
/usr/local/nginx/sbin/nginx-t
nginx平滑重启命令
/usr/local/nginx/sbin/nginx-sreload
相关文章推荐
- centos yum配置mysql-5.5/5.1 php 5.3 nginx安装 spawn-fcgi 安装 php-fpm启动
- centos yum安装nginx php mysql
- CentOS上yum安装nginx+mysql+php+php-fastcgi
- linux server安装nginx+mysql+php+apache+tomcat+java
- 1分钟完美安装最新 CentOS + Nginx + PHP-FPM + MySQL
- Linux LNMP安装 Nginx-Mysql-Php
- nginx+php+mysql安装 三
- 在CentOS 7下编译安装Nginx+PHP+MySQL环境
- CentOS5.5安装Nginx、PHP(FastCGI)、MySQL --搭建LNMP环境安装wordpress
- 安装Nginx与使用PHP5(和PHP-FPM Nginx)和MySQL在 CentOS支持6.0的支持
- Centos YUM安装httpd ,mysql , php
- CentOS6.6纯编译安装Nginx Mysql PHP Memcached
- 服务器基础搭建最全教程 CentOS 7.0编译安装 Nginx1.6.0 + MySQL5.6.19 + PHP5.6.30
- 一步一步教你安装 Nginx+PHP+Mysql
- Ubuntu 12.04上安装Nginx, PHP,Mysql及配置
- CentOS上yum安装nginx+mysql+php+php-fastcgi [经本人整理后亲自测试]
- linux下搭建LNMP(linux+nginx+mysql+php)环境之mysql5.5安装
- CentOS yum安装Apache + PHP + MySQL + Tomcat
- Mac下一键安装Apache/Nginx+MySQL+PHP开发环境 及各版本测试PHP探针
- 12.1 LNMP架构介绍 12.2 MySQL安装 12.3/12.4 PHP安装 12.5 Nginx介绍