日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 >

httpd是mysql_在Centos下安装httpd、php、Mysql并配置(转载)

發布時間:2025/3/20 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 httpd是mysql_在Centos下安装httpd、php、Mysql并配置(转载) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

轉自: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、 配置開機啟動服務:設置apache服務器httpd服務開機啟動、在服務清單中添加mysql服務、設置mysql服務開機啟動

1)

/sbin/chkconfig httpd on

/sbin/chkconfig --add mysqld

/sbin/chkconfig mysqld on

3、啟動httpd服務、啟動mysql服務

/sbin/service httpd start

/sbin/service mysqld start

3、新建一個index.php文件,內容如下:

phpinfo();

?>

將該文本上傳至默認站點目錄為/var/www/html/中,并訪問,即可測試服務信息!

4、設置mysql數據庫root帳號密碼。

mysqladmin -u root password 'newpassword'     [引號內填密碼]

5、讓mysql數據庫更安全

mysql -u root -p                     [此時會要求你輸入剛剛設置的密碼,輸入后回車即可]

mysql> DROP DATABASE test;                [刪除test數據庫]

mysql> DELETE FROM mysql.user WHERE user = '';    [刪除匿名帳戶]

mysql> FLUSH PRIVILEGES;                 [重載權限]

6、 新建一個數據庫,添加一個數據庫用戶,設置用戶權限。

mysql> CREATE DATABASE eexu_db;

mysql> GRANT ALL PRIVILEGES ON eexu_db.* TO 'user'@'localhost' IDENTIFIED BY 'password';

#eexu_db是數據庫名稱、user是用戶名、password是密碼,根據需要換成自已的

7、apache虛擬主機配置。

vi /etc/httpd/conf/httpd.conf

1)綁定域名:

添加下面內容:

NameVirtualHost *:80

ServerName www.domain.com

ServerAlias domain.com *.domain.com

DocumentRoot /www/domain

2)設置默認文檔

找到以下字符

DirectoryIndex index.html index.htm index.php

8、解決中文亂碼問題。

vi /etc/httpd/conf/httpd.conf

找到AddDefaultCharset 改為  AddDefaultCharset off

這種方式關掉了服務器的默認語言的發送,這樣僅憑html文件頭中設置的語言來決定網頁語言。有人直接用AddDefaultCharset GB2312,這種方式有問題看,雖然中文顯示沒問題了,但當你的網頁內碼不是GB2312,就算你在網頁用下面的meta指定了正確的語言,如 ISO8859-1,也不會解碼為ISO8859-1,因為Apache已經先你一步將GB2312指定為網頁的語言了。

9、低內存服務器的MySQL內存占用優化建議,僅供參考。

配置文件: 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

重啟防火墻服務

service iptables restart

11、安裝擴展

1)//安裝apache擴展

yum -y install httpd-manual mod_ssl mod_perl mod_auth_mysql

2)//安裝php的擴展

yum install php-gd

yum -y install php-gd php-xml php-mbstring php-ldap php-pear php-xmlrpc

3)//安裝mysql擴展

yum -y install mysql-connector-odbc mysql-devel libdbi-dbd-mysql

總結

以上是生活随笔為你收集整理的httpd是mysql_在Centos下安装httpd、php、Mysql并配置(转载)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。