当前位置: > CentOS > CentOS服务器 > 环境配置 >

Centos6 yum搭建Linux+Nginx+PHP+MYSQL

时间:2016-07-14 14:29来源:linux.it.net.cn 作者:IT

如下操作配置Nginx1.0.10+PHP5.3.8(fastcgi)+Mysql5.5.17

使用Nginx官方源,Epel扩展库和remi源,remi源基于epel,必须先安装epel源,remi包含php-fpm,mysql-server5.5,如果只需要php-fpm可以单独安装php-fpm后禁用此源.
安装Nginx源:

rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

安装EPEL源:

(64位系统) rpm -ivh http://download.fedora.redhat.com/pub/epel/6/x86_64/epel-release-6-5.noarch.rpm
(32位系统) rpm -ivh http://download.fedora.redhat.com/pub/epel/6/i386/epel-release-6-5.noarch.rpm

安装REMI源:

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

开启REMI,编辑 /etc/yum.repos.d/remi.repo

vi /etc/yum.repos.d/remi.repo
修改 enable=1
esc
:wq
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

1.根据需求配置 nginx配置文件 (本博文不提供具体配置)
2.修改/etc/php-fpm.conf 用户组为nginx
3.修改/var/lib/php/session(使php能保存session),web用户组为nginx

chown -R nginx:nginx /var/lib/php/session(不存在则需要创建)
chown -R nginx:nginx /var/www/(web目录)
chmod -R 775 /var/www/ (同组可修改权限,方便配置ftp,ftp应该加入到nginx组,如果需要更高的安全设置,则不应当将只读的目录赋予nginx,php组可写权限)
service nginx start(start|stop|restart|reload)
service php-fpm start(start|stop|restart)
service mysqld start(start|stop|restart|reload)
设置自启动
chkconfig nginx on
chkconfig php-fpm on
chkconfig mysqld on



 

(责任编辑:IT)
------分隔线----------------------------