centos7.3编译安装LAMP环境并搭建wordpress博客
日期:2017年8月6日
软件版本:
apr-1.5.2.tar.bz2
apr-util-1.5.4.tar.bz2
httpd-2.4.27.tar.bz2
mariadb-10.2.7-linux-x86_64.tar.gz
PHP-7.1.7.tar.bz2
wordpress-4.8-zh_CN.tar.gz
xcache-3.2.0.tar.gz
1.编译安装apache2.4
yumgroupinstalldevelopmenttools yuminstallpcre-developenssl-devel
解压缩httpd包和两个apr包,注意apr包的解压路径为httpd-xxx/srclib目录
tar-xvfhttpd-2.4.27.tar.bz2-C/tmp/ tar-xvfapr-1.5.2.tar.bz2-C/tmp/httpd-2.4.27/srclib/ tar-xvfapr-util-1.5.4.tar.bz2-C/tmp/httpd-2.4.27/srclib/ cd/tmp/httpd-2.4.27/srclib/ mvapr-1.5.2/apr mvapr-util-1.5.4/apr-util
创建httpd的安装目录
mkdir/app/web cd/tmp/httpd-2.4.27 ./configure--prefix=/app/web--enable-so--enable-ssl--enable-cgi--enable-rewrite--with-zlib--with-pcre--with-included-apr--enable-modules=most--enable-mpms-shared=all--with-mpm=prefork make&&makeinstall
添加启动路径脚本
vi/etc/profile.d/web.sh exportPATH=/app/web/bin:$PATH ./etc/profile.d/web.sh
启动服务并检查端口是否开启
apachectl ss-ntl manapachectl
2.安装mariadb10.2
如果之前已安装过mariadb,则需要先卸载
rpm-qamariadb yuminfomariadb yumremovemariadb
此mariadb包为二进制包,无需编译直接安装即可,注意必须指定解压目录为/usr/local
tar-xfmariadb-10.2.7-linux-x86_64.tar.gz-C/usr/local cd/usr/local/ ln-smariadb-10.2.7-linux-x86_64/MysqL
useradd-rMysqL-s/sbin/nologin-d/app/mariadb-m
如果有则执行
usermod-d/app/mariadbMysqL
getentpasswdMysqL
cd/usr/local/MysqL/ ./scripts/MysqL_install_db--datadir=/app/mariadb--user=MysqL
创建主配置文件
mkdir/etc/MysqL cpsupport-files/my-huge.cnf/etc/MysqL/my.cnf vim/etc/MysqL/my.cnf [MysqLd]加三行 datadir=/app/MysqLdb innodb_file_per_table=ON skip_name_resolve=ON
添加启动路径脚本
vi/etc/profile.d/web.sh exportPATH=/app/web/bin:/usr/local/MysqL/bin:$PATH ./etc/profile.d/web.sh
添加到系统服务
cpsupport-files/MysqL.server/etc/init.d/MysqLd chkconfig--addMysqLd chkconfig--listMysqLd serviceMysqLdstart
设置MysqL的root密码和其他安全配置
MysqL_secure_installation
MysqL-uroot-p MariaDB[(none)]>createdatabasewpdb; MariaDB[(none)]>grantallonwpdb.*towpuser@'192.168.10.%'identifiedby"redhat";
3.编译安装PHP7.1
tarxvfPHP-7.1.7.tar.bz2 cd/root/src/PHP-7.1.7/ yum-yinstalllibxml2-develbzip2-devellibmcrypt-devel 注:libmcrypt这个包需要epel源
./configure--prefix=/app/PHP--enable-MysqLnd--with-MysqLi=MysqLnd--with-openssl--enable-mbstring--with-png-dir--with-jpeg-dir--with-freetype-dir--with-zlib--with-libxml-dir=/usr--enable-xml--enable-sockets--with-apxs2=/app/web/bin/apxs--with-mcrypt--with-config-file-path=/etc--with-config-file-scan-dir=/etc/PHP.d--with-bz2 make&&makeinstall
more/app/web/conf/httpd.conf|grepPHP LoadModulePHP7_modulemodules/libPHP7.so 创建PHP配置文件 cpPHP.ini-production/etc/PHP.ini vim/app/web/conf/httpd.conf增加如下内容 AddTypeapplication/x-httpd-PHP.PHP AddTypeapplication/x-httpd-PHP-source.PHPs <IfModuledir_module> DirectoryIndexindex.PHPindex.html </IfModule>
重启httpd服务
apachectlrestart apachectl
测试PHP和MysqL,增加如下的主页文件,打开网页测试连接数据库成功或失败
vi/app/web/htdocs/index.PHP
<?PHP $MysqLi=newMysqLi("127.0.0.1","root","redhat"); if(MysqLi_connect_errno()){ echo"连接数据库失败!"; $MysqLi=null; exit; } echo"连接数据库成功!"; $MysqLi->close(); PHPinfo(); ?>
4.安装wordpress
解压包到web默认目录htdocs下
tarxfwordpress-4.8-zh_CN.tar.gz-C/app/web/htdocs/ cd/app/web/htdocs/ mvwordpress/wp cdwp cpwp-config-sample.PHPwp-config.php
vim wp-config.php 手动更改以下4项
/**wordpress数据库的名称*/ define('DB_NAME','wpdb'); /**MysqL数据库用户名*/ define('DB_USER','wpuser'); /**MysqL数据库密码*/ define('DB_PASSWORD','redhat'); /**MysqL主机*/ define('DB_HOST','192.168.10.33');
5.编译安装xcache3.2
tar-xf/mnt/hgfs/vms/lamp-c73/xcache-3.2.0.tar.gz-C/tmp/ cd/tmp/xcache-3.2.0/ moreINSTALL PHPize--clean&&PHPize ./configure--enable-xcache--with-PHP-config=/usr/bin/PHP-config make&&makeinstall maketest cpxcache.ini/etc/PHP.d/ apachectlrestart
博客访问地址:
http://192.168.10.33/wp/
原文链接:https://www.f2er.com/centos/376455.html