當前位置:首頁 » 雲伺服器 » linux搭建apache伺服器搭建

linux搭建apache伺服器搭建

發布時間: 2022-02-11 22:16:49

❶ 怎麼在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 :80 中的「#」刪掉,並將 改為本機的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的測試頁面, your_linux_ip/ 如圖所示 如果出現it works字樣,說明apache安裝成功

❷ 在Linux上搭建web伺服器和Apache伺服器的區別

apache 是在 linux上 是有那個最廣泛的 web伺服器!
另外 現在nginx 發展也非常迅猛。
apache nginx 都是提供 web server' 的軟體。

❸ 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的配置修改

❹ 如何在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

❻ 如何在linux搭建完整的web伺服器

可以參考如下Web伺服器的建立過程。示例環境及web伺服器軟體:

Ubuntu 12.04
LAMP(Linux,Apache,Mysql,PHP)

1、安裝Apache

(1)在安裝HTTP Server之前需安裝APR(Apache Portable Runtime)和APR-util安裝APR
$ tar zxvf apr-1.4.6.tar.gz
$ cd apr-1.4.6/
$ ./configure
$ make
$ sudo make install

(2)安裝APR-util

$ tar zxvf apr-util-1.4.1.tar.gz
$ cd apr-util-1.4.1
$ ./configure –with-apr=/usr/local/apr (whereis apr)
$ make
$ sudo make install

(3)安裝httpd-2.4.2.tar.bz2默認安裝位置/usr/local/apache2網頁放在/usr/local/apache2/htdocs配置文件/usr/local/apache2/conf/httpd.conf

$ tar jxvf httpd-2.4.2.tar.bz2
$ cd httpd-2.4.2/
$ ./configure
$ make
$ sudo make install

(4)啟動HTTP Server$ sudo /usr/local/apache2/bin/apachectl startAH00558: httpd: Could not reliably determine the server』s fully qualified domain name, using 127.0.1.1. Set the 『ServerName』 directive globally to suppress this message

(5)查看http是否正常運行$ netstat -a | grep httptcp 0 0 *:http *:* LISTEN

(6)在瀏覽器輸入127.0.0.1如果正常應該顯示「It works!」

2、安裝MySQL

(1)、下載安裝mysql-5.5.25.tar.gz,默認安裝位置/usr/local/mysql/

$ tar zxvf mysql-5.5.25.tar.gz
$ cd mysql-5.5.25/
$ sudo groupadd mysql
$ sudo useradd -r -g mysql mysql
$ cmake .
$ make
$ sudo make install
$ cd /usr/local/mysql/
$ sudo chown -R mysql .
$ sudo chgrp -R mysql .
$ sudo scripts/mysql_install_db –user=mysql
$ sudo chown -R root .
$ sudo chown -R mysql data/
$ sudo cp support-files/my-medium.cnf /etc/my.cnf
$ sudo cp support-files/mysql.server /etc/init.d/mysql.server

(2)、啟動MySQL:
方法1:$ sudo service mysql.server start
方法2:$ sudo /usr/local/mysql/bin/mysqld_safe --user=mysql &

3、安裝PHP

(1)安裝下載php-5.4.4.tar.gz

$ tar zxvf php-5.4.4.tar.gz
$ cd php-5.4.4
$ ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql --with-mysqli --enable-mbstring --with-mcrypt(可能需要安裝libmcrypt-dev )
$ sudo make install
$ sudo cp php.ini-development /usr/local/lib/php.ini

(2)配置HTTP Server使之支持PHPapache配置文件/usr/local/apache2/conf/httpd.conf修改或添加如下配置

<;IfMole dir_mole>
DirectoryIndex index.php
<;/IfMole>
<;FilesMatch \.php$>
SetHandler application/x-httpd-php
<;/FilesMatch>

(3)重啟HTTP Server
$ sudo /usr/local/apache2/bin/apachectl restart

❼ 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

#<VirtualHost *>
# ServerAdmin [email protected] //管理員的郵箱地址吧,你可以寫自己的
# DocumentRoot /www/docs/mmy-host.example.com //這個應該填你的主頁
# ServerName mmy-host.example.com //這就是DNS了吧
# ErrorLog logs/mmy-host.example.com-error_log //記錄錯誤日誌的路徑,因該是生成一個文件
# CustomLog logs/mmy-host.example.com-access_log common //日誌文件
#</VirtualHost>
拷貝要發布目錄到 var/www/html

❾ 怎樣在linux 上搭建git +apache伺服器

1:伺服器端創建用戶(git)
# sudo adsergit
2:客戶端生成公鑰,並
創建公鑰:ssh-keygen,
在客戶端的用戶目錄下查看生成的公鑰和私鑰對
#cd ~/.ssh
#ls
id_dsa id_dsa.pub

公鑰所在的目錄:windows在」C:/User/username/.ssh」目錄下,linux在」~/.ssh」,~代表用戶目錄
3:伺服器git用戶下添加各個用戶公鑰,並配置ssh服務
將各個用戶的公鑰文件追加在伺服器git用戶的authorized_keys文件中
$ cat id_rsa.john.pub >> ~/.ssh/authorized_keys
$ cat id_rsa.josie.pub >> ~/.ssh/authorized_keys
$ cat id_rsa.jessica.pub >> ~/.ssh/authorized_keys
修改.ssh和authorized_keys的許可權).忘記下面的話,會每次輸入密碼,(ps,被這個坑了好久)
chmod 700 ~/.ssh
chmod 600 ~/.ssh/authorized_keys

4,在git用戶下創建git庫
cd gitDIR
mkdir project.git
cd project.git
git init –bare
5,客戶端使用
提交自己的庫
mkdir project
cd project
git init
vi first.txt
git remote add origin gitserver/gitDIR/project.git
git push origin master
克隆:git clonegit@gitserver/gitDIR/project.git
6,限制開發者登陸
默認情況下,能夠連接git伺服器用戶也可以通過ssh直接登陸伺服器,那麼伺服器將會存在被多用戶登入的風險,限制的方法是:
Vi /etc/passwd

git:x:1000:1000::/home/git:/bin/sh

該行修改後的樣子如下:
git:x:1000:1000::/home/git:/bin/git-shell

❿ 如何在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 -

熱點內容
單片機android 發布:2024-09-20 09:07:24 瀏覽:765
如何提高三星a7安卓版本 發布:2024-09-20 08:42:35 瀏覽:664
如何更換伺服器網站 發布:2024-09-20 08:42:34 瀏覽:311
子彈演算法 發布:2024-09-20 08:41:55 瀏覽:289
手機版網易我的世界伺服器推薦 發布:2024-09-20 08:41:52 瀏覽:817
安卓x7怎麼邊打游戲邊看視頻 發布:2024-09-20 08:41:52 瀏覽:162
sql資料庫安全 發布:2024-09-20 08:31:32 瀏覽:94
蘋果連接id伺服器出錯是怎麼回事 發布:2024-09-20 08:01:07 瀏覽:507
編程鍵是什麼 發布:2024-09-20 07:52:47 瀏覽:658
學考密碼重置要求的證件是什麼 發布:2024-09-20 07:19:46 瀏覽:481