Ⅰ 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
Ⅱ Linux伺服器Apache怎麼安裝
解決方法:
安裝准備工作
登錄linux(root/123456)
利用netconfig命令設置IP地址等信息
(1)——設置IP、子網掩碼、網關、主DNS
(2)——service network restart 重啟網路服務使修改生效
也可以通過修改文件進行設置
vi /etc/sysconfig/network-scripts/ifcfg-eth0 設置IPADDR=IP地址,NETMASK=掩碼,ONBOOT=YES,啟動時啟動網卡 vi /etc/resolv.conf 設置DNS
設置完成後通過ifconfig命令可以查看當前系統的網路信息
通過SecurCRT工具鏈接到linux下
通過Zmodem Upload List添加需要從本地傳輸到linux下的文件,然後執行Start Zmodem Upload啟動傳輸。
APACHE的安裝
[root@sugar ~]# gzip -d httpd-2.2.4.tar.gz[root@sugar ~]# tar xvf httpd-2.2.4.tar
[root@sugar ~]# cd httpd-2.2.4
[root@sugar ~]# ./configure
[root@sugar ~]# make
[root@sugar ~]# make install
apache默認安裝路徑:/usr/local/apache2
/usr/local/apache2下面關鍵目錄說明
conf :apache伺服器的配置目錄
htdocs: 需要發布應用程序的目錄
bin : apache伺服器的可執行程序目錄
apache的配置修改
[root@sugar ~]# vi /usr/local/apache2/conf/httpd.conf
將#ServerName www.example.com:80 中的「#」刪掉,並將 www.example.com 改為本機的linux的ip地址
apache服務安裝檢測
apache安裝是否成功的檢測
啟動apache服務
說明:apache服務的啟動和停止
[root@sugar ~]# cd /usr/local/apache2/bin
[root@sugar ~]# ./apachectl stop 這是停止apache服務
[root@sugar ~]# ./apachectl start 這是啟動apache服務
在window平台通過ie訪問linux上面apache的測試頁面,
http://your_linux_ip/ 如圖所示
如果出現it works字樣,說明apache安裝成功
Ⅲ linux命令怎麼安裝apache
以Centos為例:
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
Ⅳ linux apache安裝啟動APACHE報錯
看到你的報錯是 iptables 防火牆的問題。應該和apache 沒有關系。咱們慢慢說說吧。
Linux下面的apache 最簡單的方法就是用yum 來安裝,服務的名稱是httpd,yum倉庫要可用。
yum -y install httpd
service httpd start \\啟動httpd服務
chkconfig httpd on \\設置httpd 開啟自啟
關於Linux下的防火牆iptables 是這樣的,默認情況下只需要在iptables的默認表也就是netfile表中添加tcp 的80埠就可以了。
netfile有三條鏈:
INPUT、OUTPUT、FORWORD
從名字上面就可以看出分別是入站,出站,和轉發的表
iptables 的使用方法:
iptables -t 表名 -I/A/D 鏈名 [-p tcp/udp/icmp/grep... -s -d -i -o] -j 動作
添加tcp的80埠可以這樣寫:
iptables -A INPUT -p tcp --dport 80 -j ACCEPT
注意iptables的書寫順序不同 效果就不同。所以我經常做的是:
iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT (要根據實際情況)
service iptables save 保存就可以了。
關於apache 和iptables 建議參考www.linuxprobe.com的相關介紹,學習Linux要有一個清晰的思路,然後多多聯系就可以了。找對關鍵很重要,加油吧!!
Ⅳ linux命令怎麼安裝apache
以Centos為例:
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
Ⅵ linux yum 安裝 apache 怎麼啟動
安裝:yum install -y httpd
啟動: service httpd start
Ⅶ 如何在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/目錄
Ⅷ 您好,想請教下怎麼在 linux(centos 7)中配置安裝apache伺服器
安裝Apache
yuminstallhttpd#根據提示,輸入Y安裝即可成功安裝
systemctlstarthttpd.service#啟動apache
systemctlstophttpd.service#停止apache
systemctlrestarthttpd.service#重啟apache
systemctlenablehttpd.service#設置apache開機啟動
在客戶端瀏覽器中打開伺服器IP地址,會出現下面的界面,說明apache安裝成功
Ⅸ 如何在Linux下搭建apache伺服器
准備篇:
1、配置防火牆,開啟80埠、3306埠
vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #允許80埠通過防火牆
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #允許3306埠通過防火牆
備註:很多網友把這兩條規則添加到防火牆配置的最後一行,導致防火牆啟動失敗,
正確的應該是添加到默認的22埠這條規則的下面
如下所示:
############################## 添加好之後防火牆規則如下所示 ##############################
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
##################################################################################################
/etc/init.d/iptables restart #最後重啟防火牆使配置生效
2、關閉SELINUX
vi /etc/selinux/config
#SELINUX=enforcing #注釋掉
#SELINUXTYPE=targeted #注釋掉
SELINUX=disabled #增加
:wq #保存,關閉
shutdown -r now #重啟系統
安裝篇:
一、安裝Apache
yum install httpd #根據提示,輸入Y安裝即可成功安裝
/etc/init.d/httpd start #啟動Apache
備註:Apache啟動之後會提示錯誤:
正在啟動 httpd:httpd: Could not reliably determine the server's fully qualif domain name, using ::1 for ServerName
解決辦法:
vi /etc/httpd/conf/httpd.conf #編輯
找到 #ServerName
修改為 ServerName #這里設置為你自己的域名,如果沒有域名,可以設置為localhost
:wq! #保存退出
chkconfig httpd on #設為開機啟動
/etc/init.d/httpd restart #重啟Apache
二、安裝MySQL
1、安裝MySQL
yum install mysql mysql-server #詢問是否要安裝,輸入Y即可自動安裝,直到安裝完成
/etc/init.d/mysqld start #啟動MySQL
chkconfig mysqld on #設為開機啟動
cp /usr/share/mysql/my-medium.cnf /etc/my.cnf #拷貝配置文件(注意:如果/etc目錄下面默認有一個my.cnf,直接覆蓋即可)
2、為root賬戶設置密碼
mysql_secure_installation
回車,根據提示輸入Y
輸入2次密碼,回車
根據提示一路輸入Y
最後出現:Thanks for using MySQL!
MySql密碼設置完成,重新啟動 MySQL:
/etc/init.d/mysqld restart #重啟
/etc/init.d/mysqld stop #停止
/etc/init.d/mysqld start #啟動
三、安裝php5
1、安裝PHP5
yum install php
根據提示輸入Y直到安裝完成
2、安裝PHP組件,使 PHP5 支持 MySQL
yum install php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt
這里選擇以上安裝包進行安裝
根據提示輸入Y回車
/etc/init.d/mysqld restart #重啟MySql
/etc/init.d/httpd restart #重啟Apche
配置篇
一、Apache配置
vi /etc/httpd/conf/httpd.conf #編輯文件
ServerTokens OS 在44行 修改為:ServerTokens Prod (在出現錯誤頁的時候不顯示伺服器操作系統的名稱)
ServerSignature On 在536行 修改為:ServerSignature Off (在錯誤頁中不顯示Apache的版本)
Options Indexes FollowSymLinks 在331行 修改為:Options Includes ExecCGI FollowSymLinks(允許伺服器執行CGI及SSI,禁止列出目錄)
#AddHandler cgi-script .cgi在796行 修改為:AddHandler cgi-script .cgi .pl (允許擴展名為.pl的CGI腳本運行)
AllowOverride None 在338行 修改為:AllowOverride All (允許.htaccess)
AddDefaultCharset UTF-8在759行 修改為:AddDefaultCharset GB2312(添加GB2312為默認編碼)
Options Indexes MultiViews FollowSymLinks 在554行 修改為 Options MultiViews FollowSymLinks(不在瀏覽器上顯示樹狀目錄結構)
DirectoryIndex index.html index.html.var 在402行 修改為:DirectoryIndex index.html index.htm Default.html Default.htm
index.php Default.php index.html.var (設置默認首頁文件,增加index.php)
KeepAlive Off 在76行 修改為:KeepAlive On (允許程序性聯機)
MaxKeepAliveRequests 100 在83行 修改為:MaxKeepAliveRequests 1000 (增加同時連接數)
:wq! #保存退出
/etc/init.d/httpd restart #重啟
rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html #刪除默認測試頁
二、php配置
vi /etc/php.ini #編輯
date.timezone = PRC #在946行 把前面的分號去掉,改為date.timezone = PRC
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#在386行 列出PHP可以禁用的函數,如果某些程序需要用到這個函數,可以刪除,取消禁用。
expose_php = Off #在432行 禁止顯示php版本的信息
magic_quotes_gpc = On #在745行 打開magic_quotes_gpc來防止SQL注入
short_open_tag = ON #在229行支持php短標簽
open_basedir = .:/tmp/ #在380行 設置表示允許訪問當前目錄(即PHP腳本文件所在之目錄)和/tmp/目錄,可以防止php木馬跨站,如果改了之後安裝程序有問題(例如:織夢內容管理系統),可以注銷此行,或者直接寫上程序的目錄/data/
:wq! #保存退出
/etc/init.d/mysqld restart #重啟MySql
/etc/init.d/httpd restart #重啟Apche
測試篇
cd /var/www/html
vi index.php #輸入下面內容
<?php
phpinfo();
?>
:wq! #保存退出
在客戶端瀏覽器輸入伺服器IP地址,可以看到如下圖所示相關的配置信息!
注意:apache默認的程序目錄是/var/www/html
許可權設置:chown apache.apache -R /var/www/html
至此,CentOS 6.4安裝配置LAMP伺服器(Apache+PHP5+MySQL)教程完成!
Ⅹ 如何利用linux 安裝apache 伺服器的配置與管理
接下來就要試試動手安裝Apache服務程序啦,同學們需要注意使用yum命令安裝軟體時後面寫的是服務程序的名字,而apache服務的軟體包名稱叫做httpd,直接執行yum install apache命令則是會報錯誤的。
[root@linuxprobe ~]# yum install httpd
將httpd服務程序啟動並加入到開機啟動項中,讓Web服務程序能夠隨系統開機而啟動運行:
[root@linuxprobe~]#systemctlstarthttpd
[root@linuxprobe~]#systemctlenablehttpd
ln-s'/usr/lib/systemd/system/httpd.service''/etc/systemd/system/multi-user.target.wants/httpd.service'
#http://www.linuxprobe.com/chapter-10.html#101