Linux服務(wù)器上安裝織夢(mèng)CMS,linux服務(wù)器織夢(mèng)cms
Jul 06, 2016 pm 02:25 PMLinux服務(wù)器上安裝織夢(mèng)CMS,linux服務(wù)器織夢(mèng)cms
安裝篇
第一步:配置防火墻(默認(rèn)情況下,端口80和3306是拒絕訪(fǎng)問(wèn)的,在防火墻上進(jìn)行配置):
- vi?/etc/sysconfig/iptables(在"COMMIT"的上一行加上如下兩句)?
- -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?
第二步:安裝Apache
?
使用以下命令安裝Apache:
- yum?install?httpd?
如果出下下面所示的語(yǔ)句,說(shuō)明已經(jīng)安裝了Apache了,不需要重新安裝:
?
安裝完之后,重新啟動(dòng)Apache:/etc/init.d/httpd restart
接著將Apache設(shè)置為開(kāi)機(jī)啟動(dòng):chkconfig httpd on.(這一步使得服務(wù)器不需要在每次重啟的時(shí)候都要手動(dòng)啟動(dòng)httpd服務(wù))
要查看httpd服務(wù)的啟動(dòng)狀態(tài),可以使用命令:chkconfig --list httpd(會(huì)顯示httpd在各個(gè)級(jí)別(level)下的啟動(dòng)狀態(tài))
第三步:安裝MySQL
1、使用以下命令安裝MySQL:
- yum?install?mysql?mysql-server?
同樣,如果出現(xiàn)提示已安裝的話(huà),就說(shuō)明系統(tǒng)安裝了MySQL了,可以跳過(guò)這一步,否則,系統(tǒng)接下來(lái)會(huì)自動(dòng)安裝MySQL。
?
安裝完成了之后,啟動(dòng)MySQL:/etc/init.d/mysql start
將MySQL設(shè)置為開(kāi)機(jī)啟動(dòng):chkconfig mysqld on
最后,拷貝配置文件:cp /usr/share/mysql/my-medium.cnf? /etc/my.cnf (在/etc下有個(gè)my.cnf文件,直接覆蓋就行了)
2、用以下命令給root賬戶(hù)設(shè)置密碼? ? ?
- mysql_secure_installation?
根據(jù)提示輸入2次密碼,就設(shè)置成功了。注意,在設(shè)置過(guò)程中,會(huì)提示刪除是否anonymous用戶(hù),是否拒絕root的遠(yuǎn)程訪(fǎng)問(wèn),是否刪除測(cè)試用的數(shù)據(jù)庫(kù)等,這些都需要根據(jù)自己的實(shí)際情況進(jìn)行選擇。最后出現(xiàn):Thanks for using MySQL!,設(shè)置密碼成功了。
?
重新啟動(dòng)MySQL:/etc/init.d/mysqld restart
第四步:安裝PHP
1、使用以下命令安裝PHP:
- yum?install?php?
?
根據(jù)提示往下安裝就行了。安裝完之后重新啟動(dòng)Apache:/etc/init.d/httpd restart
2、安裝PHP組件,是PHP支持MySQL
可以使用命令:yum search php來(lái)查看PHP的組件,選擇需要的模塊進(jìn)行安裝:
?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
安裝完之后,重啟Apache:/etc/init.d/httpd restart?
重啟MySQL:/etc/init.d/mysqld restart
?
到了這一步,LAMP中的AMP都已經(jīng)安裝完畢了,但是web服務(wù)器此時(shí)并不能被訪(fǎng)問(wèn),因?yàn)橐L(fǎng)問(wèn)服務(wù)器,還需要對(duì)Apache和PHP進(jìn)行相應(yīng)的配置。
配置篇
第一步:配置Apache
修改Apache配置文件:vi /etc/httpd/conf/httpd.conf,并在文件中查找下面所在行,進(jìn)行修改(查找可以在vi的一般模式下輸入“/要查找的字符”進(jìn)行查找):
ServerTokens OS ? ? ? ? ? 修改為: ? ? ServerTokens Prod ? ? ? ? ? ? ? ? ? ? ? (在出現(xiàn)錯(cuò)誤頁(yè)的時(shí)候不顯示服務(wù)器操作系統(tǒng)的名稱(chēng))
ServerSignature On ? ? ? ?修改為: ? ? ServerSignature Off ? ? ? ? ? ? ? ? ? ? ?(在錯(cuò)誤頁(yè)中不顯示Apache的版本)
Options Indexes FollowSymLinks ? ? 修改為: ? ? Options Includes ExecCGI FollowSymLinks ? ? ? ? ? ? (允許服務(wù)器執(zhí)行CGI及SSI,禁止列出目錄)
#AddHandler cgi-script .cgi ? ? ? ? ?修改為: ? ? AddHandler cgi-script .cgi .pl ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (允許擴(kuò)展名為.pl的CGI腳本運(yùn)行)
AllowOverride None ? ? ? ? ? ? ? ? ? ? 修改為: ? ? AllowOverride All ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? (允許.htaccess)
AddDefaultCharset UTF-8 ? ? ? ? ? 修改為: ? ? AddDefaultCharset GB2312 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(添加GB2312為默認(rèn)編碼)
Options Indexes MultiViews FollowSymLinks ? ? ?修改為 ? ? ?Options MultiViews FollowSymLinks ? ? ? ?(不在瀏覽器上顯示樹(shù)狀目錄結(jié)構(gòu))
DirectoryIndex index.html index.html.var ? ? ? ? ? ? 修改為: ?DirectoryIndex index.html index.htm Default.html Default.htm index.php Default.php index.html.var? (設(shè)置默認(rèn)首頁(yè)文件,增加index.php)
KeepAlive Off ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?修改為: ? ? KeepAlive On ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?(允許程序性聯(lián)機(jī))
MaxKeepAliveRequests 100 ? ? ? ? ? 修改為: ? ? MaxKeepAliveRequests 1000 ? (增加同時(shí)連接數(shù))
?
修改好之后保存配置,重新啟動(dòng)Apache:/etc/init.d/httpd restart
建議刪除默認(rèn)的測(cè)試頁(yè)面:rm -f /etc/httpd/conf.d/welcome.conf /var/www/error/noindex.html?
第二步:配置PHP
修改PHP配置文件:vi /etc/php.ini,以下需要修改的行的位置可以通過(guò)vi的查找命令來(lái)查找:
date.timezone = PRC ? ? ? ? ? ? ? ? ? ?#把前面的分號(hào)去掉,改為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
#列出PHP可以禁用的函數(shù),如果某些程序需要用到這個(gè)函數(shù),可以刪除,取消禁用。
expose_php = Off ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #禁止顯示php版本的信息
display_errors = OFF ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #關(guān)閉錯(cuò)誤提示
register_globals = OFF ? ? ? ? ? ? ? ? ? ? ? ? ? #關(guān)閉注冊(cè)全局變量
magic_quotes_gpc = On ? ? ? ? ? ? ? ? ? ? ? ?#打開(kāi)magic_quotes_gpc來(lái)防止SQL注入
log_errors = On ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #記錄錯(cuò)誤日志
error_log = /var/log/php/error_log.log ? #設(shè)置錯(cuò)誤日志存放目錄,文件必須允許apache用戶(hù)的和組具有寫(xiě)的權(quán)限(注意,在修改之前,要先創(chuàng)建文件/var/log/php/error_log.log,然后在修改其屬性,使其屬于apache用戶(hù)和用戶(hù)組。chown apache /var/log/php/error_log.log和chgrp apache?/var/log/php/error_log.log)
open_basedir = .:/tmp/ ? ? ? ? ? ? ? ? ? ? ? ? ? ? #設(shè)置表示允許訪(fǎng)問(wèn)當(dāng)前目錄(即PHP腳本文件所在之目錄)和/tmp/目錄,可以防止php木馬跨站
?
經(jīng)過(guò)安裝和配置之后,web服務(wù)器基本上已經(jīng)搭建起來(lái)了,可以對(duì)其進(jìn)行訪(fǎng)問(wèn)。
?
測(cè)試篇
在目錄/var/www/html下:cd /var/www/html
創(chuàng)建php文件:vi index.php
phpinfo();
?>
那么,在瀏覽器中輸入本機(jī)地址的時(shí)候,就可以訪(fǎng)問(wèn)到剛才創(chuàng)建的index.php網(wǎng)頁(yè)文件了。
注意:apache的默認(rèn)程序目錄是:/var/www/html,網(wǎng)頁(yè)文件放在這里就可以被訪(fǎng)問(wèn)到。需要保證這個(gè)目錄是屬于用戶(hù)apache和用戶(hù)組apache的。
? ? ? ? ? ? ?MySQL的數(shù)據(jù)庫(kù)目錄是:/var/lib/mysql
?
寫(xiě)到這里,LAMP就安裝配置完畢了,瀏覽器只要輸入服務(wù)器的IP地址或者是域名的話(huà),就能夠訪(fǎng)問(wèn)到服務(wù)器上的網(wǎng)頁(yè)文件了。
有錯(cuò)漏的地方,歡迎大家隨時(shí)指出修改意見(jiàn),謝謝大家的支持。
Linux系統(tǒng)中常用的命令:
?
一、Linux常用命令
1.1.權(quán)限分配chmod命令
chmod 777 dir/file
1.2.參考鏈接
1.http://blog.sina.com.cn/s/blog_3fe048830100gp0e.html
二、對(duì)mysql數(shù)據(jù)庫(kù)常用操作命令
2.1.修改MySQL字符集
1.修改my.cnf
vi /etc/my.cnf
在[client]下添加
default-character-set=utf8
在[mysqld]下添加
default-character-set=utf8
2.重新啟動(dòng)MySQL
service mysqld restart
3.查看字符集設(shè)置
show variables like 'character_set_%';
2.2.其他的一些設(shè)置方法
1.修改數(shù)據(jù)庫(kù)的字符集
mysql>use mydb
mysql>alter database mydb character set utf-8;
2.創(chuàng)建數(shù)據(jù)庫(kù)指定數(shù)據(jù)庫(kù)的字符集
mysql>create database mydb character set utf-8;
3.通過(guò)MySQL命令行修改
set character_set_client=utf8;
set character_set_connection=utf8;
set character_set_database=utf8;
set character_set_results=utf8;
set character_set_server=utf8;
set character_set_system=utf8;
set collation_connection=utf8;
set collation_database=utf8;
set collation_server=utf8;
2.3.備份還原數(shù)據(jù)庫(kù)
1.備份
mysqldump -u root -p voice>voice.sql;
2.還原
source voice.sql;
mysql -u root -p voice
1.http://blog.chinaunix.net/uid-26727991-id-4742248.html
?
參考鏈接:http://www.linuxidc.com/Linux/2012-06/63847.htm

Alat AI Hot

Undress AI Tool
Gambar buka pakaian secara percuma

Undresser.AI Undress
Apl berkuasa AI untuk mencipta foto bogel yang realistik

AI Clothes Remover
Alat AI dalam talian untuk mengeluarkan pakaian daripada foto.

Clothoff.io
Penyingkiran pakaian AI

Video Face Swap
Tukar muka dalam mana-mana video dengan mudah menggunakan alat tukar muka AI percuma kami!

Artikel Panas

Alat panas

Notepad++7.3.1
Editor kod yang mudah digunakan dan percuma

SublimeText3 versi Cina
Versi Cina, sangat mudah digunakan

Hantar Studio 13.0.1
Persekitaran pembangunan bersepadu PHP yang berkuasa

Dreamweaver CS6
Alat pembangunan web visual

SublimeText3 versi Mac
Perisian penyuntingan kod peringkat Tuhan (SublimeText3)