当前位置:网站首页>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)
边栏推荐
猜你喜欢
利用cookie获取admin权限 CTF基础题
一个网络安全小白鼠的学习之路——nmap的基本使用
hackmyvm-random walkthrough
云安全笔记:云原生全链路加密
ES6 array extension methods map, filter, reduce, fill and array traversal for…in for…of arr.forEach
A network security guinea pig's learning path - scripting of advanced usage of nmap
(4) Function, Bug, Class and Object, Encapsulation, Inheritance, Polymorphism, Copy
(6) Design of student information management system
xxe of CTF
(5) Modules and packages, encoding formats, file operations, directory operations
随机推荐
如何一步一步的:玩转全民拼购!
pytorch:保存和加载模型
hackmyvm-bunny预排
考(重点理解哪些属于其他货币资金)、其他货币资金的内容、其他货币资金的账务处理(银行汇票存款、银行本票存款、信用卡存款、信用证保证金存款、存出投资款、外埠存款)
2. PHP variables, output, EOF, conditional statements
Several interesting ways to open PHP: from basic to perverted
CTF entry md5
Shuriken: 1 vulnhub walkthrough
Offensive and defensive world - novice MISC area 1-12
(7) superficial "crawlers" process (concept + practice)
DarkHole: 2 vulnhub walkthrough
(3) string
WeChat applet development video loading: [Rendering layer network layer error] Failed to load media
hackmyvm: kitty walkthrough
Sensitive information leakage
hackmyvm: controller walkthrough
File upload vulnerability
php函数漏洞总结
(2) 顺序结构、对象的布尔值、选择结构、循环结构、列表、字典、元组、集合
hackmyvm: may walkthrough