LAMP = Linux + Apache + MySQL/MariaDB + PHP/Python
1、安装CentOS Linux 7
2、安装MariaDB
yum install -y mariadb mariadb-server
3、yum安装httpd
yum install -y httpd httpd-devel
4、安装编译器gcc
yum install -y gcc
5、编译安装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
6、安装完成后配置Apache
vim /etc/httpd/conf/httpd.conf
#添加下面一段话
<FilesMatch \.php$>
SetHandler application/x-httpd-php
</FilesMatch>
#<IfModule dir_module>
#搜索index.html,在其后添加index.php
#:/index.html
#:wq
7、配置一个虚拟主机
vim /etc/httpd/conf.d/1.conf
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName localhost
</VirtualHost>
systemctl restart httpd
systemctl enable httpd
8、防火墙的处理
firewall-cmd --add-port=3306/tcp --permanent
firewall-cmd --add-port=80/tcp --permanent
firewall-cmd --add-service=http --permanent
firewall-cmd --reload
自行下载下载phpMyAdmin、Wordpress包。
-
Wordpress
https://pan.baidu.com/s/1klqN_NVe07qlkCKR5wVUNQ
提取码1cuv -
phpMyAdmin
https://pan.baidu.com/s/1rLk2-tVZyR0REuJ3gPq5eA
提取码vwly
9、解压修改phpMyAdmin
tar -xvf phpMyAdmin.tar
cd phpMyAdminxxxx
cp config.sample.inc.php config.inc.php
vim config.inc.php
blowfishsecret='1234567890abcdefghijklmnopqrstuvwxyz'
$cfg['Servers'][$i]['controlhost'] = 'localhost';
$cfg['Servers'][$i]['controlport'] = '3306';
$cfg['Servers'][$i]['controluser'] = 'root';
$cfg['Servers'][$i]['controlpass'] = '123456';
:wq
10、解压和移动Wordpress文件
tar -xvf wordpress.tar
rm -f /var/www/html/*
cp -r wordpress/* /var/www/html
11、修改selinux设置
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
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html'
restorecon -Rv /var/www/html
chown -R apache:apache /var/www/html
12、修改数据库密码和添加wordpress管理员
systemctl start mariadb
systemctl enable 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;
13、浏览器访问服务器安装wordpress
用浏览器访问http://192.168.127.131
数据库名称:wordpress
数据库用户:jerry
数据库密码:Ab1234
主机地址:127.0.0.1
前缀:wp_
将生成的配置拷贝下来,到shell中
vi /var/www/html/wp-config.php
粘贴
:wq
完成上面的操作后,再点击生成网站