佳木斯湛栽影视文化发展公司

主頁(yè) > 知識(shí)庫(kù) > CentOS使用本地yum源搭建LAMP環(huán)境圖文教程

CentOS使用本地yum源搭建LAMP環(huán)境圖文教程

熱門(mén)標(biāo)簽:智能手機(jī) 使用U盤(pán)裝系統(tǒng) 阿里云 百度競(jìng)價(jià)點(diǎn)擊價(jià)格的計(jì)算公式 美圖手機(jī) 網(wǎng)站建設(shè) 檢查注冊(cè)表項(xiàng) 硅谷的囚徒呼叫中心

本文實(shí)例講述了CentOS使用本地yum源搭建LAMP環(huán)境。分享給大家供大家參考,具體如下:

【準(zhǔn)備工作】

配置防火墻,開(kāi)啟80端口、3306端口

vi /etc/sysconfig/iptables

如圖,添加下面兩條:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT #允許80端口通過(guò)防火墻

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT #允許3306端口通過(guò)防火墻

重啟防火墻使配置生效

/etc/init.d/iptables restart

關(guān)閉SELINUX

vi /etc/selinux/config

#SELINUX=enforcing #注釋掉
#SELINUXTYPE=targeted #注釋掉
SELINUX=disabled #增加
:wq! #保存退出

重啟系統(tǒng)

shutdown -r now

【安裝Apache】

執(zhí)行安裝

yum -y install httpd

啟動(dòng)Apache

service httpd restart

或:

/etc/init.d/httpd start

Apache啟動(dòng)之后會(huì)提示錯(cuò)誤Could not reliably determine the server's fully qualifdomain name, using ::1 for ServerName,解決方法:

vi /etc/httpd/conf/httpd.conf

找到 #ServerName www.example.com:80
修改為 ServerName www.lws.com:80  (設(shè)置為自己的域名 或 ServerName localhost:80
:wq!#保存退出

設(shè)為開(kāi)機(jī)啟動(dòng)

chkconfig httpd on

檢查安裝 訪(fǎng)問(wèn)主機(jī)地址 如圖所示安裝成功

修改Apache配置

vi /etc/httpd/conf/httpd.conf #建議使用ftp工具 修改之前做好備份

修改如下:

ServerTokens OS  #在44行 修改為:ServerTokens Prod (在出現(xiàn)錯(cuò)誤頁(yè)的時(shí)候不顯示服務(wù)器操作系統(tǒng)的名稱(chēng))
ServerSignature On  #在536行修改為:ServerSignature Off (在錯(cuò)誤頁(yè)中不顯示Apache的版本)
Options Indexes FollowSymLinks  #在331行修改為:Options Includes ExecCGI FollowSymLinks(允許服務(wù)器執(zhí)行CGI及SSI,禁止列出目錄)
#AddHandler cgi-script .cgi #在796行 修改為:AddHandler cgi-script .cgi .pl (允許擴(kuò)展名為.pl的CGI腳本運(yùn)行)
AllowOverride None  #在338行修改為:AllowOverride All (允許.htaccess)
AddDefaultCharset UTF-8 #在759行 修改為:AddDefaultCharset GB2312?。ㄌ砑覩B2312為默認(rèn)編碼)
Options Indexes MultiViews FollowSymLinks #在554行 修改為Options MultiViews FollowSymLinks(不在瀏覽器上顯示樹(shù)狀目錄結(jié)構(gòu))
DirectoryIndex index.html index.html.var #在402行 修改為:DirectoryIndexindex.html index.htm Default.html Default.htm index.php Default.phpindex.html.var (設(shè)置默認(rèn)首頁(yè)文件,增加index.php)
KeepAlive Off #在76行 修改為:KeepAlive On (允許程序性聯(lián)機(jī))
MaxKeepAliveRequests 100 #在83行 修改為:MaxKeepAliveRequests1000 (增加同時(shí)連接數(shù))

刪除兩個(gè)默認(rèn)測(cè)試頁(yè)

rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html

重啟Apache

service httpd restart

/etc/init.d/httpd restart

【安裝MySQL】

執(zhí)行安裝

yum -y install mysql mysql-server

啟動(dòng)MySQL

/etc/init.d/mysqld start

設(shè)為開(kāi)機(jī)啟動(dòng)

chkconfig mysqld on

拷貝配置文件(注意:如果/etc目錄下面默認(rèn)有一個(gè)my.cnf,直接覆蓋即可)

cp /usr/share/mysql/my-medium.cnf /etc/my.cnf

為root賬戶(hù)設(shè)置密碼

mysql_secure_installation
#回車(chē),根據(jù)提示輸入Y,輸入2次密碼,回車(chē),根據(jù)提示一路輸入Y最后出現(xiàn):Thanks for using MySQL設(shè)置完成

或者

mysqladmin -u root password '密碼'

允許遠(yuǎn)程登錄

mysql -u root -p

輸入密碼
輸入mysql命令:

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '密碼' WITH GRANT OPTION;

退出mysql:exit

重啟MySQL

service mysqld restart

【安裝PHP5】

執(zhí)行安裝

yum -y install php

安裝PHP組件(這里選擇以下安裝包,根據(jù)提示輸入Y回車(chē)安裝)

復(fù)制代碼 代碼如下:
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

修改PHP配置

vi /etc/php.ini #建議使用ftp工具 修改之前做好備份

修改如下:

date.timezone= PRC #在946行 把前面的分號(hào)去掉,改為date.timezone = PRC

復(fù)制代碼 代碼如下:
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可以禁用的函數(shù),如果某些程序需要用到這個(gè)函數(shù),可以刪除,取消禁用。

expose_php = Off #在432行 禁止顯示php版本的信息

magic_quotes_gpc = On #在745行 打開(kāi)magic_quotes_gpc來(lái)防止SQL注入

short_open_tag = On #在229行支持php短標(biāo)簽

open_basedir = .:/tmp/
#在380行 設(shè)置表示允許訪(fǎng)問(wèn)當(dāng)前目錄(即PHP腳本文件所在之目錄)和/tmp/目錄,可以防止php木馬跨站,如果改了之后安裝程序有問(wèn)題,可以注銷(xiāo)此行,或者直接寫(xiě)上程序的目錄/data/www.osyunwei.com/:/tmp/

重啟MySQL、Apahe

service mysqld restart
service httpd restart

(到此完成yum源搭建LAMP環(huán)境,我們可以查看一下各部分的安裝版本)

查看Apache版本

httpd -v

查看PHP版本

php –v

查看MySQL版本

mysql -V 

(注意大寫(xiě))

希望本文所述對(duì)大家CentOS服務(wù)器配置有所幫助。

標(biāo)簽:懷化 賀州 湘潭 湖北 煙臺(tái) 黃山 山南 通遼

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《CentOS使用本地yum源搭建LAMP環(huán)境圖文教程》,本文關(guān)鍵詞  ;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 收縮
    • 微信客服
    • 微信二維碼
    • 電話(huà)咨詢(xún)

    • 400-1100-266
    泗阳县| 永济市| 鄂尔多斯市| 固原市| 凯里市| 株洲县| 武义县| 华坪县| 龙川县| 建平县| 洛南县| 瑞安市| 邳州市| 太和县| 嘉鱼县| 谷城县| 南和县| 华宁县| 吉首市| 呼图壁县| 邮箱| 南阳市| 青河县| 宜城市| 安溪县| 嵩明县| 柳州市| 五指山市| 北辰区| 长岭县| 竹北市| 类乌齐县| 大荔县| 四子王旗| 贵德县| 耒阳市| 同心县| 孝昌县| 昆山市| 永康市| 山阳县|