当前位置: 首页 > 后端技术 > PHP

CentOS6.5下使用yum搭建LNMP环境

时间:2023-03-29 16:46:16 PHP

1.安装php71。更新yum源(yum源默认php版本为5.3.3)#rpm-Uvhhttp://mirror.webtatic.com/yum/el6/latest.rpm2.安装php7和常用扩展模块#yum-yinstallphp70wphp70w-mysqlphp70w-mbstringphp70w-mcryptphp70w-gdphp70w-imapphp70w-ldapphp70w-odbcphp70w-pearphp70w-xmlphp70w-xmlrpcphp70w-pdophp70w-fpmphp70w-devel模块可以使用命令yum-yinstallphp70w-xxx3.测试是否安装成功#??php-v4.配置php.ini文件,在末尾添加cgi.fix_pathinfo=1#vim/etc/php.ini2、安装mysql5.51。卸载5.1版本的mysql-libs#rpm-qa|grepmysql#rpm-emysql-libs--nodeps2.添加新源#rpm-Uvhhttp://mirror.steadfast.net/epel/6/i386/epel-release-6-8.noarch.rpm#rpm-Uvhhttp://rpms.famillecollet.com/enterprise/remi-release-6.rpm3.install#yum-y--enablerepo=remi,remi-test安装mysqlmysql-server4。启动#servicemysqldstart5。设置bootstart#chkconfig--levels345mysqldon6。修改默认密码#mysqlmysql>selectuser,host,passwordfrommysql.user;mysql>dropuser''@localhost;mysql>updatemysql.usersetpassword=PASSWORD('newpassword')whereuser='root';mysql>flushprivileges;mysql>exit3.安装nginx1。安装#yuminstallnginx2。配置conf文件#vim/etc/nginx/conf.d/default.conf杀死以下行listen[::]:80default_server;并添加fastcgi支持索引index.phpindex.htmlindex.htm;位置~\.php${root/usr/share/nginx/html;fastcgi_pass127.0.0.1:9000;fastcgi_indexindex.php;fastcgi_paramSCRIPT_FILENAME/usr/share/nginx/html$fastcgi_script_name;包括fastcgi_params;}3.设置启动#chkconfig--levels345nginxon4.启动nginx和php-fpm#servicenginxstart#servicephp-fpmstart4.测试#vim/usr/share/nginx/html/phpinfo.php