LINUX虚拟机内使用Apache搭建个人博客笔记
查看IP以及配IP,测试能否连接外网
IP:
ip a
nmcli connection add
con-name zxy type
ethernet ifname ens33
ipv4.method manual
ipv4.addresses 192.168.62.62/24
ipv4.gateway 192.168.62.62
nmcli con up zxy
ip a
挂载:
mount /dev/cdrom /mnt
cd /etc/yum.repos.d/
rm -rf *
vi zxy.repo
[zxy]
name=zxy
baseurl=file:///mnt
gpgcheck=0
enable=1
刷新repos缓存: yum makecache
yum clean all
查看Apache运行状态: systemctl status httpd
开机自启Apache: systemctl enale httpd
关闭防火墙(临时关闭,关机后自动开启): systemctl stop firewalld
禁止开机启动防火墙: systemctl disable firewalld
--不关闭防火墙,放行80端口访问Apache:
firewall-cmd --zone=public --add-port=80/tcp --permanent (permanent:永久生效,没有次参数重启后失效)
重启Apache服务 systemctl restart httpd
Httpd:
yum install -y httpd
systemctl status httpd
systemctl start httpd
systemctl enable httpd
firewall-cmd --permanent --add-service=http
firewall-cmd --reload
firewall-cmd --list-all
cd /var/www/html
PHP:
yum install -y php
vim /var/www/html/info.php
<?
phpinfo();
?>
192.168.0.1/info.php
MariaDB:
yum install mariadb mariadb-server -y
# 开机自启marindb systemctl enable mariadb
# 开启mariadb systemctl start mariadb
mysql_secure_installation
mysql -uroot -p123456
vim /var/www/html/sql.php
<?php
$link=mysql_connect('localhost','root','123456');
if($link)
echo "1111";
else
echo "2222";
mysql_close();
?>
yum install php-mysql -y
systemctl restart httpd
解压: tar xf wordpress-5.0.2-zh_CN.tar
Wordpress:
<VirtualHost *:80>
ServerName liyukun.com
DocumentRoot "/code/wordpress"
DirectoryIndex index.php index.html
ErrorLog logs/error_wordpress_log
CustomLog logs/access_wordpress_log combined
</VirtualHost>
<Directory /code/wordpress>
AllowOverride All
Require all granted
</Directory>
systemctl restart httpd
mysql -uroot -p123456
创建wordpress数据库表: create database wordpress;
C:\Windows\System32\drivers\etc
无法连接FTP服务器问题:wordpress/wp-config.php 后面加代码:
define("FS_CHMOD_DIR", 0777);
define("FS_CHMOD_FILE", 0777);
define("FS_METHOD", "direct");
wordpress更新目录创建失败问题:html路径下执行下面代码
chown -R apache:apache wordpress