LAMP部署手册

LAMP部署

LAMP架构是在Linux系统上部署Apache、MySQL、PHP。

LINUX系统准备

yum源仓库搭建,使用阿里云源搭建yum仓库

[root@localhost ~]# uname -a 
Linux localhost.localdomain 3.10.0-862.el7.x86_64 #1 SMP Fri Apr 20 16:44:24 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@localhost ~]# 

## yum源搭建
[root@localhost yum.repos.d]#cd /etc/yum.repos.d/
[root@localhost yum.repos.d]#yum -y install wget  #安装wget工具
[root@localhost yum.repos.d]#mkdir repo.bak
[root@localhost yum.repos.d]#mv *.repo repo.bak
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo
[root@localhost yum.repos.d]# ls 
CentOS-Base.repo  repo.bak 
[root@localhost yum.repos.d]# yum clean all  #清除缓存
[root@localhost ~]# yum makecache 	#重建缓存

apache部署

apache部署的两种方式

  • 源码包编译安装
  • yum仓库安装
## 源码安装1
# 下载源码包
 wget https://mirrors.aliyun.com/apache/httpd/httpd-2.4.54.tar.gz
 wget https://mirrors.aliyun.com/apache/apr/apr-1.7.0.tar.gz
 wget https://mirrors.aliyun.com/apache/apr/apr-util-1.6.1.tar.gz
## 下载依赖包
 yum -y install gcc-c++
 tar -zxvf httpd-2.4.54.tar.gz 
 cd httpd-2.4.54/ 
 ./configure --prefix=/usr/local/apache --with-mpm=worker  --enable-so --enable-rewrite --enable-headers --disable-status  #编译
 make && make install #安装
 # 编辑配置文件
 vim /usr/local/apache/conf/httpd.conf
 #ServerName www.example.com:80
 ServerName localhost:80
 # 启动
 /usr/local/apache/bin/apachectl start
 
## yum安装apache--httpd服务
[root@localhost ~]# yum search httpd 
[root@localhost ~]# yum -y install httpd 

# 启动httpd服务
[root@localhost ~]# systemctl status httpd 
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; disabled; vendor preset: disabled)
   Active: inactive (dead)
     Docs: man:httpd(8)
           man:apachectl(8)
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# ps -ef | grep httpd 
root       2696      1  0 10:55 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     2697   2696  0 10:55 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     2698   2696  0 10:55 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     2699   2696  0 10:55 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     2700   2696  0 10:55 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
apache     2701   2696  0 10:55 ?        00:00:00 /usr/sbin/httpd -DFOREGROUND
root       2703   2374  0 10:55 pts/0    00:00:00 grep --color=auto httpd
[root@localhost ~]# netstat -tunlp | grep httpd 
tcp6       0      0 :::80                   :::*                    LISTEN      2696/httpd          
[root@localhost ~]# 

#验证httpd服务
[root@localhost ~]# curl localhost:80

在这里插入图片描述

mysql部署

使用yum仓库搭建mysql数据库,使用mariadb。

## 使用yum安装
[root@localhost ~]# yum search mariadb mariadb-server
[root@localhost ~]# yum -y install mariadb 
[root@localhost ~]# systemctl start mariadb

#mysql测试
[root@localhost ~]# mysql -u root -p 
Enter password:   #无密码,直接回车即可
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.68-MariaDB MariaDB Server

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]> 
MariaDB [(none)]> update mysql.user set password=PASSWORD('123456') where user='root';  #设置密码
Query OK, 0 rows affected (0.00 sec)
Rows matched: 4  Changed: 0  Warnings: 0

MariaDB [(none)]> flush privileges;  #刷新修改
Query OK, 0 rows affected (0.00 sec)

安装PHP

使用yum仓库安装php。

[root@localhost ~]# yum search php 
[root@localhost ~]# yum -y install php
[root@localhost ~]# cd /var/www/html/  #apache站点目录
[root@localhost html]# more phpinfo.php 
<?php
phpinfo();
?>
[root@localhost html]# 

在这里插入图片描述

搭建discuz论坛网站

利用LAMP架构搭建discuz论坛网站

# 将discuz论坛网站上传
[c:\~]$ sftp root@192.168.44.152


Connecting to 192.168.44.152:22...
Connection established.
To escape to local shell, press 'Ctrl+Alt+]'.

Your current local directory is
C:\Users\chengdb\Documents\NetSarang\Xshell\Sessions

Type `help' to browse available commnands.
sftp:/root> 
Uploading Discuz_X3.4_SC_UTF8_20221220.zip to remote:/root/Discuz_X3.4_SC_UTF8_20221220.zip

# 关闭selinux
[root@localhost ~]# vim /etc/selinux/config 
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected. 
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

#关闭后reboot

# 解压缩discuz

[root@localhost ~]# cp Discuz_X3.4_SC_UTF8_20221220.zip /var/www/html/
[root@localhost ~]# unzip Discuz_X3.4_SC_UTF8_20221220.zip
[root@localhost ~]# chown -R apache:apache /var/www/html/

# 若提示mysql_connector()不可用
[root@localhost ~]# yum -y install php-mysql

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值