<b>CentOS + Nginx + PHP-FPM + MySQL快速完善安装教程</b>[服务器安全]
本文“<b>CentOS + Nginx + PHP-FPM + MySQL快速完善安装教程</b>[服务器安全]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:
PHP 5.3.1
MySQL 5.0.89
Nginx 0.8.33 或 0.7.65 (可选)
目前,我们可以快速全自动搞定 CentOS + Nginx + PHP-FPM + MySQL 的安装了
这个可比网上传播的什么一键安装包要好得多,激烈举荐此法安装,合适全部菜鸟和高手我服务器上全用的源代码编译安装,也好不到哪去,还很吃力
我这个装完已经包含 php 的一些常用扩大, PDO,eaccelerator,memcache,tidy等等
先新建一个 repo
# vi /etc/yum.repos.d/centos.idcfree.com.repo
放入以下内容
[idcfree.com]
name=idcfree.com Packages for Enterprise Linux 5 - $basearch
baseurl=http://www.idcfree.com/centos/5/$basearch/
enabled=1
gpgcheck=0
protect=1
启用 EPEL repo
i386
rpm -ihv http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
x86_64
rpm -ihv http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
接着导入key
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
好了,一键安装
# yum install nginx php-fpm mysql-server
爽吧!
假如 nginx 你要用 0.7.65 最新安定版,把
yum -y install nginx
换成
yum -y install nginx-stable
便可以了
更完好的安装
yum -y update
yum -y mysql-server
service mysqld start
mysqladmin -u root password root
service mysqld stop
yum -y install nginx php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator
# APC 和 eAccelerator 有冲突,2选1
yum -y install php-pecl-apc看下我的完好安装,只要一句
yum -y install nginx mysql-server php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator
安装后果,全自动
Dependencies Resolved
==========================================================
Package Arch Version Repository Size
==========================================================
Installing:
mysql x86_64 5.0.89-1.el5 idcfree.com 3.5 M
mysql-server x86_64 5.0.89-1.el5 idcfree.com 10 M
nginx x86_64 0.8.33-3.el5 idcfree.com 422 k
php-cli x86_64 5.3.1-2.el5 idcfree.com 2.4 M
php-eaccelerator x86_64 2:0.9.6-1.el5 idcfree.com 118 k
php-fpm x86_64 5.3.1-2.el5 idcfree.com 1.2 M
php-gd x86_64 5.3.1-2.el5 idcfree.com 110 k
php-mbstring x86_64 5.3.1-2.el5 idcfree.com 1.1 M
php-mcrypt x86_64 5.3.1-2.el5 idcfree.com 27 k
php-mysql x86_64 5.3.1-2.el5 idcfree.com 84 k
php-pdo x86_64 5.3.1-2.el5 idcfree.com 91 k
php-pear noarch 1:1.9.0-1.el5 idcfree.com 420 k
php-pecl-memcache x86_64 2.2.5-3.el5 idcfree.com 44 k
php-tidy x86_64 5.3.1-2.el5 idcfree.com 31 k
php-xml x86_64 5.3.1-2.el5 idcfree.com 115 k
php-xmlrpc x86_64 5.3.1-2.el5 idcfree.com 48 k
Installing for dependencies:
gmp x86_64 4.1.4-10.el5 base 201 k
libXaw x86_64 1.0.2-8.1 base 329 k
libXmu x86_64 1.0.2-5 base 63 k
libXpm x86_64 3.5.5-3 base 44 k
libedit x86_64 2.11-2.20080712cvs.el5 epel 80 k
libmcrypt x86_64 2.5.8-4.el5.centos extras 105 k
libtidy x86_64 0.99.0-14.20070615.el5 epel 140 k
php-common x86_64 5.3.1-2.el5 idcfree.com 554 k
sqlite2 x86_64 2.8.17-5.el5 idcfree.com 165 k
t1lib x86_64 5.1.1-7.el5 epel 208 k
Updating for dependencies:
libevent x86_64 1.4.12-1.el5 idcfree.com 129 k
Transaction Summary
==========================================================
Install 26 Package(s)
Update 1 Package(s)
Remove 0 Package(s)
最后只要 yum -y update 一下,满是最新的
别忘了开机启动
chkconfig --level 345 mysqld on
chkconfig --level 345 php-fpm on
chkconfig --level 345 nginx on
增补:全部的配置文件都在 /etc 目录下,包含 nginx, php-fpm, mysql 的配置文件,请自行查找设置,以下为我的 nginx 的配置典范
先新建一个 /www 目录,网站和日记也全放在这里
别忘了建日记存放目录,你在配置文件中 access_log 用到的 /www/logs
注意:fastcgi_params 要加入这一行
# vim /etc/nginx/fastcgi_params
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
# vi /etc/nginx/nginx.conf
user nobody nobody;
worker_processes 8; #这里按照你的CPU和内存配置, 设置2到10都OK
error_log /www/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid;
#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;
events {
use epoll;
worker_connections 51200;
}
http {
include mime.types;
default_type application/octet-stream;
#charse gb2312; # 默许编码,可以不设置
server_names_hash_bucket_size 128;
client_header_buffer_size 16k;
large_client_header_buffers 4 16k;
client_max_body_size 8m;
sendfile on;
tcp_nopush on;
keepalive_timeout 60;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
以上是“<b>CentOS + Nginx + PHP-FPM + MySQL快速完善安装教程</b>[服务器安全]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
本文地址: | 与您的QQ/BBS好友分享! |