centosapache編譯安裝
❶ Centos 下Apache(httpd) 安裝過程
其實,網上這塊的部署文章非常多 。隨便搜索,都有 。
這篇文章,老徐幫大家挑選幾個比較重點的過程 & 命令 。
1. 有些 linux 版本中已經預置了有Apache,並且已經是服務了,所有首先檢查系統中是否已經存在httpd的服務
1)先檢查 伺服器 上是否已經啟動了此服務 。
命令如下
ps -ef|grep httpd
2)查看linux系統服務中有沒有httpd
chkconfig --list | grep httpd
3)如果有服務存在,那麼需要先關閉httpd服務自啟動
命令 chkconfig httpd off
4)停止httpd服務
命令 service httpd stop
5)再次查看,是否有進程存在
命令 ps -ef|grep httpd
6)如果有進程存在,關閉進程
命令 kill -9 pid
1)先檢查 安裝包 的名字
命令 rpm -qa|grep httpd
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[root@istester]~# rpm -qa|grep httpd
httpd-2.2.15-69.el6.centos.x86_64
httpd-tools-2.2.15-69.el6.centos.x86_64</pre>
2)根據安裝包名字刪除包
rpm -e httpd-tools-2.2.15-69.el6.centos.x86_64
rpm -e httpd-2.2.15-69.el6.centos.x86_64
3)刪除httpd.conf文件
<pre class="prettyprint" style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">#先檢查文件在哪
find / -name httpd.conf
rm /xxx/xxx/httpd.conf</pre>
3. 准備事項已完成,剩下的就是常規安裝了 。
註:我們通過yum的方式,在線安裝,非常簡單 。
1)檢查是否存在httpd包
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[www@istester ~]$ yum list httpd
Loaded plugins: security
base | 3.7 kB 00:00
epel | 4.7 kB 00:00
epel/primary_db | 6.0 MB 00:00
extras | 3.4 kB 00:00
extras/primary_db | 28 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 3.2 MB 00:00
Available Packages
httpd.x86_64 2.2.15-69.el6.centos base</pre>
2、安裝Apache
yum install httpd
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">Total 20 MB/s | 932 kB 00:00
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 1/4
Updating : httpd-tools-2.2.15-69.el6.centos.x86_64 2/4
Installing : httpd-2.2.15-69.el6.centos.x86_64 3/4
Cleanup : httpd-tools-2.2.15-53.el6.centos.x86_64 4/4
Verifying : httpd-tools-2.2.15-69.el6.centos.x86_64 1/4
Verifying : httpd-2.2.15-69.el6.centos.x86_64 2/4
Verifying : apr-util-ldap-1.3.9-3.el6_0.1.x86_64 3/4
Verifying : httpd-tools-2.2.15-53.el6.centos.x86_64 4/4
Installed:
httpd.x86_64 0:2.2.15-69.el6.centos
Dependency Installed:
apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1
Dependency Updated:
httpd-tools.x86_64 0:2.2.15-69.el6.centos
Complete!</pre>
安裝過程,不用理會,如果看到如上提示,說明安裝成功了。
3、設置Apache服務的啟動級別
chkconfig --levels 235 httpd on
Apache是一個服務,所以,可以通過設置服務的啟動級別來讓它啟動。
4、啟動服務
兩種方式,
1)如下 /etc/init.d/httpd start
2)如下
service httpd start
5、查看服務是否正常啟動
兩種方式,
1)查看服務狀態
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[root@istester www]# service httpd status
httpd (pid 10339) is running...</pre>
2)查看進程
<pre style="box-sizing: border-box; font-family: Monaco, Menlo, Consolas, "Courier New", monospace; font-size: 12px; white-space: pre-wrap; display: block; padding: 9.5px; margin: 0px 0px 10px; line-height: 1.38462; color: rgb(51, 51, 51); word-break: break-all; overflow-wrap: break-word; background-color: rgb(245, 245, 245); border: 1px solid rgb(204, 204, 204); border-radius: 4px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-thickness: initial; text-decoration-style: initial; text-decoration-color: initial;">[root@istester www]# ps -ef|grep httpd | grep -v grep
root 10339 1 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10341 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10342 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10343 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10344 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10345 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10346 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10347 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd
apache 10348 10339 0 23:15 ? 00:00:00 /usr/sbin/httpd</pre>
補充,
1)停止服務
service httpd stop
2)重啟服務
service httpd restart
6、安裝之後的說明:
1)驗證是否安裝成功
現在打開 http://ip 地址,看看有沒有Apache的默認頁面出來了?如果有就對了。
2)安裝目錄說明
Apache默認將網站的根目錄指向 /var/www/html
默認的主配置文件是 /etc/httpd/conf/httpd.conf
配置存儲在的/etc/httpd/conf.d/目錄
End
文 / IDO老徐
❷ linux怎麼安裝apache
這是CentOS7編譯安裝方法(或者你也可以yum安裝,這種安裝方法版本較低):
CentOS 下編譯安裝Apache
卸載原有的apache
首先從 http://httpd.apache.or 下載apache源碼包httpd-2.4.4.tar.gz
然後從 http://apr.apache.org 下載apr-1.4.6.tar.gz和apr-util-1.5.1.tar.gz
然後從 http://sourceforge.net/ 下載pcre-8.32.tar.gz和pcre-devel-8.32.tar.gz
先裝gcc和make
yum -y install gcc
yum -y install make
yum -y install gcc-c++ 沒有這個gcc-c++一會編譯不prce
切到下載好的源碼包目錄,本人是~/Download
安裝apr:
tar -zvxf apr-1.4.6.tar.gz
cd apr-1.4.6
./configure --prefix=/usr/local/apr
make && make install
安裝apr-util
tar -zvxf apr-util-1.5.1.tar.gz
cd apr-util-1.5.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make && make install
安裝pcre
tar -zvxf pcre-8.32.tar.gz
cd pcre-8.32
./configure
make && make install
安裝pcre-devel
如果已經安裝好了pcre 一定要安裝
tar –zxvf pcre-devel-8.32.tar.gz
cd pcre-devel-8.32
./configure
make && make install
安裝apache 一定要先裝上面那三個不然編譯不了
tar -zvxf httpd-2.4.4.tar.gz
cd httpd-2.4.4
./configure --prefix=/usr/local/apache –with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
make && make install
配置/usr/local/apache/conf下的http.conf文件(先備份)。
1、伺服器
#ServerName www.example.com:80 前的#號刪除。
2、目錄訪問許可權
<Directory />
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all #修改為此樣
</Directory>
3、默認字元集
AddDefaultCharset utf-8 #指定默認字元集
4、啟動httpd
cd bin/
./apachectl start | restart | stop
將httpd添加為系統服務
cp apachectl /etc/init.d/httpd
/etc/init.d/
編輯httpd,在第二行加入如下信息:
# chkconfig: 345 85 15
# description: Activates/Deactivates Apache Web Server
以上兩句必須添加,否則會提示「httpd服務不支持」;第一行3個數字參數意義分別為:哪些Linux級別需要啟動httpd(3,4,5);啟動序號(85);關閉序號(15)。
添加啟動信息(Ubuntu與CentOS有區別)
chkconfig –add httpd
查看是否添加成功
chkconfig --list
伺服器控制
service httpd start | restart | stop
❸ centos安裝apache mysql php用YUM安裝與編譯安裝有什麼區別
YUM安裝:需要連接網路,依賴庫可以自動補全;
編譯安裝:自己下載安裝包,依賴包要自己補
❹ centos安裝apache mysql php用YUM安裝與編譯安裝有什麼區別
yum安裝方便,內容固定。
編譯安裝內容定製靈活,但手續稍復雜。
❺ 如何在CentOS6下實現Apache+PHP+MySQL的快速安裝
LAMP是一個免費、開源的解決方案,代表了Linux、Apache、MySQL、PHP,主要用作建立可行的通用的web伺服器。那麼如何在CentOS6下實現安裝Apache+php+Mysql的快速安裝?其具體安裝配置步驟可以如下進行:
1.准備工作
使用yum進行安裝,為了提高速度,最好先是修改為中國CentOS鏡像伺服器。目前國內有三個鏡像可以選擇,分別是:中國科學技術大學、163和Sohu的鏡像,建議教育網用戶選擇中科大,電信用戶選擇163
下面命令是備份CentOS-Base.repo文件,並修改使用163鏡像作為yum源:
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.save
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo
mv CentOS6-Base-163.repo /etc/yum.repos.d/CentOS-Base.repo
2.更新系統內核
yum -y update
3.安裝Apahce、Mysql、PHP
yum -y install httpd php mysql mysql-server
默認情況下,mysql數據目錄位於/var/lib/mysql
4.安裝相關組件:
yum install php-mysql php-gd php-imap php-ldap php-odbc
php-pear php-xml php-xmlrpc
5.安裝MySQL管理工具phpMyAdmin
yum -y install phpMyAdmin
6.配置Apache隨系統啟動
chkconfig --levels 235 httpd on
/etc/init.d/httpd start
7.配置MySQL隨系統啟動
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
8.設置資料庫root密碼
/usr/bin/mysqladmin -u root password 'New+Password#www.yupengyan.com'
9.測試PHP是否安裝成功
在 CentOS 中 Apache 的默認根目錄是 /var/www/html,配置文件 /etc/httpd/conf/httpd.conf。其他配置存儲在 /etc/httpd/conf.d/ 目錄。
❻ 如何在linux centos中安裝apache
Apache在Linux系統中,其實叫「httpd」,它「無恥的」占據了官方名義!
CentOS可以使用yum命令,非常簡單和容易的安裝Apache,下面演示一下步驟:
1、安裝Apache
yum install httpd
2、設置Apache服務的啟動級別
chkconfig --levels 235 httpd on
Apache是一個服務,所以,可以通過設置服務的啟動級別來讓它啟動。2,3,5三個級別分別表示什麼意思就不用我多說了吧。
3、現在就啟動它
/etc/init.d/httpd start
安裝之後的說明:
1、驗證是否安裝成功
現在打開http://ip地址,看看有沒有Apache的默認頁面出來了?如果有就對了。
2、安裝目錄介紹
Apache默認將網站的根目錄指向/var/www/html 目錄
默認的主配置文件是/etc/httpd/conf/httpd.conf
配置存儲在的/etc/httpd/conf.d/目錄
❼ centos編譯安裝php7怎麼加入apache
centos編譯安裝php7怎麼加入apache
可以直接下載PHP7.0.2的安裝包解壓,編譯,安裝:
下載php7,並解壓
$ cd /usr/src/
$ wget http://cn2.php.net/distributions/php-7.0.2.tar.gz
#解壓
$ tar -xzxvf php-7.0.2.tar.gz
$ cd php-7.0.2
解壓完後先不要編譯,請檢查是否安裝了gcc ,沒有的話執行yum install gcc
檢查是否安裝了libxml2 ,沒有的話執行yum install libxml2
檢查是否安裝了libxml2-devel,沒有的話執行yum install libxml2-devel
註:因為改為用nginx了,所以編譯參數中的--with-apxs2=/usr/bin/apxs去掉了,如果要配置apache用,安裝PHP前,請先安裝apache。