當前位置:首頁 » 網頁前端 » linux搭建web網站方法
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

linux搭建web網站方法

發布時間: 2022-05-06 07:19:49

❶ 如何在Linux 中搭建一個web伺服器

web伺服器的簡單搭建
1、安裝一個可以提供web服務的軟體
yum -y install httpd

2、 啟動httpd服務
systemctl start httpd

3、進入主配置文件
vim /etc/httpd/conf/httpd.conf

在此范圍內添加或刪除設置,為了方便編寫,編輯了一個子配置文件/etc/httpd/conf.d/httpd-vhosts.conf
4、 編輯子配置文件
vim /etc/httpd/conf.d/httpd-vhosts.conf 此路徑必為conf.d/*.conf (意:為.conf 後綴命名)

systemctl restart httpd 重啟服務

5、 編輯頁面測試文件
在web服務中默認存放網頁文件的路徑:/var/ chaodiquan.com /html
默認網頁文件名字:index.html
6、 瀏覽器測試
ifconfig ens33 查看ens33網卡的地址

在瀏覽器裡面 輸入你的IP就可以看到測試文件里 希望可以幫助到的哈!

❷ 如何在自己的linux伺服器上搭建網站

1.根據機器的用途,許多服務是不需要的。如果Linux只是一個桌面,那麼就不需要sendmail、HTTPD和許多其他服務。

如果您的伺服器只是一個Web伺服器,您還可以關閉許多服務。為此,轉到administration菜單並檢查服務項。只需撤消您不想啟動的任何服務選項。

❸ 如何在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搭建web伺服器

1.開始說明
本教程中使用的IP地址是192.168.0.100,主機名稱為Server1.example.com 這些設置可能會有所不同,你需要根據不同情況進行修改。

CentOS 6.2下安裝MySQL
2.開始安裝MySQL5
首先我們應該先用下面的命令安裝MySQL:
yum install mysql mysql-server
然後我們需要創建MySQL系統的啟動鍵鏈接啟動MySQL伺服器,這樣以便於MySQL在系統啟動時自動啟動
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
為MySQL root帳戶設置密碼
mysql_secure_installation
會出現下面的一系列提示:
root@server1 ~]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MySQL to secure it, we'll need the current
password for the root user. If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.
Set root password? [Y/n] <-- ENTER
New password: <-- yourrootsqlpassword
Re-enter new password: <-- yourrootsqlpassword
Password updated successfully!
Reloading privilege tables..
... Success!
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
proction environment.
Remove anonymous users? [Y/n] <-- ENTER
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] <-- ENTER
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a proction environment.
Remove test database and access to it? [Y/n] <-- ENTER
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] <-- ENTER
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MySQL
installation should now be secure.
Thanks for using MySQL!
[root@server1 ~]#

CentOS 6.2下安裝Apache
3.安裝阿帕奇2
Apache2的是作為一個CentOS的軟體包,因此我們可以直接用下面命令安裝它:
yum install httpd
現在配置系統在引導時啟動Apache
chkconfig --levels 235 httpd on
並啟動Apache
/etc/init.d/httpd start
現在,您的瀏覽器到http://192.168.0.100,你應該看到Apache2的測試頁:

Apache 2測試網頁
Apache的默認文檔根目錄是在CentOS上的/var/www/html 目錄 ,配置文件是/etc/httpd/conf/httpd.conf。配置存儲在的/etc/httpd/conf.d/目錄。
4.安裝PHP5
我們可以用下面的命令來安裝PHP5
yum install php
安裝完需要重啟
/etc/init.d/httpd restart

CentOS 6.2下安裝PHP5
5.我們可以安裝PHP5和Apache的PHP5的模塊如下:
默認網站的文件根目錄是在/srv/www/html中。現在我們將在該目錄中創建一個小型PHP文件(info.php的)在瀏覽器中調用它。該文件將顯示很多關於我們的PHP安裝,如安裝的PHP版本和有用的一些細節。
vi /var/www/html/info.php

修改細節
現在,我們可以用瀏覽器訪問例如http://192.168.0.100/info.php文件

PHP頁面
正如你所看到的,PHP5的工作,它通過Apache 2.0的處理程序,在伺服器API線。如果你繼續向下滾動,你會看到所有在PHP5中已經啟用的模塊。MySQL是沒有列出,這意味著我們沒有在PHP5支持MySQL。
6.PHP5獲得MySOL的支持
讓PHP在MySQL中獲得支持,我們可以安裝的php-mysql軟體包。安裝一些其他的PHP5模塊,以及您可能需要的應用程序,這是一個好主意:
yum search php
還安裝需要安裝的
yum install php-mysql php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc
現在重新啟動Apache2的:
/etc/init.d/httpd restart
現在,重載http://192.168.0.100/info.php在您的瀏覽器,並再次向下滾動到模塊部分。現在,你應該找到許多新的模塊,包括MySQL模塊:

MySQL頁面

CentOS 6.2下安裝phpMyAdmin
7.安裝phpMyAdmin
phpMyAdmin是一個網路介面,通過它可以管理你的MySQL資料庫
首先,我們使CentOS系統RPMForge軟體庫的phpMyAdmin,而不是官方的CentOS 6.2庫:
所以需要導入RPMForge的GPG密鑰:
rpm --import
x86_64系統:
yum install
在i386系統:
yum install
安裝phpmyadmin
yum install phpmyadmin
現在我們可以設置phpMyAdmin,了我們可以改變Apache的配置來讓phpMyAdmin不僅僅只能從localhost登錄。
vi /etc/httpd/conf.d/phpmyadmin.conf

配置
下一步,我們從HTTP改變的phpMyAdmin的cookie來身份驗證:
vi /usr/share/phpmyadmin/config.inc.php

修改身份驗證
重啟阿帕奇
/etc/init.d/httpd restart
在地址欄輸入http://192.168.0.100/phpMyAdmin/:你就可以訪問phpMyAdmin了。

phpmyadmin頁面
CentOS可以得到RHEL的所有功能,甚至是更好的軟體。但CentOS並不向用戶提供商業支持,當然也不負上任何商業責任。
如果你要將你的RHEL轉到CentOS上,因為不希望為RHEL升級而付費。當然,你必須有豐富linux使用經驗,因此RHEL的商業技術支持對你來說並不重要。但如果你是單純的業務型企業,那麼還是建議你選購RHEL軟體並購買相應服務。這樣可以節省你的IT管理費用,並可得到專業服務。

❺ 如何在linux搭建web伺服器

web伺服器常見的是apache和nginx。apache嫌麻煩就直接用軟體管理工具(centos跟小紅帽用yum,ubuntu用apt-get)安裝,也可以到官網下載httpd-2.4.25.tar.gz,解壓並編譯安裝,nginx同理

❻ Linux怎麼搭建Web伺服器

Linux怎麼搭建Web伺服器
1,基於apache的web伺服器基礎搭建:
(1)實驗環境:一台ip為192.168.10.10的rhel5.9主機作為web伺服器,一台ip為192.168.10.15的win7主機作為測試機
(2)查看服務主機軟體是否安裝
[root@ser1 ~]# rpm -q httpd httpd-manual httpd-devel
package httpd is not installed
package httpd-manual is not installed
package httpd-devel is not installed
(3)安裝軟體包
[root@ser1 ~]# yum install -y httpd httpd-manual httpd-devel
(4)啟動服務
[root@ser1 ~]# service httpd start
啟動httpd: [確定]
[root@ser1 ~]# chkconfig httpd on
(5)在win7上測試,無網頁預設下顯示紅帽測試頁
<報錯頁面存放位置/var/www/error/noindex.html>
.jpg
(6)打開配置文件
[root@ser1 ~]# vim /etc/httpd/conf/httpd.conf
可獲得以下重要欄位:
目錄設置:
<Directory 目錄> .. .. </Directory>
訪問位置設置:
<LocationURL> .. .. </Location>
虛擬主機設置:
<VirtualHost 監聽地址> .. .. </VirtualHost>
常用的全局設置參數:
ServerName本站點的FQDN名稱
DocumentRoot網頁文檔的根目錄:預設/var/www/html/
DirectoryIndex默認索引頁/首頁文件:一般設為index.html index.php
ErrorLog錯誤日誌文件的位置
CustomLog 訪問日誌文件的位置
Listen 監聽服務的IP地址、埠號
ServerRoot 服務目錄:/etc/httpd/
Timeout網路連接超時,默認 300 秒
KeepAlive是否保持連接,可選On或Off
MaxKeepAliveRequests每次連接最多處理的請求數
KeepAliveTimeout保持連接的超時時限
Include 可包含其他子配置文件: /etc/httpd/conf.d/
(7)創建測試網頁
[root@ser1 ~]# vim /var/www/html/index.html
<h1>
This is a test page !!!
</h1>
~
(8)win7下測試,主頁變為測試網頁
.jpg
2,基於apache的web伺服器的訪問控制:
(1)web服務的地址限制
I,rder 配置項,定義控制順序
allow,deny 先允許後拒絕,預設拒絕所有;沖突時,拒絕生效;allow不設置,拒絕所有
deny,allow 先拒絕後允許,預設允許所有;沖突時,允許生效;deny不設置,允許所有
II,Allow/Deny from 配置項,設置許可權
Allow from 地址1 地址2 .. ..
Deny from 地址1 地址2 .. ..
配置如下:
[root@ser1 ~]# vim /etc/httpd/conf/httpd.conf
331 #
332 Orderallow,deny
333 Allowfrom 192.168.20.0/24
334
335 </Directory>
[root@ser1 ~]# service httpd restart……重啟服務
停止httpd: [確定]
啟動httpd: [確定]
在win7上測試,測試完成並還原配置文件:
.jpg
看過「 Linux怎麼搭建Web伺服器 」的人還看了:
1.win7如何搭建Web伺服器
2.基於WebRTC的瀏覽器端Web伺服器的研究論文
3.LINUX下配置管理APACHE伺服器的方法
4.如何安全設置Apache Web伺服器
5.全國網路技術水平考試二級實踐指導書

❼ linux怎麼搭建web伺服器

看看 主機筆記 裡面有個搭建網站的文章

❽ 在linux平台怎樣進行網頁web開發

你可以用node, nginx, apache等等做伺服器,前端調試就用瀏覽器。
linux下做Java開發需要搭建java開發環境:jdk是 Java 語言的軟體開發工具包,Tomcat是Java環境下WEB伺服器, Eclipse 是一個開放源代碼的、基於Java的可擴展開發平台;這三個工具,方法如下:
1、JDK的安裝
#執行下面命令安裝JDK(首先創建/opt/java目錄)
tar -xvf jdk-7u9-linux-i586.tar.gz -C /opt/java
ln -s /opt/java/jdk1.7.0_09 /opt/java/jdk //創建一個鏈接
vi /etc/frofile //設置環境變數
export JAVA_HOME=/opt/java/jdk
exprot PATH=$JAVA_HOME/bin:$PATH
#相當於重新設置PATH=JAVA_HOME/bin+PATH
#配置好之後要用命令source /etc/profile
#執行java -version 命令測試一下jdk是否安裝成功
2、tomcat的安裝

#解壓安裝
tar -xvf apache-tomcat-6.0.10.tar.gz -C /opt/tomcat/
ln -s /opt/tomcat/apache-tomcat-6.0.10 /opt/tomcat/tomcat6.0 //創建一個鏈接
cd /opt/tomcat/tomcat6.0/bin
./startup.sh
#打開瀏覽器測試一下,輸入http:localhost:8080,看有沒有貓標識的頁面出來,有的話就說明安裝成功了。
3、eclipse的安裝

gunzip eclipse-java-juno-SR2-linux-gtk.tar.gz
tar -xvf eclipse-java-juno-SR2-linux-gtk.tar -C /opt
#然後去圖形界面進入/opt/eclipse目錄,運行eclipse,就可以打開eclipse界面了。