首先安装数据库MariaDB,可以利用rpm yum 编译去安装,在这里我们利用yum来安装
yum install -y mariadb mariadb-server
安装完成后安装httpd
yum install httpd httpd-devel
安装编译器gcc
yum install -y gcc
安装php
yum -y install libxml2 libxml2-devel
wget https://www.php.net/distributions/php-7.3.5.tar.gz
tar xvf php-7.3.5.tar.gz
cd php-7.3.5
./configure --with-apxs2=/usr/bin/apxs --with-pdo-mysql --with-mysqli --with-zlib --without-pear --disable-phar
make
make install
成功编译安装后安装pear,并复制文件
wget http://pear.php.net/go-pear.phar
/usr/local/bin/php go-pear.phar
cp php.ini-production /usr/local/php/php.ini
成功后配置Apache
vim /etc/httpd/conf/httpd.conf
配置内容如下:
<FilesMatch .php$>
SetHandler application/x-httpd-php
删除Indexes
搜索index.html,在其后添加index.php
:/index.html
配置完成后保存退出
重新配置一个虚拟主机
vi /etc/httpd/conf.d/1.conf
配置内容如下:
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName localhost
systemctl restart httpd
写一个简单的php网页,测试php是否可用
vi /var/www/html/index.php
打开浏览器访问php
http://localhost/index.php
如果防火墙出现问题,则对防火墙的处理
firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --reload
systemctl start mariadb
mysqladmin -u root -p password ‘123456’
mysql -u root -p
create database wordpress;
grant all privileges on wordpress.* to tom@localhost identified by ‘Ab123456’;
grant all privileges on wordpress.* to tom@127.0.0.1 identified by ‘Ab123456’;
flush privileges;
exit;
安装WordPress
wget https://wordpress.org/latest.tar.gz
tar xvf wordpress-xxx.tar.gz
cp -r wordpress/* /var/www/html/
restorecon -Rv /var/www/html
chown -R apache:apache /var/www/html
setsebool -P httpd_can_network_connect 1
setsebool -P httpd_can_network_connect_db 1
restorecon -rv /var/www/html
ausearch -c ‘httpd’ --raw | audit2allow -M my-httpd
semodule -i my-httpd.pp
全部完成后,利用浏览器访问http
http://localhost/
数据库的名称为wordpress
用户为tom
密码为Ab123456
主机地址为127.0.0.1
且前缀为wp_
将生成的配置拷贝至shell
vi /var/www/html/wp-config.php
将拷贝的内容粘贴进里面
保存退出
点击生成网站,会发现网站已经生成完毕。