在CentOS中快速安装PHP,MySQL,Nginx和phpMyAdmin

前端之家收集整理的这篇文章主要介绍了在CentOS中快速安装PHP,MySQL,Nginx和phpMyAdmin前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
安装环境
yum install -y autoconf automake gcc gcc-c++ git libtool make nasm pkgconfig zlib-devel

安装PHP

yum install -y PHP PHP-fpm PHP-MysqL  PHP-devel PHP-mbstring PHP-gd

启动PHP-fpm

service PHP-fpm start

PHP-fpm加入启动项

chkconfig --levels 2345 PHP-fpm on

查看

chkconfig --list | grep PHP-fpm

安装MysqL

  • yum安装
yum install -y MysqL-server MysqL MysqL-devel

开启MysqL Server daemon (MysqLd)

service MysqLd start

用root帐号登录MysqL Server

MysqL -u root

修改 root 帐号的密码: (注: 这一步完成之后,下次使用MysqL -p -u root登录)

MysqL> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('password');

删除除root外的其它用户

select user,host from MysqL.user;
delete from MysqL.user where not (user="root");
MysqL> FLUSH PRIVILEGES;
select user,host from MysqL.user;

MysqL> quit;

设置MysqLd开机启动

chkconfig --level 2345 MysqLd on && service MysqLd restart && chkconfig --list | grep MysqLd

======================================================

Centos7中用MariaDB代替了MysqL数据库

CentOS 7的yum源中貌似没有正常安装MysqL时的MysqL-sever文件,需要去官网上下载

# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# rpm -ivh MysqL-community-release-el7-5.noarch.rpm
# yum install MysqL-community-server
附:
  
  
rpm-e需要卸载的安装包

在卸载之前,通常需要使用rpm-q…命令查出需要卸载的安装包名称


ruby-1.8.7.352-7.el6_2.x86_64isaduplicatewithruby-1.8.7-1.el6.x86_64
yum erase ruby

成功安装之后重启MysqL服务

# service MysqLd restart

如果仍不能下载,把原来的yum源里自定义的源删除

=====================================

安装web服务器Nginx

下载链接http://pan.baidu.com/s/1sjqknO5密码:7q59

yum install -y pcre-devel zlib-devel
tar -zxf Nginx-1.5.3.tar.gz
cd Nginx-1.5.3
./configure --prefix=/opt/Nginx
make && make install

查看配置信息是否正确(可以一起复制)

cd /opt/Nginx/sbin/
./Nginx -t

启动Nginx

/opt/Nginx/sbin/Nginx

开机启动

echo /opt/Nginx/sbin/Nginx >> /etc/rc.local

开放80端口

/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/etc/init.d/iptables save
service iptables restart

或直接关闭防火墙(可选)

service iptables stop 

开机关闭防火墙(可选)

chkconfig --level 0123456 iptables off


配置Nginx

vim /opt/Nginx/conf/Nginx.conf

安装vim

yum install -y vim

去掉注释并修改脚本路径为/opt/Nginx/html

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#
   location ~ \.PHP$ {
         root           html;
         fastcgi_pass   127.0.0.1:9000;
         fastcgi_index  index.PHP;
         fastcgi_param  SCRIPT_FILENAME  /opt/Nginx/html$fastcgi_script_name;
         include        fastcgi_params;
   }

重新加载

cd /opt/Nginx/sbin
./Nginx -s reload
service PHP-fpm restart

启停Nginx的脚本

参见: 编写Nginx启停服务脚本
之后就可以 service Nginx restart重启了

安装PHPmyadmin

链接http://pan.baidu.com/s/1i3pKD3f密码:et1z

tar -jxf PHPMyAdmin-4.0.6-all-languages.tar.bz2
mv PHPMyAdmin-4.0.6-all-languages PHPmyadmin
mv PHPmyadmin/ /opt/Nginx/html/
cd /opt/Nginx/html/PHPmyadmin/
cp config.sample.inc.PHP config.inc.PHP

修改用户名和密码

vim  config.inc.PHP

修改下面2行:

$cfg['Servers'][$i]['controluser'] = 'root';// MysqL用户
$cfg['Servers'][$i]['controlpass'] = 'password'; // MysqL用户密码

重新加载

cd /opt/Nginx/sbin
./Nginx -s reload
service PHP-fpm restart

问题:
Call to undefined function PMA_DBI_num_rows() in /opt/Nginx/html/PHPmyadmin/libraries/navigation/Nodes/Node.class.PHP

   
   
yuminstallPHP-MysqL
原文链接:https://www.f2er.com/centos/380922.html

猜你在找的CentOS相关文章