編譯安裝LAMP

編譯安裝LAMP

(1) 系統環境:CentOS 6, 7 
    CentOS 6:
apr, apr-util的版本為1.3.9,不適用于httpd-2.4; 
    CentOS 7:
apr, apr-util的版本為1.4+, 
(2) 開發環境: 
    Development Tools, Server Platform Development 
(3) 各程序版本 
    httpd: 2.2, 2.4 
    php:5.3.x 5.4.x, 5.6.x 
    mysql:5.1, 5.5, 5.6, 5.7, 5.8, 8.0 
    mariadb:5.x, 10.x 
(4) httpd+php 
    php的編譯選項: 
        Modules:
--with-apxs 
        httpd MPM: 
            prefork: 
            worker, event:專用選項–enable-maintainer-zts 
    fpm:
--enable-fpm

本次安裝以CentOS 7為例進行安裝

安裝httpd-2.4

[root@centos7 ~]# mkdir -p /usr/local/lamp  #創建lamp目錄
[root@centos7 ~]# yum -y groupinstall "Development Tools" "Server Platform Development"  #安裝開發環境
[root@centos7 ~]# yum -y install pcre-devel openssl-devel libevent-devel apr-devel apr-util-devel  #安裝依賴包
[root@centos7 ~]# useradd -r -s /sbin/nologin apache  #創建apache系統用戶
[root@centos7 ~]# tar xf httpd-2.4.6.tar.bz2  #解壓
[root@centos7 ~]# cd httpd-2.4.6/
[root@centos7 httpd-2.4.6]# ./configure --prefix=/usr/local/lamp/apache2 --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --enable-modules=most --enable-mpms-shared=all --with-mpm=prefork --with-pcre --with-zlib --with-apr=/usr --with-apr-util=/usr  #配置httpd
[root@centos7 httpd-2.4.6]# make   #編譯
[root@centos7 httpd-2.4.6]# make install #安裝
[root@centos7 ~]# echo "export PATH=/usr/local/lamp/apache2/bin:$PATH" > /etc/profile.d/httpd.sh  #配置PATH環境變量
[root@centos7 ~]# . /etc/profile.d/httpd.sh   #生效
[root@centos7 ~]# vim /etc/httpd/httpd.conf   #編輯配置文件

287)C{F]5MS5S7{PE[G@357.png

8JL)6O$0I(7S7B6[81U`_N9.png

[root@centos7 ~]# apachectl start  #啟動httpd服務

G$$Z}(FYJ5MFKLX){[C[TSW.png

]PK)ZMXWWT7T1S0({HSJ_KK.png

安裝mariadb

安裝MariaDB: 
    1.預制的包管理器格式的程序包: 
        rpm包: 
            os vendor:mariadb-devel 
            MariaDB官方 
    2.通用二進制格式的程序包: 
    3.源碼包編譯:項目構建工具為cmake, 而非流行的make;

本次以通用二進制格式包的安裝配置

[root@centos7 ~]# useradd -r -s /sbin/nologin mysql  #創建mysql系統用戶
[root@centos7 ~]# tar xf mariadb-VERSION-linux-x86_64.tar.gz -C /usr/local/lamp  #解壓至/usr/local/lamp目錄下
[root@centos7 ~]# cd /usr/local/lamp
[root@centos7 lamp]# ln -s mariadb-VERSION-linux-x86_64 mysql  #創建軟連接
[root@centos7 ~]# cd mysql
[root@centos7 mysql]# chown -R mysql:mysql ./*  #修改屬主屬組為mysql
[root@centos7 mysql]# mkdir -pv /mydata/data  #為mysql創建數據目錄
[root@centos7 mysql]# chown -R mysql:mysql /mydata/data  #修改數據目錄屬主屬組為msql
[root@centos7 mysql]# ./scripts/mysql_install_db  --user=mysql  --datadir=/mydata/data --skip_name_resolve   #安裝mysql
[root@centos7 mysql]# cp support-files/my-large.cnf  /etc/my.cnf  #生成配置文件
[root@centos7 mysql]# cp support-files/mysql.server  /etc/rc.d/init.d/mysqld   #生成服務腳本文件
[root@centos7 mysql]# chkconfig --add mysqld   #添加開機自啟動
[root@centos7 mysql]# chkconfig --level 2345 mysqld on  #開機在2345運行級別下啟動

[root@centos7 mysql]# vim /etc/my.cnf  #編輯配置文件

%RS3FI0M@E4I(DW]4{9N33U.png

[root@centos7 mysql]# service mysqld start   #啟動mysql服務
Starting MySQL.. SUCCESS!
[root@centos7 mysql]#

1E2E4)XP}VB%I_P}F2U(E8S.png

[root@centos7 ~]# echo "export PATH=/usr/local/mysql/bin:$PATH" > /etc/profile.d/mysql.sh   #配置PATH環境變量
[root@centos7 ~]# . /etc/profile.d/mysql.sh   #生效
[root@centos7 ~]# mysql_secure_installation   #可對數據庫做安全配置  
[root@centos7 ~]# mysql  #測試數據庫
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 5.5.46-MariaDB-log MariaDB Server

Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>     #數據庫配置成功!?。?!

基于module安裝php

Modules:--with-apxs 
    httpd MPM: 
        prefork: 
        worker, event:專用選項
--enable-maintainer-zts 

[root@centos7 ~]# yum -y install gd-devel freetype-devel libxml2-devel libmcrypt-devel   #安裝php依賴包
[root@centos7 ~]# tar xf php-5.4.40.tar.bz2  #解壓
[root@centos7 ~]# cd php-5.4.40/
[root@centos7 php-5.4.40]# ./configure --prefix=/usr/local/lamp/php5 --with-mysql=/usr/local/lamp/mysql --with-mysqli=/usr/local/lamp/mysql/bin/mysql_config --with-openssl --enable-mbstring --enable-xml --enable-sockets --with-freetype-dir --with-gd --with-libxml-dir=/usr --with-zlib --with-jpeg-dir --with-png-dir --with-mcrypt --with-apxs2=/usr/local/lamp/apache2/bin/apxs --with-config-file-path=/etc/php.ini --with-config-file-scan-dir=/etc/php.d/  #配置php參數
[root@centos7 php-5.4.40]# make  #編譯
[root@centos7 php-5.4.40]# make install  #安裝
[root@centos7 php-5.4.40]# cp php.ini-production /etc/php.ini  #復制配置文件
[root@centos7 php-5.4.40]# vim /etc/httpd/httpd.conf  #編輯httpd配置文件整合httpd+php

U~2WL7IY2OV2~GWT4W]4I_M.png

W~BZECTA}_BP2CIRQCOWK3J.png

[root@centos7 ~]# vim /usr/local/lamp/apache2/htdocs/index.php   #創建默認訪問頁

EHROD{PZ_11Z2N`1_1A@H[F.png

測試

I~GIT6%CXQ]F[1CF9}Z~KI0.png

基于php-fpm安裝php

fpm:--enable-fpm 

[root@centos7 ~]# yum -y install gd-devel freetype-devel libxml2-devel libmcrypt-devel  #安裝php依賴包
[root@centos7 ~]# tar xf php-5.4.40.tar.bz2  #解壓
[root@centos7 ~]# cd php-5.4.40/
[root@centos7 php-5.4.40]# ./configure --prefix=/usr/local/lamp/php5 --with-mysql=/usr/local/lamp/mysql --with-mysqli=/usr/local/lamp/mysql/bin/mysql_config --with-openssl --enable-mbstring --enable-xml --enable-sockets --with-freetype-dir --with-gd --with-libxml-dir=/usr --with-zlib --with-jpeg-dir --with-png-dir --with-mcrypt --enable-fpm --with-config-file-path=/etc/php.ini --with-config-file-scan-dir=/etc/php.d/  #配置php參數
[root@centos7 php-5.4.40]# make  #編譯
[root@centos7 php-5.4.40]# make install  #安裝
[root@centos7 php-5.4.40]# cp php.ini-production /etc/php.ini  #復制配置文件
[root@centos7 php-5.4.40]# cp /usr/local/lamp/php5/php-fpm.conf.default /usr/local/lamp/php5/php-fpm.conf  #生成php-fpm配置文件
[root@centos7 php-5.4.40]# vim /etc/httpd/httpd.conf  #編輯httpd配置文件整合httpd+php

U~2WL7IY2OV2~GWT4W]4I_M.png

W~BZECTA}_BP2CIRQCOWK3J.png

)YSFV7Y8R~Z9$$2UVENP2_B.png

[root@centos7 php-5.4.40]# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm   #生成php-fpm服務腳本文件
[root@centos7 php-5.4.40]# chkconfig --add php-fpm   #添加php-fpm開機自啟動
[root@centos7 php-5.4.40]# chkconfig --level 2345 php-fpm on   #開機在2345運行級別下開啟此服務
[root@centos7 ~]# service php-fpm start   #開啟php-fpm服務

EME%SB{KZGEU[%PUORLV(@D.png

測試

I~GIT6%CXQ]F[1CF9}Z~KI0.png

原創文章,作者:zhai796898,如若轉載,請注明出處:http://www.www58058.com/57262

(0)
zhai796898zhai796898
上一篇 2016-11-03 21:32
下一篇 2016-11-03 23:08

相關推薦

  • 高可用+LVS-NAT

    關鍵:floating VIP 要以組為單位同時切換 實驗1: 主備VRRP 切換實驗 預期: 設定配置文件: A主機 (172.18.48.61) vrrp_sync_group VG1 { group { outside_network inside_network } } vrrp_instance outside_network { state MA…

    2017-05-14
  • N22-第七周作業

    1、創建一個10G分區,并格式為ext4文件系統;   (1) 要求其block大小為2048, 預留空間百分比為2, 卷標為MYDATA, 默認掛載屬性包含acl;   (2) 掛載至/data/mydata目錄,要求掛載時禁止程序自動運行,且不更新文件的訪問時間戳; 在擴展分區/dev/sda4下新建一個10G的分…

    Linux干貨 2016-10-25
  • 8.9作業

    刪除/etc/grub2.conf文件中所有以空白開頭的行,行首的空白字符 [root@English6 ~]# sed "s@^[[:space:]]\+@@" /etc/grub.conf  # grub.conf generated by an…

    Linux干貨 2016-08-11
  • Linux學習小結 1

    一、描述計算機的組成及其功能 計算機由硬件和軟件組成: 1、硬件組成又分為: 中央處理器(CPU):功能主要是解釋計算機指令以及處理計算機軟件中的數據, 中央處理器主要包括運算器(算術邏輯運算單元,ALU,Arithmetic Logic Unit)和高速緩沖存儲器(Cache)及實現它們之間聯系的數據(Data)、控制及狀態的總線(Bus)內部存儲器(Me…

    Linux干貨 2017-06-27
  • 馬哥教育網絡班21期+第3周課程練習

    1、列出當前系統上所有已經登錄的用戶的用戶名,注意:同一個用戶登錄多次,則只顯示一次即可。 //使用who命令列出列出當明顯登錄的所有用戶,使用cut命令取出用戶名,使用sort命令去重即可// [root@localhost ~]# who | cut -d' ' -f1…

    Linux干貨 2016-08-08
  • SELinux介紹

    SELinux介紹 SELinux: Secure Enhanced Linux, 是美國國家安全局(NSA=The National Security Agency)和SCC(Secure Computing Corporation)開發的 Linux的一個強制訪問控制的安全模塊。 2000年以GNU GPL發布, Linux內核2.6版本后集成在內核中D…

    Linux干貨 2016-10-08
欧美性久久久久