91Linux - uvh
type: channel
link: https://91linux.org/tag/uvh/
items: centos使用yum安装lamp环境

centos使用yum安装lamp环境
type: item
date: 2020-04-13T11:58:00+08:00
description: yum安装方便，快捷，能够快速解决包依赖的问题，但是没有源码安装的配置过程可以进行自定义参数设定，总而言之yum还是比较适合新手的。本篇文章lamp使用：centos，httpd，mysql5.5，php5一、Linux我们选择centos，目前centos6和centos7还是用的比较多的。二、apache安装：yum install -y httpd httpd-devel三、mysql5.5安装：默认使用安装的mysql不是5.5版本的，我们需要增加两个新的repocentos6： rpm -Uvh http://mirror.steadfast.net/epel/6/i386/epel-release-6-8.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpmcentos7： rpm -Uvh http://mirror.steadfast.net/epel/7/x86_64/e/epel-release-7-9.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm查看一下是不是有mysql 5.5了yum --enablerepo=remi,remi-test list mysql mysql-server安装mysql5.5yum --enablerepo=remi,remi-test install mysql mysql-server启动mysql5.5centos6: /etc/init.d/mysqld startcentos7: systemctl start mysqld设置开机启动centos6: chkconfig --levels 345 mysqld oncentos7: systemctl enable mysqld修改一下mysql的root用户密码mysqladmin -u root password [your_password_here]为指定数据库，指定用户配置指定客户端（IP）远程访问本示例的配置参数如下DB_NAME = testdb USER_NAME = testdb_user REMOTE_IP = 10.0.15.1 PASSWORD = password001 PERMISSIONS = ALL 创建数据库 webdbmysql> CREATE DATABASE testdb;创建用户webdb_usermysql> CREATE USER 'testdb_user'@'10.0.15.1' IDENTIFIED BY 'password001';授权mysql> GRANT ALL ON testdb.* TO testdb_user@'10.0.15.1';重载权限表mysql> FLUSH PRIVILEGES;centos6配置防火墙开启3306端口：vi /etc/sysconfig/iptables 在COMMIT之前加入以下内容:-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT 重启Iptables:service iptables restartcentos7配置防火墙开启3306端口：firewall-cmd --add-port=3306/tcp --permanent firewall-cmd --reload 在客户机上测试远程访问数据库:mysql -h dbserver_name_or_ip_address -u webdb_user -p webdb 四、php5安装默认安装的版本太低了，所以用以下办法来安装1.检查当前安装的PHP包yum list installed | grep php如果有安装的PHP包，先删除他们yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64 2.Centos 5.X rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpmCentOs 6.x rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpmCentOs 7.X rpm -Uvh https://mirr…