1. 程式人生 > 實用技巧 >LAMP 編譯安裝 +wordpress+discuz

LAMP 編譯安裝 +wordpress+discuz


#軟體下載

#開源部落格Wordpress 下載地址:https://cn.wordpress.org/wordpress-4.7.4-zh_CN.tar.gz

#PHP 7 下載地址:http://cn2.php.net/distributions/php-7.1.4.tar.gz

#apache 下載地址:http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.25.tar.gz

#資料庫 Mariadb 下載地址:系統映象(本次採取yum 安裝, 編譯安裝 參考:Mysql 5.7.17 編譯安裝


#系統環境

[[email protected]_1~]#cat/etc/redhat-release
CentOSLinuxrelease7.2.1511(Core)
[
[email protected]
_1~]#ipaddrshoweno33554960 3:eno33554960:<BROADCAST,MULTICAST,UP,LOWER_UP>mtu1500qdiscpfifo_faststateUPqlen1000 link/ether00:0c:29:84:b7:60brdff:ff:ff:ff:ff:ff inet192.168.174.134/24brd192.168.174.255scopeglobaldynamiceno33554960 valid_lft1779secpreferred_lft1779sec inet6fe80::20c:29ff:fe84:b760/64scopelink valid_lftforeverpreferred_lftforever


#關閉防火牆和selinux

[[email protected]_1~]#systemctlstopfirewalld
[[email protected]_1~]#setenforce0


#YUM設定

[[email protected]_1~]#cat/etc/yum.repos.d/local.repo
[local]
name=local
baseurl=file:///mnt/cdrom
gpgcheck=0
enabled=1


apache編譯安裝

#下載軟體(自行操作)

[[email protected]_1~]#ls
httpd-2.4.25.tar.gzphp-7.1.4.tar.gzwordpress-4.7.4-zh_CN.tar.gz
[
[email protected]
_1~]#tar-xfhttpd-2.4.25.tar.gz [[email protected]_1~]#cdhttpd-2.4.25/ #安裝依賴包 [[email protected]_1httpd-2.4.25]#yuminstall-ynet-toolspcre-develzlib-develaprapr-develapr-utilapr-util-develgcc-c++ #編譯 [[email protected]_1httpd-2.4.25]#./configure--prefix=/usr/local/apache--with-mysql=/usr/share/mysql--enable-module=so--enable-shared=max--enable-rewrite #出現以下結果表示編譯檢查成功 configure:summaryofbuildoptions: ServerVersion:2.4.25 Installprefix:/usr/local/apache Ccompiler:gcc-std=gnu99 CFLAGS:-pthread LDFLAGS: LIBS: CPPFLAGS:-DLINUX-D_REENTRANT-D_GNU_SOURCE Cpreprocessor:gcc-E #編譯安裝 [[email protected]_1httpd-2.4.25]#make&&makeinstall


#安裝資料庫

#本次採用yum安裝 (編譯安裝可參考 Mysql 5.7.17 編譯安裝

[[email protected]_1~]#yuminstall-ymariadbmariadb-server
[[email protected]_1~]#systemctlstartmariadb


#初始化資料庫

[[email protected]_1~]#mysql_secure_installation
/usr/bin/mysql_secure_installation:line379:find_mysql_client:commandnotfound

NOTE:RUNNINGALLPARTSOFTHISSCRIPTISRECOMMENDEDFORALLMariaDB
SERVERSINPRODUCTIONUSE!PLEASEREADEACHSTEPCAREFULLY!

InordertologintoMariaDBtosecureit,we'llneedthecurrent
passwordfortherootuser.Ifyou'vejustinstalledMariaDB,and
youhaven'tsettherootpasswordyet,thepasswordwillbeblank,
soyoushouldjustpressenterhere.

Entercurrentpasswordforroot(enterfornone):
OK,successfullyusedpassword,movingon...

SettingtherootpasswordensuresthatnobodycanlogintotheMariaDB
rootuserwithouttheproperauthorisation.

Setrootpassword?[Y/n]y#選擇y
Newpassword:#設定密碼123456
Re-enternewpassword:#設定密碼123456
Passwordupdatedsuccessfully!
Reloadingprivilegetables..
...Success!


Bydefault,aMariaDBinstallationhasananonymoususer,allowinganyone
tologintoMariaDBwithouthavingtohaveauseraccountcreatedfor
them.Thisisintendedonlyfortesting,andtomaketheinstallation
goabitsmoother.Youshouldremovethembeforemovingintoa
productionenvironment.

Removeanonymoususers?[Y/n]y#選擇y
...Success!

Normally,rootshouldonlybeallowedtoconnectfrom'localhost'.This
ensuresthatsomeonecannotguessattherootpasswordfromthenetwork.

Disallowrootloginremotely?[Y/n]n#選擇n
...skipping.

Bydefault,MariaDBcomeswithadatabasenamed'test'thatanyonecan
access.Thisisalsointendedonlyfortesting,andshouldberemoved
beforemovingintoaproductionenvironment.

Removetestdatabaseandaccesstoit?[Y/n]y#選擇y
-Droppingtestdatabase...
...Success!
-Removingprivilegesontestdatabase...
...Success!

Reloadingtheprivilegetableswillensurethatallchangesmadesofar
willtakeeffectimmediately.

Reloadprivilegetablesnow?[Y/n]y#選擇y
...Success!

Cleaningup...

Alldone!Ifyou'vecompletedalloftheabovesteps,yourMariaDB
installationshouldnowbesecure.

ThanksforusingMariaDB!


#建立Wordpress資料庫

[[email protected]_1~]#mysql-uroot-p123456
WelcometotheMariaDBmonitor.Commandsendwith;or\g.
YourMariaDBconnectionidis9
Serverversion:5.5.44-MariaDBMariaDBServer

Copyright(c)2000,2015,Oracle,MariaDBCorporationAbandothers.

Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.

MariaDB[(none)]>createdatabasewordpressdb;
QueryOK,1rowaffected(0.00sec)

MariaDB[(none)]>createuser'wordpressuser'@'localhost'identifiedby'123456';
QueryOK,0rowsaffected(0.00sec)

MariaDB[(none)]>grantallonwordpressdb.*to'wordpressuser'@'localhost';
QueryOK,0rowsaffected(0.00sec)

MariaDB[(none)]>grantallonwordpressdb.*to'wordpressuser'@'%';
QueryOK,0rowsaffected(0.00sec)

MariaDB[(none)]>flushprivileges;
QueryOK,0rowsaffected(0.00sec)

MariaDB[(none)]>exit
Bye


#PHP7編譯安裝

#安裝PHP依賴 libmcrypt 下載地址ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.6.tar.gz

#下載libmcrypt
[[email protected]_1~]#wgetftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.6.tar.gz
[[email protected]_1~]#tar-xflibmcrypt-2.5.6.tar.gz
[[email protected]_1~]#cdlibmcrypt-2.5.6/
[[email protected]_1libmcrypt-2.5.6]#./configure
[[email protected]_1libmcrypt-2.5.6]#make&&makeinstall


#軟體下載(自行操作)

[[email protected]_1~]#ls
httpd-2.4.25.tar.gzphp-7.1.4.tar.gzwordpress-4.7.4-zh_CN.tar.gzhttpd-2.4.25
[[email protected]_1~]#tar-xfphp-7.1.4.tar.gz
[[email protected]_1~]#cdphp-7.1.4/
[[email protected]_1php-7.1.4]#yum-yinstalllibxml2libxml2-developensslopenssl-develcurl-devellibjpeg-devellibpng-develfreetype-devellibmcrypt-devel
[[email protected]_1php-7.1.4]#./configure--prefix=/usr/local/php7--with-apxs2=/usr/local/apache/bin/apxs\
--with-mcrypt=/usr/include--enable-mysqlnd--with-mysqli--with-pdo-mysql\
--enable-fpm--with-gd--with-iconv--with-zlib--enable-xml\
--enable-shmop--enable-sysvsem--enable-inline-optimization--enable-mbregex\
--enable-exif--enable-mbstring--enable-ftp--enable-gd-native-ttf--with-openssl\
--enable-pcntl--enable-sockets--with-xmlrpc--enable-zip--enable-soap--without-pear\
--with-gettext--enable-session--with-curl--with-jpeg-dir\
--with-freetype-dir--enable-opcache--enable-fileinfo


#出現以下情況表示編譯檢查成功
+--------------------------------------------------------------------+
|License:|
|ThissoftwareissubjecttothePHPLicense,availableinthis|
|distributioninthefileLICENSE.Bycontinuingthisinstallation|
|process,youareboundbythetermsofthislicenseagreement.|
|Ifyoudonotagreewiththetermsofthislicense,youmustabort|
|theinstallationprocessatthispoint.|
+--------------------------------------------------------------------+

ThankyouforusingPHP.

config.status:creatingphp7.spec
config.status:creatingmain/build-defs.h
config.status:creatingscripts/phpize
config.status:creatingscripts/man1/phpize.1
config.status:creatingscripts/php-config
config.status:creatingscripts/man1/php-config.1
config.status:creatingsapi/cli/php.1
config.status:creatingsapi/fpm/php-fpm.conf
config.status:creatingsapi/fpm/www.conf
config.status:creatingsapi/fpm/init.d.php-fpm
config.status:creatingsapi/fpm/php-fpm.service
config.status:creatingsapi/fpm/php-fpm.8
config.status:creatingsapi/fpm/status.html
config.status:creatingsapi/cgi/php-cgi.1
config.status:creatingext/phar/phar.1
config.status:creatingext/phar/phar.phar.1
config.status:creatingmain/php_config.h
config.status:executingdefaultcommands

#編譯安裝
[[email protected]_1php-7.1.4]#make&&makeinstall


#注:此處同時開啟了--enable-fpm 和--with-apxs2

# --with-apxs2 是直接把php編譯到apache的模組中去 ,apachectl -M 可以檢視被載入的模組

# --enable-fpm 是開啟php-fpm

#如果只想使用php-fpm 可以取消--with-apxs2選項

#引數詳解http://www.jianshu.com/p/0a79847c8151

#方便起見,本文沒有采用php-fpm



#修改http配置檔案以支援php

[[email protected]_1~]#vim/usr/local/apache/conf/httpd.conf
#將第254行修改為如下值
<IfModuledir_module>
DirectoryIndexindex.phpindex.html
</IfModule>
#第392行增加如下值
AddTypeapplication/x-httpd-php.php


#開啟服務

[[email protected]_1~]#/usr/local/apache/bin/apachectl-kstart
AH00557:httpd:apr_sockaddr_info_get()failedforKVM_1
AH00558:httpd:Couldnotreliablydeterminetheserver'sfullyqualifieddomainname,using127.0.0.1.Setthe'ServerName'directivegloballytosuppressthismessage
[[email protected]_1~]#

此處的兩個警告產生的原因是沒有設定ServerName和沒有在/etc/hosts設定主機名與ip的對應關係

[[email protected]_1~]#vim/usr/local/apache/conf/httpd.conf
#修改第196行改為如下值
ServerNamelocalhost:80


[[email protected]_1~]#vim/etc/hosts
[[email protected]_1~]#cat/etc/hosts
127.0.0.1localhostlocalhost.localdomainlocalhost4localhost4.localdomain4
::1localhostlocalhost.localdomainlocalhost6localhost6.localdomain6
192.168.174.134KVM_1
[[email protected]_1~]#/usr/local/apache/bin/apachectl-krestart


#新增php檔案

[[email protected]_1~]#vim/usr/local/apache/htdocs/index.php
[[email protected]_1~]#rm-f/usr/local/apache/htdocs/index.html
[[email protected]_1~]#cat/usr/local/apache/htdocs/index.php
<?php
phpinfo();
?>
[[email protected]_1~]#chown-Rdaemon:daemon/usr/local/apache


#測試

wKiom1kQn4KBavJMAADuc2yoay4493.png



#設定虛擬主機

[[email protected]_1~]#vim/usr/local/apache/conf/httpd.conf
#取消第479行的註釋(或者在最後一行增加如下配置)
Includeconf/extra/httpd-vhosts.conf
[[email protected]_1~]#vim/usr/local/apache/conf/extra/httpd-vhosts.conf
#新增如下配置(刪除原有配置)
<VirtualHost192.168.174.134>
DocumentRoot"/usr/local/apache/htdocs/blog"
ServerName"blog.chauncey.com"
<Directory"usr/local/apache/htdocs/blog">
AllowOverrideNone
Requireallgranted
</directory>
</VirtualHost>

[[email protected]_1~]#mkdir/usr/local/apache/htdocs/blog


#安裝開源部落格 Wordpress

#軟體下載(自行操作)

[[email protected]_1~]#ls
anaconda-ks.cfghttpd-2.4.25.tar.gzlibmcrypt-2.5.6.tar.gzphp-7.1.4.tar.gzwordpress-4.7.4-zh_CN.tar.gz
httpd-2.4.25libmcrypt-2.5.6php-7.1.4
[[email protected]_1~]#tar-xfwordpress-4.7.4-zh_CN.tar.gz
[[email protected]_1~]#cp-rfwordpress/*/usr/local/apache/htdocs/blog/
[[email protected]_1~]#chown-Rdaemon:daemon/usr/local/apache/htdocs/blog

#語法檢查
[[email protected]_1~]#/usr/local/apache/bin/apachectl-t
SyntaxOK

#開啟服務
[[email protected]_1~]#/usr/local/apache/bin/apachectl-kstart
[[email protected]_1~]#netstat-lntup|grep80
tcp00192.168.174.134:800.0.0.0:*LISTEN3068/httpd
[[email protected]_1~]#

#設定DNS解析

#window設定hosts檔案(C:\Windows\System32\drivers\etc\hosts)增加一行解析 #Linux設定hosts (/etc/hosts)


wKioL1kRHxrhpVBrAAAvUzG1qIQ112.png


#輸入blog.chauncey.com

wKiom1kRHxvShcv7AADQMykuHeo691.png


#填寫相關資料

wKiom1kRHxzTeOUcAACv48o2Qm8321.png



#填寫相關資料

wKioL1kRHx2CFv1lAADpBrYHdxI350.png


wKiom1kRHx2hQqgoAABUGKSLo_g645.png

#安裝完成,wordpress十分強大,外掛豐富,可以去騰訊雲或者阿里雲買一臺雲主機,來搭建自己的個人部落格。


wKioL1kRJUHSzojHAAPxVGGqmTM069.png



#登陸密碼忘記 找回方法:

WordPress恢復密碼PHP檔案 下載地址:https://www.freehao123.com/dl-wordpress-password-php/

上傳到 wordpress根目錄下面/usr/local/apache/htdocs/blog


訪問

wKiom1kRMsXSM5s-AACQa0Mshzk639.png














#Discuz!論壇安裝

#軟體下載 下載地址:http://www.discuz.net/forum-10-1.html


#建立Discuz!資料庫

[[email protected]_1~]#mysql-uroot-p123456
WelcometotheMariaDBmonitor.Commandsendwith;or\g.
YourMariaDBconnectionidis80
Serverversion:5.5.44-MariaDBMariaDBServer
Copyright(c)2000,2015,Oracle,MariaDBCorporationAbandothers.
Type'help;'or'\h'forhelp.Type'\c'toclearthecurrentinputstatement.
MariaDB[(none)]>createdatabasediscuz;
QueryOK,1rowaffected(0.00sec)
MariaDB[(none)]>createuser'discuzuser'@'localhost'identifiedby'123456';
QueryOK,0rowsaffected(0.01sec)
MariaDB[(none)]>grantallondiscuz.*to'discuzuser'@'localhost';
QueryOK,0rowsaffected(0.01sec)
MariaDB[(none)]>grantallondiscuz.*to'discuzuser'@'%';
QueryOK,0rowsaffected(0.00sec)
MariaDB[(none)]>flushprivileges;
QueryOK,0rowsaffected(0.00sec)
MariaDB[(none)]>exit
Bye


#上傳軟體

[[email protected]_1~]#wgethttp://download.comsenz.com/DiscuzX/3.3/Discuz_X3.3_SC_GBK.zip
[[email protected]_1~]#yuminstall-yunzip
[[email protected]_1~]#unzipDiscuz_X3.3_SC_GBK.zip
[[email protected]_1~]#mkdir/usr/local/apache/htdocs/bbs/
[[email protected]_1~]#cp-rfupload/*/usr/local/apache/htdocs/bbs/
[[email protected]_1~]#chown-Rdaemon:daemon/usr/local/apache/htdocs/bbs


#增加虛擬主機

[[email protected]_1~]#vim/usr/local/apache/conf/extra/httpd-vhosts.conf
[[email protected]_1~]#cat/usr/local/apache/conf/extra/httpd-vhosts.conf
#增加如下配置
<VirtualHost192.168.174.134>
DocumentRoot"/usr/local/apache/htdocs/bbs"
ServerName"bbs.chauncey.com"
<Directory"usr/local/apache/htdocs/bbs">
AllowOverrideNone
Requireallgranted
</directory>
</VirtualHost>


#開啟服務

#語法檢查
[[email protected]_1~]#/usr/local/apache/bin/apachectl-t
SyntaxOK
[[email protected]_1~]#/usr/local/apache/bin/apachectl-krestart


#設定DNS解析

#window設定hosts檔案(C:\Windows\System32\drivers\etc\hosts)增加一行解析 #Linux設定hosts (/etc/hosts)

wKiom1kRtazTBI0FAAA-qR9o7y0854.png


#開始安裝

wKiom1kRtlvD8vqdAAEyj20MJR4122.png


#開始安裝

wKioL1kRta6hjgSaAADX9zAr3-0642.png


#檢查環境

wKiom1kRta6wnJJ8AACRN0SGzeA055.png


#設定資料庫

wKioL1kRta6wgIOEAACxbOt5GDE352.png


#安裝完成

wKiom1kRtbDSjYJkAAROPYzCmj0894.png


#測試訪問

wKioL1kRtbHzafWjAAC9SR_FM7E658.png









轉載於:https://blog.51cto.com/cqwujiang/1923521