杜坤福博客

Hi, 请登录

centos7无网络下安装部署lamp环境


1、 先ping www.baidu.com,root账户下,如果未联网,创建目录,把提前下载好的rpm包拷贝到rpm目录下如图:(如果没有安装包请查看我的另一篇教程下载这些安装包)

mkdir /data/rpm -p

image.png

2、 进入该目录

cd /data/rpm

3、 安装该目录下所有.rpm后缀的安装包

yum localinstall *.rpm -y

4、 安装完后开始启动服务

(1)安装好后将php-fpm设置为开机启动

systemctl enable php-fpm.service

(2)启动php 的服务

systemctl start php-fpm  #启动


下面是php启动关闭重启命令,这里执行启动:

systemctl start php-fpm  #启动
systemctl stop php-fpm  #关闭
systemctl restart php-fpm   #重启

(3)apache启动服务

systemctl start httpd.service

(4)apache开机自启

systemctl enable httpd.service

下面是apache的启动停止重启命令


# 启动apache
 systemctl start httpd.service
# 停止apache
 systemctl stop httpd.service 
# 重启apache
 systemctl restart httpd.service


(5)启动 MySQL 服务

systemctl start mysqld.service

(6) 开机启动 MySQL 服务

systemctl enable mysqld

5、 修改 MySQL 配置文件

vim /etc/my.cnf

进入如图界面后用i编辑,修改默认编码为 UTF-8,添加在 [mysqld] 后


character_set_server = utf8
init_connect = 'SET NAMES utf8'

然后按Esc推出并输入

:wq!

保存退出。

如图:

image.png

退出后如图:

image.png

重新加载服务

systemctl daemon-reload

6、 搜索 MySQL 的 root 用户密码,systemctl start mysqld.service启动后会在 /var/log/mysqld.log 中给 root 生成密码,查看密码:

grep 'temporary password' /var/log/mysqld.log

查看密码后使用 root 用户登录

mysql -uroot -p

如图;

image.png

7、 修改 MySQL 的 root 用户密码

set password for 'root'@'localhost' = password('新密码');


8、 注意使用mysql数据库,配置这一步

use mysql;

查看表

show tables;

修改表

update user set user.Host = '%' where user.User = 'root';

查看修改结果

select user.Host,user.User from user;

退出

quit;

9、 现在我们要查看一下防火墙的状态

systemctl list-unit-files|grep firewalld.service

10、 如果处于enabled状态,关闭防火墙:

systemctl stop firewalld.service

11、 禁止防火墙开机自启:

systemctl disable firewalld.service

12、 配置SELinux:

 vim /etc/selinux/config

按i进行编辑,把找到SELINUX=enforcing将它改为

SELINUX=disabled

然后按Esc再按:再输入

:wq!

保存退出,退出后一定执行

reboot

命令重启,否则会影响访问!

13、 我们还有最后一步,配置httpd.conf,先找到他的位置:

whereis httpd.conf

如图

image.png

这个/etc/httpd就是该文件存放的目录,我们进入该目录:

cd /etc/httpd

然后查看

ll

我们就能看到这个文件夹里的文件,如图:我们cd到conf这个文件夹

cd conf


14、 最终到conf文件夹里编辑我们要编辑的httpd.conf文件ll

执行

vim httpd.conf


修改相应配置

关于httpd.conf我是直接用已经配置好的httpd.conf文件传输到该目录系下替换原来的配置

15、 修改完httpd.conf文件后记得重启该服务


16、 然后把php的源码压缩包放入,ll查看一下该目录的权限


这里html目录的权限是root,我们把权限更改为apache权限

chown -R apache:apache html(项目文件夹名称)


17、 重启服务

systemctl restart httpd.service


18、 解压该目录的压缩包,注意解压后查看项目是否在html根目录下

tar -xvf 名称.tar




相关推荐

评论

  • 昵称 (必填)
  • 邮箱
  • 网址
二维码
评论