標籤:字元 ges 允許 html 軟體包 ide 資料 x86_64 client
練習三—虛擬web主機
[[email protected] conf]# cd /var/www/html/
[[email protected] html]# mkdir google tfft
[[email protected] html]# vim google/index.html
[[email protected] html]# vim tfft/index.html
[[email protected] html]# cat google/index.html
<h1> welcome to google ! </h1>
[[email protected] html]# cat tfft/index.html
<h1> welcome to tfft ! </h1>
[[email protected] html]# vim /etc/httpd/conf.d/vhosts.conf
[[email protected] html]# cat /etc/httpd/conf.d/vhosts.conf
NameVirtualHost 192.168.102.123
<VirtualHost 192.168.102.123>
DocumentRoot /var/www/html/google
ServerName www.google.com
</VirtualHost>
<VirtualHost 192.168.102.123>
DocumentRoot /var/www/html/tfft
ServerName www.tfft.com
</VirtualHost>
[[email protected] html]# /etc/init.d/httpd restart
停止 httpd: [確定]
正在啟動 httpd:httpd: Could not reliably determine the server‘s fully qualified domain name, using ::1 for ServerName
[確定]
補充:Windows系統中C:\Windows\System32\drivers\etc\hosts可添加IP和網域名稱對應關係
192.168.102.123 www.google.com
192.168.102.123 www.tfft.com
練習四—構建LAMP網站平台
1.安裝相應軟體包
[[email protected] html]# rpm -qa httpd mysql-server mysql php php-mysql
httpd-2.2.15-59.el6.centos.x86_64
[[email protected] html]# yum install mysql-server mysql php php-mysql
2.配置mysql
[[email protected] html]# /etc/init.d/mysqld restart
停止 mysqld: [確定]
初始化 MySQL 資料庫: Installing MySQL system tables...
[[email protected] html]# chkconfig mysqld on
[[email protected] html]# chkconfig mysqld --list
mysqld 0:關閉1:關閉2:啟用3:啟用4:啟用5:啟用6:關閉
[[email protected] html]# mysqladmin -u root password ‘Taren1‘
3.配置PHP
[[email protected] html]# vim /etc/php.ini
.. ..
default_charset = "utf-8" //設定預設字元集
file_uploads = On //允許從PHP網頁上傳檔案
upload_max_filesize = 2M //允許上傳的檔案大小
post_max_size = 8M //每次POST提交的資料限制
4.配置httpd
[[email protected] html]# vim /etc/httpd/conf/httpd.conf
...
DirectoryIndex index.php index.html
[[email protected] html]# vim /var/www/html/test1.php
<?php
phpinfo();
?>
[[email protected] html]# vim /var/www/html/test2.php
<?php
$link=mysql_connect(‘localhost‘,‘root‘,‘Taren1‘);
if($link) echo "Success !!"; //成功則顯示Success !!
else echo "Failure !!"; //失敗則顯示Failure !!
mysql_close(); //關閉資料庫連接
?>
5.重啟httpd服務及訪問
[[email protected] html]# /etc/init.d/httpd restart
停止 httpd: [確定]
正在啟動 httpd:httpd: Could not reliably determine the server‘s fully qualified domain name, using ::1 for ServerName
[確定]
練習五—部署PHP應用(Discuz!論壇系統)
1.建論壇庫
[[email protected] ~]# mysql -uroot -p
Enter password: //驗證管理密碼
mysql> create database bbsdb;//建立bbsdb資料庫
mysql> show databases;//查看資料庫
mysql> grant all on bbsdb.* to [email protected] identified by ‘pwd123‘;//授權資料庫
mysql> quit
2.部署論壇網頁代碼
[[email protected] ~]# unzip Discuz_X3.2_SC_UTF8.zip -d tdir
[[email protected] ~]# ls -F tdir/
[[email protected] ~]# cp -rf tdir/upload/ /var/www/html/bbs
[[email protected] ~]# cd /var/www/html/bbs/
[[email protected] bbs]# chown -R apache template/ config/ data/ uc_client/ uc_server/
3.安裝論壇系統及後續訪問
http://192.168.102.123/bbs/install/
搭建web服務二