运维黄金架构LAMP(一)----LAMP的部署

运维黄金架构LAMP(一)----LAMP的部署

  1. 环境准备
# 清除防火墙协议并关闭
[root@LAMP ~]# iptables -F
[root@LAMP ~]# systemctl stop firewalld
[root@LAMP ~]# systemctl disable firewalld

[root@LAMP ~]# getenforce
Disabled

# 卸载nginx程序
[root@LAMP ~]# yum remove nginx -y

# 安装apache程序
[root@LAMP ~]# yum install httpd -y
Last metadata expiration check: 0:00:50 ago on Wed 10 Aug 2022 09:40:17 PM CST.
# 启动apache
[root@LAMP ~]# systemctl start httpd  
[root@LAMP ~]# netstat -tunlp|grep httpd
tcp6       0      0 :::80                   :::*                    LISTEN      37234/httpd       
  1. 部署mysql
# yum安装mariadb
[root@LAMP ~]# yum install mariadb-server mariadb -y
Last metadata expiration check: 0:03:40 ago on Wed 10 Aug 2022 09:40:17 PM CST.
Dependencies resolved.

# 启动mariadb
[root@LAMP ~]# systemctl start mariadb
[root@LAMP ~]# netstat -tunlp | grep "mysql"
tcp6       0      0 :::3306                 :::*                    LISTEN      27594/mysqld 

# 使用mariadb(默认没有密码)
[root@LAMP Discuz]# mysql -uroot -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 10.3.28-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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
+--------------------+
3 rows in set (0.000 sec)

# 查看mysql数据库下的user表
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]> select user,password,host from user;
+------+----------+-----------+
| user | password | host      |
+------+----------+-----------+
| root |          | localhost |
| root |          | lamp      |
| root |          | 127.0.0.1 |
| root |          | ::1       |
+------+----------+-----------+
4 rows in set (0.000 sec)

MariaDB [mysql]> exit
Bye
  1. 部署php
# 1.安装php所需依赖
[root@LAMP ~]# yum install libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel
Last metadata expiration check: 0:16:15 ago on Wed 10 Aug 2022 09:40:17 PM CST.

# 2.使用yum进行安装
[root@LAMP ~]# yum install php php-devel
Last metadata expiration check: 0:13:48 ago on Wed 10 Aug 2022 09:40:17 PM CST.
Dependencies resolved.

# 3.查看是否安装成功
[root@LAMP ~]# php -v
PHP 7.2.24 (cli) (built: Oct 22 2019 08:28:36) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies

# 4.安装mysql扩展,用于连接数据库
[root@LAMP ~]# yum install php-mysqlnd
Last metadata expiration check: 0:14:12 ago on Wed 10 Aug 2022 09:40:17 PM CST.
Dependencies resolved.

# 5.启动服务
[root@LAMP ~]# systemctl start php-fpm.service

# 6.查看服务
[root@LAMP ~]# systemctl status php-fpm.service
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; disabled; vendor preset: disabled)
   Active: active (running) since Wed 2022-08-10 21:54:43 CST; 4s ago
 Main PID: 37129 (php-fpm)
   Status: "Ready to handle connections"
    Tasks: 6 (limit: 24896)
   Memory: 9.4M
   CGroup: /system.slice/php-fpm.service
           ├─37129 php-fpm: master process (/etc/php-fpm.conf)
           ├─37130 php-fpm: pool www
           ├─37131 php-fpm: pool www
           ├─37132 php-fpm: pool www
           ├─37133 php-fpm: pool www
           └─37134 php-fpm: pool www

Aug 10 21:54:43 LAMP systemd[1]: Starting The PHP FastCGI Process Manager...
Aug 10 21:54:43 LAMP systemd[1]: Started The PHP FastCGI Process Manager.

# 7.将服务设置为开机启动
[root@LAMP ~]# systemctl enable php-fpm.service
Created symlink /etc/systemd/system/multi-user.target.wants/php-fpm.service → /usr/lib/systemd/system/php-fpm.service.
  1. php程序和apache结合
# 1.编辑apache配置文件
[root@LAMP ~]# vim /etc/httpd/conf/httpd.conf

# 2.对配置文件进行修改
# 使用vim,显示行号:set nu
# 在122行后添加如下配置
122 DocumentRoot "/var/www/html"
123     TypesConfig /etc/mime.types
124     AddType application/x-httpd-php .php
125     AddType application/x-httpd-php-source .phps
126     DirectoryIndex index.php index.html

# 3.编写一个php脚本,用于测试
[root@LAMP ~]# vim /var/www/html/index.php
<meta charset=utf8>
此页面为测试页面!!!
<?php
phpinfo();
?>

# 4.重启服务
[root@LAMP ~]# systemctl restart httpd

在浏览器重新输入IP:80,看到phpinfo的页面后,表示LAMP架构搭建完成。接下来在架构上部署Disuz论坛。

部署Disuz论坛

# 1.下载论坛压缩代码(按个人习惯放在目录里,我放在了/tmp文件夹下)
[root@LAMP tmp]# wget https://download.comsenz.com/files/DiscuzX/3.4/Discuz_X3.4_SC_UTF8_20220518.zip
--2022-08-11 10:20:34--  https://download.comsenz.com/files/DiscuzX/3.4/Discuz_X3.4_SC_UTF8_20220518.zip
Resolving download.comsenz.com (download.comsenz.com)... 49.234.165.129, 81.69.156.121, 81.69.153.197, ...
Connecting to download.comsenz.com (download.comsenz.com)|49.234.165.129|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 11962143 (11M) [application/zip]
Saving to: ‘Discuz_X3.4_SC_UTF8_20220518.zip’

Discuz_X3.4_SC_UTF8_2 100%[========================>]  11.41M   114KB/s    in 97s     

2022-08-11 10:22:11 (120 KB/s) - ‘Discuz_X3.4_SC_UTF8_20220518.zip’ saved [11962143/11962143]

# 2.解压缩代码包,使用解压命令unzip
[root@LAMP tmp]# yum install unzip -y
Last metadata expiration check: 1:29:25 ago on Thu 11 Aug 2022 08:54:57 AM CST.
Package unzip-6.0-43.el8.x86_64 is already installed.
Dependencies resolved.

# 3.解压缩
[root@LAMP tmp]# unzip -q -d Discuz Discuz_X3.4_SC_UTF8_20220518.zip 

# 4.拷贝upload代码到apache目录下,即可访问
[root@LAMP Discuz]# cp -r upload/* /var/www/html/
cp: overwrite '/var/www/html/index.php'? y

# 5.修改代码权限
[root@LAMP Discuz]# chmod -R 777 /var/www/html/*

# 6.访问Disuz安装向导页面
本机IP:80
----根据于超老师视频讲解进行笔记,做了相对更改,如有侵权请联系作者删除。

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