標籤:groups 依賴 lamp安裝 dev str stop mon des ice
什麼是LAMP
LAMP是指一組通常一起使用來運行動態網站或者伺服器的自由軟體名稱首字母縮寫:
- Linux,作業系統
- Apache,網頁伺服器
- MariaDB或MySQL,資料庫管理系統(或者資料庫伺服器)
- PHP、Perl或Python,指令碼語言
LAMP架構我們需要的源碼包如下:
Apache=http://httpd.apache.org/ httpd主程式包
MySQL=http://dev.mysql.com/downloads/mysql/ mysql主程式包
PHP=http://php.net/downloads.php php主程式包
apr=http://apr.apache.org/ apr是httpd的依賴包
apr-util=http://apr.apache.org/ apr-util是httpd的第二個依賴包
apr和apr-util這個兩個軟體是對後端服務軟體進行最佳化的,
apr-util只是在apr的基礎上提供了更多的資料結構和作業系統封裝介面而已。
pcre 是httpd的第三個依賴包 http://pcre.org/
編譯安裝LAMP所需要及其所使用的源碼版本:
httpd version:httpd-2.4.16
apr version:apr-1.5.2
pcre version:pcre-8.37
apr-util version:apr-util-1.5.4
mysql version:mysql-5.6.26
php version:php-5.6.13
建議在編譯之前,把開發包組安裝:
"Development Tools"和 "Development Libraries"
yum groupinstall "Development Tools" "Development Libraries" -y
yum install gcc gcc-c++ openssl-devel -y
apr和apr-util獨立編譯
./configure --prefix=/usr/local/apr && make -j 2 && make install
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr && make -j 2 && make install
./configure --prefix=/usr/local/pcre && make -j 2 && make install && cd
Apache源碼編譯
依賴環境安裝完成,開始編譯安裝apache
tar xvf httpd-2.4.16.tar.bz2 -C /usr/local/src/ && cd /usr/local/src/httpd-2.4.16
./configure --prefix=/usr/local/apache2.4 --enable-so --enable-rewrite --enable-ssl --with-pcre=/usr/local/pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event && make -j 2 && make install &&
--prefix=/usr/local/apache2.4 #安裝路徑
--enable-so #支援動態載入模組
--enable-rewrite #支援網站地址修正
--enable-ssl #支援SSL加密
--with-pcre=/usr/local/pcre #pcre路徑
--with-apr=/usr/local/apr #apr路徑
--with-apr-util=/usr/local/apr-util #apr-util路徑
遇到如下錯誤:
1、checking for OpenSSL… checking for user-provided OpenSSL base directory… none
checking for OpenSSL version >= 0.9.8a… FAILED
configure: WARNING: OpenSSL version is too old
no
checking whether to enable mod_ssl… configure: error: mod_ssl has been requested but can
not be built due to prerequisite failures
應該是ssl版本太老了,解決方案:
yum install openssl-devel
yum update openssl
配置Apache的啟動指令碼
cp/usr/local/apache2.4/bin/apachectl /etc/init.d/apache2.4
/etc/init.d/httpd stop
chkconfig httpd off
編輯啟動指令檔
vim/etc/init.d/apache2.4
#!/bin/sh
# chkconfig: 2345 6436
#這個是啟動層級的服務,2345是指那些層級啟動,64是開啟順序,應該在network服務的後面,36是關閉順序,應該在network的前面,這裡並不是注釋
#預設network的是:2345 10 90
# description: Apache2.4.16 startscript #描述欄位,有了這兩個欄位,就可以用chkconfig命令控制
service apache2.4 start
chkconfig apache2.4 on #設定開機自啟動
Apache安裝完成需要注意的地方
ps -aux | grepapache //源碼編譯apache,運行使用者為deamon
Warning: bad syntax, perhaps a bogus ‘-‘? See /usr/share/doc/procps-3.2.8/FAQ
root 43191 0.0 0.0 70632 2184? Ss 16:54 0:00/usr/local/apache2.4/bin/httpd -k start
daemon 43192 0.0 0.1663500 4820? Sl 16:54 0:00/usr/local/apache2.4/bin/httpd -k start
daemon 43193 0.0 0.1414892 4184? Sl 16:54 0:00/usr/local/apache2.4/bin/httpd -k start
daemon 43194 0.0 0.1414892 4188? Sl 16:54 0:00/usr/local/apache2.4/bin/httpd -k start
root 43344 0.0 0.0103244 864 pts/0 S+ 17:12 0:00 grep apache
useradd -M -s/sbin/nologinapache //建立一個使用者用來運行apache
vim/usr/local/apache2.4/conf/httpd.conf //修改設定檔改變apache運行身份
Userapache #修改運行使用者daemon為apache
Groupapache #修改運行組為apache
idapache
uid=500(apache) gid=500(apache) groups=500(apache)
更改目錄許可權
chown -R apache:apache /usr/local/apache2.4/ //預設是root,改為apache
至此 Apache部分安裝部署完畢
LAMP安裝(一)關於Apache的源碼安裝