当前位置:网站首页>centos8 安装搭建php环境
centos8 安装搭建php环境
2022-08-02 03:26:00 【陌潇】
安装apache
yum install httpd
//配置ServerName//将#ServerName www.example.com:80修改为ServerName localhost:80
vi /etc/httpd/conf/httpd.conf
//这个修改就不需要多说了吧,i 进入修改模式;完成之后 Esc + : eq 保存退出
//启动apache:
systemctl start httpd
///查看安装版本: (我的是apache/2.4.37)
httpd -v
//设置开机启动:
systemctl enable httpd
安装mysql
yum install mysql mysql-server
//启动mysql
systemctl start mysqld.service
//设置root密码为123456
mysqladmin -u root password 123456
//后续如果需要修改root密码
alter user 'root'@'%' identified with mysql_native_password by '111';
//登录mysql
mysql -u root -p //回车然后输入密码
//设置远程可访问
grant all privileges on *.* to 'root'@'%'with grant option;
flush privileges;//如果远程还是无法访问,有可能是防火墙的原因,关闭防火墙
//这里可以查看root用户的host ‘localhost' 已经变成了 ’%‘
use mysql
select host,user from user;
安装php
yum install php php-devel
//查看php版本 (我的是php 7.2.11)
php -v//安装php扩展yum install php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc
//我这里在安装php-mysql的时候会提示错误:没有匹配的参数:php-mysql
//解决如下:
yum search php-mysql
//找到两个匹配版本:php-mysqlnd.x86_64 ;执行安装
yum install php-mysqlnd.x86_64
//启动php
systemctl start php-fpm
//设置开机启动
systemctl enable php-fpm
最后重启apache: systemctl restart httpd. 到这里已经全部安装完环境。
apache默认解析目录是在 /var/www/html 目录下,更改成 /var/www 目录
vim /etc/httpd/conf/httpd.conf
//从 DocumentRoot "var/www/html/" 开始 改成 ”var/www/" 重启apache :
systemctl restart httpd
测试
在/var/www/目录下新建文件 index.php 浏览器直接访问:localhost 会显示index.php的内容
设置多站点: /etc/httpd/conf.d/目录下 新建.conf 文件;对应 /var/www/目录下新建网站目录
cd /etc/httpd/conf.d/
touch test.conf
//test.conf 插入代码
<VirtualHost *:80>
DocumentRoot /var/www/test
ServerName www.test.com
<Directory "/var/www/test">
Require all granted
Options FollowSymLinks
AllowOverride all
#Require all denied
</Directory>
</VirtualHost>
客户端 hosts 指定ip地址和 域名,就可以正常访问网站了。(如 www.test.com)
边栏推荐
- Orasi: 1 vulnhub walkthrough
- 超级云APP,陪伴您一起成长的软件
- redis未授权访问(4-unacc)
- (2) 顺序结构、对象的布尔值、选择结构、循环结构、列表、字典、元组、集合
- PHP deserialization vulnerability
- 什么是广告电商商业模式?这几个门派告诉你
- (1) print()函数、转义字符、二进制与字符编码 、变量、数据类型、input()函数、运算符
- Turn trendsoft/capital amount of Chinese capital library
- CTF入门笔记之ping
- PHP Foundation March Press Announcement Released
猜你喜欢
随机推荐
hackmyvm: controller walkthrough
一个网络安全小白鼠的学习之路—nmap高级用法之脚本使用
ES6 iterator explanation example
Eric靶机渗透测试通关全教程
hackmyvm: again walkthrough
(1) introduction to Thinkphp6, installation view, template rendering, variable assignment
Command Execution Vulnerability
CTF-Neting Cup Past Topics
GreenOptic: 1 vulnhub walkthrough
cmake安装到指定目录
(1) the print () function, escape character, binary and character encoding, variables, data type, the input () function, operator
hackmyvm: again walkthrough
CTF入门之md5
The CTF introductory notes of SQL injection
加密数字货币前传:从大卫·乔姆到中本聪
Praying: 1 vulnhub walkthrough
hackmyvm: may walkthrough
Smart Tips for Frida Scripting in Kali Environment
借贷记账法下的账户结构、借贷记账法的记账规则、借贷记账法下的账户对应关系与会计分录
强化学习笔记:DDPG








