赞
踩
目录
3.2.3 将网站目录的所属主和所属组设置为apache用户
LAMP:由Linux、Apache、MySQL、PHP组成的一个web网络平台。
LAMP环境,主要给WEB端应用程序(各种类型的网站项目),提供了一个部署安装和使用的平台。
注意:Apache服务在Linux中的映射名字为 httpd
- # 安装Apache服务
- yum -y install httpd
- # 启动Apache服务
- systemctl start httpd
- # 关闭防火墙
- systemctl stop firewalld
- # 关闭防火墙自启动
- systemctl disabled firewalld
- # 关闭selinux
- setenforce 0
- # 创建网站目录
- mkdir /var/www/html/www.a.com
- # 编写网站首页文件
- vim /var/www/html/www.a.com/index.html
- # 添加以下内容
- <h1>Hello World!</h1>
- # 执行以下操作
- vim /etc/httpd/conf.d/a.com.conf
- # 子配置文件中添加以下内容
- <VirtualHost *:80>
- ServerName www.a.com
- DocumentRoot /var/www/html/www.a.com
- </VirtualHost>
- # 重新加载配置文件
- systemctl reload httpd
- # 坚持配置文件是否正确
- httpd -t
- vim /etc/hosts
- # 添加以下内容
- 服务器IP www.a.com
浏览器中访问www.a.com
修改 C:\Windows\System32\drivers\etc\hosts
- # 添加以下内容
- 服务器IP www.a.com
浏览器中访问www.a.com
- # 创建网站目录
- mkdir /web/www.b.com
- # 创建网站首页文件
- vim /web/www.b.com/index.html
- # 添加以下内容
- <h2>我是第二个网站</h2>
- # 执行以下操作
- vim /etc/httpd/conf.d/b.com.conf
- # 添加以下内容
- <VirtualHost *:80>
- ServerName www.b.com
- DocumentRoot /web/www.b.com
- </VirtualHost>
- <Directory "/web/www.b.com">
- Require all granted
- </Directory>
- # 重新加载配置文件
- systemctl reload httpd
- # 坚持配置文件是否正确
- httpd -t
yum -y install httpd
由于该项目需要mariaDB数据库10.x版本以上,先配置mariaDB yum源
- # 执行以下操作
- vim /etc/yum.repo.d/mariadb.repo
- # 添加以下内容
- [mariaDB]
- name = MariaDB
- baseurl = http://mirrors.aliyun.com/mariadb/yum/10.5/centos/7/x86_64/
- gpgkey = http://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
- gpgcheck = 1
- # 清除旧缓存,建立新缓存
- yum clean all && yum makecache
- # 安装MariaDB 数据库
- yum -y install mariadb-server mariadb
安装Remi仓库,它提供了最新的PHP版本和其他Web开发工具。
yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
启用Remi仓库中的PHP 8.2模块。
yum install -y yum-utils yum-config-manager --enable remi-php82
安装PHP 8.2及其扩展
yum -y install php php-cli php-fpm php-mysqlnd php-zip php-devel gd php-gd php-mbstring php-curl php-xml php-pear php-bcmath php-json
- # 启动Apache服务和mariadb服务
- systemctl start httpd mariadb
- # 设置开机自启动
- systemctl enable httpd mariadb
wget https://gitee.com/Discuz/DiscuzX/repository/archive/v3.5.zip
- # 创建网站目录
- mkdir /web/discuz
- # 解压压缩包
- unzip v3.5.zip
- # 复制uoload目录中所有文件到网站目录
- cp -r ./uploda/* /web/discuz
- # 修改网站目录所属主和所属组为apache
- chown -R apache:apache /web/discuz
- # 执行以下操作
- vim /etc/httpd/conf.d/discuz.conf
- # 配置文件中添加以下内容
- <VirtualHost *:80>
- ServerName www.discuz.com
- DocumentRoot /web/discuz
- </VirtualHost>
- <Directory "/web/discuz">
- Require all granted
- </Directory>
检查配置文件是否正确
- # 重新加载配置文件
- systemctl reload httpd
- # 坚持配置文件是否正确
- httpd -t
路径: C:\Windows\System32\drivers\etc\hosts
服务器IP www.discuz.com
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。