httpd是mysql_在Centos下安装httpd、php、Mysql并配置(转载)
轉(zhuǎn)自:http://club.jledu.gov.cn/?action-viewspace-itemid-299020
1、安裝Apahce, PHP, Mysql, 以及php連接mysql庫組件。
yum -y install httpd php mysql mysql-server php-mysql
2、 配置開機(jī)啟動服務(wù):設(shè)置apache服務(wù)器httpd服務(wù)開機(jī)啟動、在服務(wù)清單中添加mysql服務(wù)、設(shè)置mysql服務(wù)開機(jī)啟動
1)
/sbin/chkconfig httpd on
/sbin/chkconfig --add mysqld
/sbin/chkconfig mysqld on
3、啟動httpd服務(wù)、啟動mysql服務(wù)
/sbin/service httpd start
/sbin/service mysqld start
3、新建一個(gè)index.php文件,內(nèi)容如下:
phpinfo();
?>
將該文本上傳至默認(rèn)站點(diǎn)目錄為/var/www/html/中,并訪問,即可測試服務(wù)信息!
4、設(shè)置mysql數(shù)據(jù)庫root帳號密碼。
mysqladmin -u root password 'newpassword' [引號內(nèi)填密碼]
5、讓mysql數(shù)據(jù)庫更安全
mysql -u root -p [此時(shí)會要求你輸入剛剛設(shè)置的密碼,輸入后回車即可]
mysql> DROP DATABASE test; [刪除test數(shù)據(jù)庫]
mysql> DELETE FROM mysql.user WHERE user = ''; [刪除匿名帳戶]
mysql> FLUSH PRIVILEGES; [重載權(quán)限]
6、 新建一個(gè)數(shù)據(jù)庫,添加一個(gè)數(shù)據(jù)庫用戶,設(shè)置用戶權(quán)限。
mysql> CREATE DATABASE eexu_db;
mysql> GRANT ALL PRIVILEGES ON eexu_db.* TO 'user'@'localhost' IDENTIFIED BY 'password';
#eexu_db是數(shù)據(jù)庫名稱、user是用戶名、password是密碼,根據(jù)需要換成自已的
7、apache虛擬主機(jī)配置。
vi /etc/httpd/conf/httpd.conf
1)綁定域名:
添加下面內(nèi)容:
NameVirtualHost *:80
ServerName www.domain.com
ServerAlias domain.com *.domain.com
DocumentRoot /www/domain
2)設(shè)置默認(rèn)文檔
找到以下字符
DirectoryIndex index.html index.htm index.php
8、解決中文亂碼問題。
vi /etc/httpd/conf/httpd.conf
找到AddDefaultCharset 改為 AddDefaultCharset off
這種方式關(guān)掉了服務(wù)器的默認(rèn)語言的發(fā)送,這樣僅憑html文件頭中設(shè)置的語言來決定網(wǎng)頁語言。有人直接用AddDefaultCharset GB2312,這種方式有問題看,雖然中文顯示沒問題了,但當(dāng)你的網(wǎng)頁內(nèi)碼不是GB2312,就算你在網(wǎng)頁用下面的meta指定了正確的語言,如 ISO8859-1,也不會解碼為ISO8859-1,因?yàn)锳pache已經(jīng)先你一步將GB2312指定為網(wǎng)頁的語言了。
9、低內(nèi)存服務(wù)器的MySQL內(nèi)存占用優(yōu)化建議,僅供參考。
配置文件: vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1
# Low memory optimizations
skip-bdb
skip-innodb
skip-networking
server-id = 1
key_buffer = 256K
max_allowed_packet=1M
thread_stack = 64K
table_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 64K
query_cache_limit=256K
query_cache_size = 2M
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/my
10、防火墻開啟80端口
vi /etc/sysconfig/iptables
添加
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
重啟防火墻服務(wù)
service iptables restart
11、安裝擴(kuò)展
1)//安裝apache擴(kuò)展
yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql
2)//安裝php的擴(kuò)展
yum install php-gd
yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc
3)//安裝mysql擴(kuò)展
yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql
總結(jié)
以上是生活随笔為你收集整理的httpd是mysql_在Centos下安装httpd、php、Mysql并配置(转载)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java word 在线编辑图片_jav
- 下一篇: linux cmake编译源码,linu