共计 4543 个字符,预计需要花费 12 分钟才能阅读完成。
CentOS 7.3 编译安装 LAMP 实现 WordPress 个人博客搭建
软件环境:
- apr-1.6.2.tar.gz
- apr-util-1.6.0.tar.gz http://apr.apache.org/
- httpd-2.4.27.tar.bz2 http://httpd.apache.org/
- php-7.1.10.tar.xz http://php.net/
- mariadb-10.2.8-linux-x86_64.tar.gz http://mariadb.org/
- wordpress-4.8.1-zh_CN.tar.gz https://cn.wordpress.org/
1、源码编译安装 Httpd2.4
(1)安装包组和包
yum groupinstall “development tools”
yum installopenssl-devel expat-devel pcre-devel
(2)解压包
tar xvf apr-1.6.2.tar.gz
tar xvf apr-util-1.6.0.tar.gz
tar xvf httpd-2.4.27.tar.bz2
(3)编译安装:
cp -r apr-1.6.2 httpd-2.4.27/srclib/apr
cp -r apr-util-1.6.0 httpd-2.4.27/srclib/apr-util
cd httpd-2.4.27/
./configure –prefix=/app/httpd24 –sysconfdir=/etc/httpd24 –enable-so –enable-ssl –enable-rewrite –with-zlib –with-pcre –with-included-apr –enable-modules=most –enable-mpms-shared=all –with-mpm=prefork
make -j 4 && make install 用四核编译并安装
(4)修改 PATH 路径
vim /etc/profile.d/lamp.sh
PATH=/app/httpd24/bin/:$PATH
./etc/profile.d/lamp.sh 生效修改
echo $PATH 查看是否生效
(5)启动服务
apachectl 启动服务
ss -tnl 查看 80 端口是否打开
2、二进制安装 mariadb
(1)解压到固定目录 /usr/local/
tar xvf mariadb-10.2.8-linux-x86_64.tar.gz -C /usr/local/
(2)创建一个软连接,或者将 mariadb-10.2.8-linux-x86_64 目录名修改为 mysql,必须是 mysql
cd /usr/local
ln -s mariadb-10.2.8-linux-x86_64/ mysql
(3)创建用户 mysql
useradd -r -m -d /app/mysqldb -s /sbin/nologin mysql
(4)生成数据库
cd mysql/
scripts/mysql_install_db –datadir=/app/mysqldb –user=mysql
(5)修改配置文件
mkdir /etc/mysql
cp support-files/my-large.cnf /etc/mysql/my.cnf
vim /etc/mysql/my.cnf 添加下面三行
[mysqld]
datadir = /app/mysqldb 数据库位置
innodb_file_per_table = ON 规定一个数据库表一个文件夹
skip_name_resolve = ON 跳过名字解析
(5)添加服务
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig –add mysqld 添加服务
chkconfig –list 查看是否添加成功
(6)创建日志
mkdir /var/log/mariadb
chown mysql /var/log/mariadb/
service mysqld start
(7)修改 PATH 路径
vi /etc/profile.d/lamp.sh
PATH=/app/httpd24/bin/:/usr/local/mysql/bin/:$PATH
./etc/profile.d/lamp.sh
mysql_secure_installation 运行安全脚本
(8)创建数据库
mysql -uroot -pcentos
create datebase wpdb;
grant all on wpdb.* to wpuser@’192.168.191.%’ identified by ‘centos’;
grant all on wpdb.* to wpuser@’127.%’ identified by ‘centos’;
grant all on wpdb.* to wpuser@’localhost’ identified by ‘centos’;
3、源码编译安装 Php
(1)安装依赖包
yum install libxml2-devel bzip2-devel libmcrypt-devel(epel)
(2)解压
tar xvf php-7.1.10.tar.xz
(3)编译,安装
cd php-7.1.10/
./configure \
–prefix=/app/php \
–enable-mysqlnd \
–with-mysqli=mysqlnd \
–with-openssl \
–with-pdo-mysql=mysqlnd \
–enable-mbstring \
–with-freetype-dir \
–with-jpeg-dir \
–with-png-dir \
–with-zlib \
–with-libxml-dir=/usr \
–enable-xml \
–enable-sockets \
–with-apxs2=/app/httpd24/bin/apxs \
–with-mcrypt \
–with-config-file-path=/etc \
–with-config-file-scan-dir=/etc/php.d \
–enable-maintainer-zts \
–disable-fileinfo
make -j 4 && make install
(4)修改配置文件
cp php.ini-production /etc/php.ini
vim /etc/httpd24/httpd.conf
在文件尾部加两行
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
修改下面行
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
(5)重启服务
apachectl stop
apachectl
4、测试 php 和 mariadb 连接
vim /app/httpd24/htdocs/index.php
<html><body><h1>LAMP</h1></body></html>
<?php
$mysqli=newmysqli(“localhost”,”root”,”centos”);
if(mysqli_connect_errno()){
echo “ 连接数据库失败!”;
$mysqli=null;
exit;
}
echo “ 连接数据库成功!”;
$mysqli->close();
phpinfo();
?>
5、配置 wordpress
(1)解压
tar xvf wordpress-4.8.1-zh_CN.tar.gz -C /app/httpd24/htdocs
(2)cd /app/httpd24/htdocs
mv wordpress/ blog/
注意:如果想要访问 http://192.168.191.107/ 就访问博客,mv wordpress/* /app/httpd24/htdocs
(3)修改配置文件
cd /app/httpd24/htdocs/blog/
cp wp-config-sample.php wp-config.php
vim wp-config.php
define(‘DB_NAME’, ‘wpdb’);
/** MySQL 数据库用户名 */
define(‘DB_USER’, ‘wpuser’);
/** MySQL 数据库密码 */
define(‘DB_PASSWORD’, ‘centos’);
/** MySQL 主机 */
define(‘DB_HOST’, ‘localhost’);
6、登录测试
http://192.168.191.107/blog
下面关于 LAMP 相关 的内容你可能也喜欢:
CentOS 7 下搭建 LAMP 平台环境 http://www.linuxidc.com/Linux/2015-06/118818.htm
Ubuntu 17.10 上使用 Apache+MariaDB+PHP7.1 安装 WordPress http://www.linuxidc.com/Linux/2017-10/148066.htm
CentOS 7.3 下配置 LAMP 实现 WordPress http://www.linuxidc.com/Linux/2017-07/145947.htm
Ubuntu 14.04 配置 LAMP+phpMyAdmin PHP(5.5.9)开发环境 http://www.linuxidc.com/Linux/2014-10/107924.htm
LAMP 结合 NFS 构建小型博客站点 http://www.linuxidc.com/Linux/2015-08/121029.htm
CentOS7 下安装部署 LAMP 环境 http://www.linuxidc.com/Linux/2016-04/130653.htm
CentOS 7 上安装(LAMP)服务 Linux,Apache,MySQL,PHP http://www.linuxidc.com/Linux/2017-05/143868.htm
Ubuntu Server 14.04 LTS 下搭建 LAMP 环境图文详解 http://www.linuxidc.com/Linux/2016-12/138758.htm
Ubuntu Server 16.04 下配置 LAMP 环境 http://www.linuxidc.com/Linux/2016-12/138757.htm
在 Ubuntu 17.04 上安装搭建 LAMP 组件环境 http://www.linuxidc.com/Linux/2017-07/145644.htm
CentOS 7 下部署 LAMP 教程及实现 WordPress http://www.linuxidc.com/Linux/2017-10/147945.htm
Ubuntu 16.04 搭建 LAMP 开发环境 http://www.linuxidc.com/Linux/2016-10/136327.htm
本文永久更新链接地址:http://www.linuxidc.com/Linux/2017-11/148947.htm