快速部署LAMP架构

快速部署LAMP架构

部署linux系统环境

注意关闭防火墙、selinux

[root@localhost ~]# iptables -F
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

[root@localhost ~]#vim /etc/selinux/config
 SELINUX=disabled
[root@localhost ~]#reboot
[root@localhost ~]# getenforce 
Disabled

部署apache

安装apache
[root@localhost ~]# yum install httpd -y

启动apache
[root@localhost ~]# systemctl start httpd
[root@localhost ~]# netstat -tunlp|grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      1269/httpd     

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-kqxhl8lI-1669648798113)(E:\360MoveData\Users\zhangsong\Desktop\猿来\apache.png)]

部署 mysql

#yum 安装部署
安装
[root@localhost ~]yum install mariadb-server mariadb -y

启动
[root@localhost ~]# systemctl start mariadb
[root@localhost ~]# netstat -tunlp|grep "mysql"
tcp        0      0 0.0.0.0:3306            0.0.0.0:*               LISTEN      1571/mysqld  

[root@localhost ~]# mysql -uroot -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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
+--------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| host                      |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
24 rows in set (0.00 sec)

MariaDB [mysql]> select user,password,host from user;
+------+----------+-----------------------+
| user | password | host                  |
+------+----------+-----------------------+
| root |          | localhost             |
| root |          | localhost.localdomain |
| root |          | 127.0.0.1             |
| root |          | ::1                   |
|      |          | localhost             |
|      |          | localhost.localdomain |
+------+----------+-----------------------+
6 rows in set (0.00 sec)


部署 PHP

1、解决 php 安装的依赖

[root@localhost ~]# yum -y install zlib-devel libxml2-devel libjpeg-devel libjpeg-turbo-devel libiconv-devel freetype-devel libpng-devel gd-devel libcurl-devel linxslt-devel libtool-ltdl-devel pcre pcre-devel apr apr-devel zlib-devel gcc make 


2、安装 php ,以及php连接mysql数据库的驱动

[root@localhost ~]# yum install php php-fpm php-mysql -y


3、php不需要额外修改,但是需要修改apache配置文件,支持php
#php程序和apache结合工作


4、编辑apache配置文件

[root@localhost ~]# vim /etc/httpd/conf/httpd.conf 

5、进行配置文件修改
[root@localhost ~]# vim /etc/httpd/conf/httpd.conf
显示行号  :set nu
DocumentRoot "/var/www/html"
120  TypesConfig /etc/mime.types
121  AddType application/x-httpd-php .php
122  AddType application/x-httpd-php-source .phps
123  DirectoryIndex index.php index.html

6、编写一个php脚本
#脚本需要放在如下位置

[root@localhost ~]# vim /var/www/html/index.php

我的新首页,你好兄弟们


[root@localhost ~]# systemctl restart httpd

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-khjiCjpS-1669648798121)(E:\360MoveData\Users\zhangsong\Desktop\猿来\php.png)]

看到phpinfo()页面,表示 linux + apache + mysql + php 搭建好了

就可以在此环境是运行其他代码

部署一个论坛

部署一个论坛 disuz

[root@localhost ~]# wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_UTF8.zip

#解压缩
[root@localhost ~]# yum -y install unzip
[root@localhost ~]# unzip Discuz_X3.2_SC_UTF8.zip

[root@localhost ~]# mv Discuz_X3.2_SC_UTF8.zip readme upload utility /home/
[root@localhost ~ ]# cd /home/

拷贝
[root@localhost home]# cp -r upload/* /var/www/html/
cp:是否覆盖"/var/www/html/index.php"? y


权限
[root@localhost home]# chmod 777 /var/www/html/*
修改权限
[root@localhost home]# chmod -R 777 /var/www/html/*


快速部署LAMP架构_第1张图片

快速部署LAMP架构_第2张图片

快速部署LAMP架构_第3张图片

快速部署LAMP架构_第4张图片
快速部署LAMP架构_第5张图片
快速部署LAMP架构_第6张图片

MariaDB [(none)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| test               |
| ultrax             |
+--------------------+
5 rows in set (0.00 sec)

MariaDB [(none)]> use ultrax;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [ultrax]> show tables;

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-pwPAXIY8-1669648798135)(E:\360MoveData\Users\zhangsong\Desktop\猿来\8.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-EI17UYSY-1669648798136)(E:\360MoveData\Users\zhangsong\Desktop\猿来\7.png)]

[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-bmu6bj4B-1669648798138)(E:\360MoveData\Users\zhangsong\Desktop\猿来\8.png)]

this feature to get a quicker startup with -A

Database changed
MariaDB [ultrax]> show tables;


![在这里插入图片描述](https://img-blog.csdnimg.cn/d8aa9f496f7a40c38ccbb24979bcc15c.png#pic_center)


![在这里插入图片描述](https://img-blog.csdnimg.cn/afec30b68d0b4866a2b9cca55c5d509e.png#pic_center)

![在这里插入图片描述](https://img-blog.csdnimg.cn/71ce5e03ad5b40d5883f8a45b924d048.png#pic_center)


你可能感兴趣的:(架构,mysql,apache)