LAMP环境和软件版本

名称 版本号 查询命令
linux系统 CentOS Linux release 7.7.1908 (Core) cat /etc/redhat-release
Apache httpd-2.4.6-90.el7.centos.x86_64 rpm -qa | grep httpd
mariadb mariadb-server-5.5.64-1.el7.x86_64 rpm -qa | grep mariadb
php php-5.4.16-46.el7.x86_64 rpm -qa | grep php

一、安装Apache

1、查看是否安装过Apache。
# rpm -qa | grep httpd

2、有就卸载httpd。
# yum remove -y httpd*

3、重新安装httpd。
# yum install -y httpd

4、查看启动状态。
# systemctl status httpd

5、启动httpd。
# systemctl start httpd

6、添加开机启动。
# systemctl enable httpd

7、设置防火墙开放tcp80端口。
# firewall-cmd --zone=public --add-port=80/tcp --permanent
# firewall-cmd --reload
# firewall-cmd --query-port=80/tcp

8、使用浏览器访问http://192.168.1.150/,显示如下界面,说明安装的Apache HTTP服务正常运行。
Linux安装LAMP(centos7)

二、安装mysql数据库

1、查看是否安装过mariadb。
# rpm -qa | grep mariadb

2、有就卸载mariadb。
# yum remove -y mariadb*

3、重新安装mariadb-server。
# yum install -y mariadb-server

4、启动mariadb。
# systemctl start mariadb.service

5、查看启动状态。
# systemctl status mariadb

6、添加开机启动。
# systemctl enable mariadb

7、设置mysql数据库root账号密码。
# mysqladmin -uroot password ‘yourpassword’

# mysql_secure_installation
Linux安装LAMP(centos7)

8、root账号登陆mysql。
# mysql -uroot -p

9、登陆mysql后可以使用如下命令重新设置当前账户数据库密码。
MariaDB[(none)]> set password=password(‘123456’)

10、创建一个新用户newuser,密码为123456,授权远程计算机使用账号newuser登陆数据库,并立刻刷新权限。
MariaDB[(none)]> grant all on *.* to ‘newuser’ @’%’ identified by ‘123456’ ;
MariaDB[(none)]> flush privileges;
上述语句表示使用"newuser"账户,"123456“”密码从任何主机连接到mysql服务器,并赋予所有的权限。

11、退出mysql数据库。
MariaDB[(none)]> quit;

MariaDB[(none)]> exit;

12、设置防火墙开放tcp3306端口。
# firewall-cmd --zone=public --add-port=3306/tcp --permanent
# firewall-cmd --reload
# firewall-cmd --query-port=3306/tcp
Linux安装LAMP(centos7)

13、远程计算机连接服务器数据库时使用如下命令,输入密码即可登录mysql数据库。
# mysql -unewuser -p -h 192.168.1.150 -P 3306

三、安装PHP

1、查看是否安装过php。
# rpm -qa | grep php

2、有就卸载php。
# yum remove -y php*

3、重新安装php。
# yum install -y php

4、创建文件/var/www/html/index.php,写入内容 “<?php phpinfo(); ?>” 。使用浏览器访问http://192.168.1.150/index.php,如果显示如下图,则说明php安装成功。
# touch /var/www/html/index.php
# echo “<?php phpinfo(); ?>” > /var/www/html/index.php

5、重启apache服务,使用浏览器访问http://192.168.1.150/index.php,如果显示如下图,则说明php安装成功。
# systemctl restart httpd

Linux安装LAMP(centos7)

相关文章:

  • 2021-08-22
  • 2021-11-30
  • 2018-01-07
  • 2022-12-23
  • 2022-12-23
  • 2021-05-16
  • 2021-12-04
  • 2021-12-03
猜你喜欢
  • 2021-09-30
  • 2021-11-20
  • 2021-05-21
  • 2021-11-30
  • 2021-09-30
相关资源
相似解决方案