Centos7.2/Linux的下搭建LAMP環(huán)境的搭建和配置虛擬主機(jī)-創(chuàng)新互聯(lián)

LAMP環(huán)境:LINUX + Apahce的+ MYSQL + PHP的網(wǎng)絡(luò)服務(wù)器環(huán)境。

創(chuàng)新互聯(lián)公司是一家集網(wǎng)站建設(shè),克州企業(yè)網(wǎng)站建設(shè),克州品牌網(wǎng)站建設(shè),網(wǎng)站定制,克州網(wǎng)站建設(shè)報(bào)價(jià),網(wǎng)絡(luò)營(yíng)銷,網(wǎng)絡(luò)優(yōu)化,克州網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強(qiáng)企業(yè)競(jìng)爭(zhēng)力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時(shí)我們時(shí)刻保持專業(yè)、時(shí)尚、前沿,時(shí)刻以成就客戶成長(zhǎng)自我,堅(jiān)持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實(shí)用型網(wǎng)站。

(一)。準(zhǔn)備工作

1.下載并安裝CentOS7.2,配置好網(wǎng)絡(luò)環(huán)境,確保centos能上網(wǎng),可以獲取到y(tǒng)um源(阿里云服務(wù)器已配置好,不需要自己動(dòng)手)
2。配置防火墻,開(kāi)啟21,80,3306端口。 CentOS 7.0默認(rèn)使用的是防火墻作為防火墻,這里改為iptables 防火墻。停止防火墻服務(wù)輸入命令systemctl stop firewalld.service 禁止防火墻開(kāi)機(jī)啟動(dòng)輸入命令systemctl disable firewalld.service 安裝iptables 防火墻輸入命令:yum install iptables-services 編輯防火墻配置文件輸入命令vim / etc / sysconfig / iptables 打開(kāi)后,在-A INPUT -p tcp -m state -state NEW -m tcp -dport 22 -j ACCEPT下方添加:-A INPUT -p tcp -m state -state NEW -m tcp -dport 80 -j ACCEPT -A INPUT -p tcp -m state -state NEW -m tcp -dport 3306 -j ACCEPT 保存退出,最后重啟防火墻使配置生效systemctl restart iptables.service 設(shè)置防火墻開(kāi)機(jī)啟動(dòng)systemctl啟用iptables.service










  1. 關(guān)閉seinux(阿里云已配置好)
    修改配置文件
    vi / etc / selinux / config

SELINUX =強(qiáng)制#注釋掉
SELINUXTYPE =有針對(duì)性#注釋掉
SELINUX =禁用#增加
:wq?。M顺霰4?br/>使配置|立即生效

setenforce 0

(二)。安裝燈環(huán)境
1.安裝apahce (http://www.1jaz.com)
yum install httpd 
設(shè)置apache開(kāi)機(jī)啟動(dòng)
systemctl啟用httpd.service 
重啟apache服務(wù)系統(tǒng)
重啟httpd.service

ps:可能會(huì)用到的:
systemctl start httpd.service#啟動(dòng)apache 
systemctl stop httpd.service #dail止apache 
systemctl restart httpd.service#重啟apache 
systemctl enable httpd.service#settings置apache開(kāi)機(jī)啟動(dòng)

2.安裝mysql(可不安裝)
由于yum源上沒(méi)有mysql-server。所以必須去官網(wǎng)下載,這里我們用wget命令,直接獲取。依次輸入下方三條命令:    
wget http://dev.mysql.com/get /mysql-community-release-el7-5.noarch.rpm    http://www.1jaz.com
rpm -ivh mysql-community-release-el7-5.noarch.rpm 
yum install mysql-community-server

安裝完成后重啟mysql,輸入命令:
systemctl restart mysqld.service

此時(shí)mysql的root用戶沒(méi)有密碼:    
[root @linuxidc -web linuxidc] #mysql -u root

設(shè)置msyql密碼為123456 
mysql>為'root'設(shè)置密碼@'localhost'=密碼('123456');

遠(yuǎn)程連接設(shè)置,所有以root賬號(hào)連接的遠(yuǎn)程用戶,設(shè)其密碼為123456 
mysql>授予所有權(quán)限。來(lái)自'123456'標(biāo)識(shí)的@'%';

更新權(quán)限
mysql>刷新權(quán)限;

退出,mysql 
退回回車

3.安裝php輸入命令:
yum install php 
安裝PHP組件,使用PHP支持mysql輸入命令:
yum install php-mysql php-gd libjpeg * php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php -bcmath php- 
mhash 
重啟對(duì)應(yīng)服務(wù)systemctl重啟mysqld.service 
systemctl restart httpd.service

(三。)配置虛擬主機(jī)
1.創(chuàng)建自定義網(wǎng)站根目錄
mkdir / home / webroot 
2.打開(kāi)httpd主配置文件
vim /etc/httpd/conf/httpd.conf 
3.找到以下代碼


AllowOverride無(wú)

# Allow open access:Require all granted


將其改為:


AllowOverride All

# Allow open access:Require all granted


4.找到以下代碼


# Possible values for the Options directive are "None", "All",# or any combination of:#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews## Note that "MultiViews" must be named *explicitly* --- "Options All"# doesn't give it to you.## The Options directive is both complicated and important.  Please see# http://httpd.apache.org/docs/2.4/mod/core.html#options# for more information.#Options Indexes FollowSymLinks## AllowOverride controls what directives may be placed in .htaccess files.# It can be "All", "None", or any combination of the keywords:#   Options FileInfo AuthConfig Limit#AllowOverride None## Controls who can get stuff from this server.#Require all granted


改為[Options -Indexes為禁止訪問(wèn)目錄列表]:


# Possible values for the Options directive are "None", "All",# or any combination of:#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews## Note that "MultiViews" must be named *explicitly* --- "Options All"# doesn't give it to you.## The Options directive is both complicated and important.  Please see# http://httpd.apache.org/docs/2.4/mod/core.html#options# for more information.#Options Indexes FollowSymLinksOptions -Indexes## AllowOverride controls what directives may be placed in .htaccess files.# It can be "All", "None", or any combination of the keywords:#   Options FileInfo AuthConfig Limit#AllowOverride None## Controls who can get stuff from this server.#Require all granted


5.追加自動(dòng)壓縮網(wǎng)頁(yè)代碼功能,在主配置文件繼續(xù)加入
添加Gzip


SetOutputFilter DEFLATE 
SetEnvIfNoCase Request_URI。(?:gif | jpe?g | png)$ no-gzip不變
SetEnvIfNoCase Request_URI。(?:exe | t?gz | zip | bz2 | sit | rar)$ no-gzip不變
SetEnvIfNoCase Request_URI。(?:pdf | mov | avi | mp3 | mp4 | rm)$ no-gzip不要改變
AddOutputFilterByType DEFLATE text / 
AddOutputFilterByType DEFLATE application / ms application / vnd * application / postscript application / javascript appliction / x-javascript 
AddOutputFilterByType DEFLATE application / x-httpd-php application / x-httpd-fastphp

6.建立一個(gè)項(xiàng)目目錄
mkdir / home / webroot / demo 
7.進(jìn)入apache子配置文件夾,建立對(duì)應(yīng)的項(xiàng)目配置文件
cd /etc/httpd/conf.d 
vim demo.conf 
8.在打開(kāi)的配置文件中,輸入以下代碼


DocumentRoot“/ home / webroot / demo” 
ServerName你的公網(wǎng)IP

ps:如果已經(jīng)申請(qǐng)下域名,則輸入以下代碼(上方作者),允許r-collar.com www.hehaoke.com兩種方式的域名訪問(wèn),并禁止直接訪問(wèn)服務(wù)器IP的方式訪問(wèn)項(xiàng)目

ServerName你的公網(wǎng)IP

訂單允許,拒絕
所有人拒絕



DocumentRoot“/ home / webroot / demo” 
ServerName r-collar.com

DocumentRoot“/ home / webroot / demo” 
ServerName www.hehaoke.com

9.重啟apache 
systemctl重啟httpd.service

注:此方式是基于端口實(shí)現(xiàn)的虛擬主機(jī),如要添加新端口來(lái)訪問(wèn)新項(xiàng)目,還需要注意去主配置文件httpd.conf中給新端口添加監(jiān)聽(tīng),并在防火墻中允許新端口的訪問(wèn)。

更多:http://www.1jaz.com

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。

當(dāng)前文章:Centos7.2/Linux的下搭建LAMP環(huán)境的搭建和配置虛擬主機(jī)-創(chuàng)新互聯(lián)
網(wǎng)頁(yè)網(wǎng)址:http://muchs.cn/article14/dcppge.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT網(wǎng)站導(dǎo)航、自適應(yīng)網(wǎng)站、外貿(mào)建站、用戶體驗(yàn)、靜態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

外貿(mào)網(wǎng)站建設(shè)