軟體環境:
apr-1.6.2.tar.gz
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
<code><html><body><h1>LAMP</h1></body></html></code>
<code> </code><code><?php</code>
<code> </code><code>$mysqli</code><code>=newmysqli(</code><code>"localhost"</code><code>,</code><code>"root"</code><code>,</code><code>"centos"</code><code>);</code>
<code> </code><code>if</code><code>(mysqli_connect_errno()){</code>
<code> </code><code>echo</code> <code>"連接配接資料庫失敗!"</code><code>;</code>
<code> </code><code>$mysqli</code><code>=null;</code>
<code> </code><code>exit</code><code>;</code>
<code> </code><code>}</code>
<code> </code><code>echo</code> <code>"連接配接資料庫成功!"</code><code>;</code>
<code> </code><code>$mysqli</code><code>->close();</code>
<code> </code><code>phpinfo();</code>
<code>?></code>
<a href="https://s2.51cto.com/oss/201710/23/af2246f0f9523c453a49b1dcc2ee06fe.png" target="_blank"></a>
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
<code>define(</code><code>'DB_NAME'</code><code>, </code><code>'wpdb'</code><code>);</code>
<code> </code>
<code>/** MySQL資料庫使用者名 */</code>
<code>define(</code><code>'DB_USER'</code><code>, </code><code>'wpuser'</code><code>);</code>
<code>/** MySQL資料庫密碼 */</code>
<code>define(</code><code>'DB_PASSWORD'</code><code>, </code><code>'centos'</code><code>);</code>
<code>/** MySQL主機 */</code>
<code>define(</code><code>'DB_HOST'</code><code>, </code><code>'localhost'</code><code>);</code>
6 、登入測試
http://192.168.191.107/blog
填寫部落格資訊
本文轉自 hawapple 51CTO部落格,原文連結:http://blog.51cto.com/guanm/1975351