centos7.6快速搭建lamp环境调试过程
最小化安装系统后先更新
[root@Server ~]# yum update -y
[root@Server ~]# cat /etc/redhat-release CentOS Linux release 7.6.1810 (Core)
[root@Server ~]# uname -r 3.10.0-957.10.1.el7.x86_64
关闭防火墙 systemctl stop firewalld.service
关闭防火墙开机启动 systemctl disable firewalld.service
关闭SELINUX (重启生效) sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
1.安装AMP [root@Server ~]# yum install -y httpd mariadb-server php php-mysql
2.启动服务及加入开机自启 [root@Server ~]# systemctl start httpd.service;systemctl start mariadb.service;systemctl enable httpd.service;systemctl enable mariadb.service
3.设置mysql root密码 [root@Server ~]# mysql_secure_installation 依次会有以下提示: 提示输入密码,没有密码就直接回车(新安装的默认没有密码) 提示设置root user密码 Y 设置好密码 生产环境建议删除系统创建的匿名用户 Y 禁止root用户远程登录 Y 删除test数据库 Y 重载权限表 Y 完成
4.验证mysql (可选操作)
[root@Server html]# mysql -u root -p
输入你设置的root密码
MariaDB [(none)]> show databases;
MariaDB [(none)]> select user,host from mysql.user;
MariaDB [(none)]> exit;
5.创建info.php 并测试 (可选操作) 访问 http://你的IP 如果出现testing 123.. 页面 表示apche安装正确
echo '<?php phpinfo();?>' >>/var/www/html/info.php 访问 http://你的ip/info.php 如出现php信息页面 表示php安装正确
6.将网站源码放在 /var/www/html/ 下 即可 (PHP扩展模块可按需自行安装)
至此LAMP环境搭建完成
附:安装samba 将网站目录共享 方便上传源码
[root@Server ~]# yum install -y samba
编辑smb.conf 在配置文件最下面 新增共享网站目录 [root@Server ~]vi /etc/samba/smb.conf [myshare] comment = myshare path = /var/www/html writable = yes 保存退出
创建samba的root用户密码: touch /etc/samba/smbpasswd smbpasswd -a root
重启SMB服务并加入开机自启 [root@Server ~]# systemctl restart smb; systemctl enable smb
windows电脑访问验证 开始--运行 输入 \ip 输入密码即可访问