布置實(shí)驗(yàn)環(huán)境
關(guān)閉防火墻 iptables -F
禁用selinux setenforce 0
配置yum源(包括本地源和epel源) :
[base]
name=kbq
baseurl=file:///mnt
gpgcheck=0
[epel]
name=kbqe
baseurl=http://172.16.0.1/fedora-epel/7/x86_64/
gpgcheck=0
準(zhǔn)備軟件包
將準(zhǔn)備的軟件包上傳至/src中
[root@centos7 src]# ls
apr-1.5.2.tar.bz2 php-7.1.7.tar.bz2
apr-util-1.5.4.tar.bz2 wordpress-4.8-zh_CN.tar.gz
httpd-2.4.27.tar.bz2 xcache-3.2.0.tar.gz
mariadb-10.2.7-linux-x86_64.tar.gz
編譯安裝http
先將3個(gè)軟件包解壓
tar xvf apr-1.5.2.tar.bz2
tar xvf apr-util-1.5.4.tar.bz2
tar xvf httpd-2.4.27.tar.bz2
將apr的2個(gè)包移入httpd-2.4.27下的srclib中并改名
[root@centos7 src]# mv apr-1.5.2 httpd-2.4.27/srclib/apr
[root@centos7 src]# mv apr-util-1.5.4 httpd-2.4.27/srclib/apr-util
進(jìn)入httpd-2.4.27目錄中進(jìn)行編譯
./configure --prefix=/app/httpd24 --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
若為最小化安裝系統(tǒng)娩梨,在首次編譯時(shí)會(huì)提示缺少一些包組沿腰;
yum -y install openssl-devel pcre-devel
再嘗試安裝即可。
make && make install
編譯成功后可將二進(jìn)制程序的路徑添加至默認(rèn)路徑中狈定。
export PATH=/app/httpd24/bin:usr/local/mysql/bin:$PATH
查看端口是否打開并打開網(wǎng)站颂龙。
[root@centos7 httpd-2.4.27]# apachectl
[root@centos7 httpd-2.4.27]# ss -ntl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
QQ截圖20170807144132.png
安裝mariadb
先用rpm -qa "mariadb*"查看有無安裝過該包組,若有需使用yum -remove 該包組防止與我們編譯安裝的mariadb沖突纽什。
將mariadb壓縮包解壓到/usr/local下并創(chuàng)建一個(gè)軟連接
tar xvf mariadb-10.2.7-linux-x86_64.tar.gz -C /usr/local/
cd /usr/local/
ln -s mariadb-10.2.7-linux-x86_64/ mysql
查看有無mysql用戶若不存在則創(chuàng)建這個(gè)用戶
[root@centos7 local]# getent passwd mysql
[root@centos7 local]# useradd -r mysql -s /sbin/nologin -d /app/mysqldb -m
[root@centos7 local]# getent passwd mysql
mysql:x:997:995::/app/mysqldb:/sbin/nologin
生成數(shù)據(jù)庫
cd mysql/
scripts/mysql_install_db --datadir=/app/mysqldb --user=mysql
在本次實(shí)驗(yàn)中采用的是最小化安裝系統(tǒng)措嵌,缺少了libaio-0.3.107- 10.el6.x86_64這個(gè)rpm包,所以在生成數(shù)據(jù)庫時(shí)會(huì)報(bào)錯(cuò)芦缰。所以需要先安裝這個(gè)包即可企巢。rpm -ivh libaio-0.3.107-10.el6.x86_64
此時(shí)查看/app/mysql目錄下已生成數(shù)據(jù)庫
[root@centos7 mysql]# ls /app/mysqldb/
aria_log.00000001 ibdata1 mysql
aria_log_control ib_logfile0 performance_schema
ib_buffer_pool ib_logfile1 test
復(fù)制對應(yīng)的配置文件到/etc/mysql下
[root@centos7 mysql]# mkdir /etc/mysql
[root@centos7 mysql]# cp support-files/my-huge.cnf /etc/mysql/my.cnf
[root@centos7 mysql]# vim /etc/mysql/my.cnf
在【mysql】中加入三行
datadir =/app/mysqldb
innodb_file_per_table = ON
skip_name_resolve = ON
###復(fù)制服務(wù)腳本并添加服務(wù)
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig --list mysqld
將路徑添加至PATH變量中
vim /etc/profile.d/app.sh
export PATH=/usr/local/mysql/bin:/app/httpd24/bin:$PATH
. /etc/profile.d/app.sh
service mysqld start
安全初始化
mysql_secure_installation
mysql -uroot -pmagedu
MariaDB [(none)]> create database blogdb;
MariaDB [(none)]>grant all on blogdb.* to wpuser@'192.168.8.%' identified by "magedu";
編譯安裝php
tar xvf php-7.1.7.tar.bz2
cd /root/src/php-7.1.7/
yum -y install libxml2-devel bzip2-devel libmcrypt-devel
./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/httpd24/bin/apxs --with-mcrypt --with-config-file-path=/etc --with-config-file-scan-dir=/etc/php.d --with-bz2
make && make install
cp php.ini-production /etc/php.ini
vim /app/httpd24/conf/httpd.conf
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
<IfModule dir_module>
DirectoryIndex index.php index.html
</IfModule>
apachectl stop
apachectl start
QQ截圖20170807164415.png
5
tar xf wordpress-4.8-zh_CN.tar.gz
mv wordpress /app/httpd24/htdocs/blog
setfacl -m u:daemon:rwx blog/
QQ截圖20170807133755.png