1. 程式人生 > >PHP安裝-phpMyAdmin+Discuz

PHP安裝-phpMyAdmin+Discuz

uri 可執行 sql cto write 如果 doc cal The

PHP安裝-phpMyAdmin+Discuz
基於Apache和MySQL安裝完成之後繼續安裝PHP。以構建LAMP動態網站平臺。
http:./configure --prefix=/usr/local/httpd --enable-rewrite --enable-so --enable-charset-lite --enable-cgi

一、安裝PHP
[root@localhost ~]# tar -zxvf libmcrypt-2.5.8.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/libmcrypt-2.5.8/
[root@localhost ~]# ./configure && make && make install
[root@localhost ~]# ln -s /usr/local/lib/libmcrypt.* /usr/lib/
[root@localhost ~]# tar -zxvf mhash-0.9.9.9.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/mhash-0.9.9.9/
[root@localhost ~]# ./configure && make && make install
[root@localhost ~]# ln -s /usr/local/lib/libmhash* /usr/lib/
[root@localhost ~]# tar -zxvf mcrypt-2.6.8.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/mcrypt-2.6.8/
[root@localhost ~]# ./configure(如果報錯,請執行下面的命令)
[root@localhost ~]# export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
[root@localhost ~]# ./configure && make && make install
[root@localhost ~]# tar -zxvf php-5.3.28.tar.gz -C /usr/src/
[root@localhost ~]# cd /usr/src/php-5.3.28/
[root@localhost ~]# ./configure --prefix=/usr/local/php --with-mcrypt --withapxs2=/
usr/local/httpd/bin/apxs --with-mysql=/usr/local/mysql --with-config-filepath=/
usr/local/php --enable-mbstring
[root@localhost ~]# make && make install
或者:yum install libxml2-devel
[root@localhost ~]#cp /usr/src/php-5.3.28/php.ini-development /usr/local/php/php.ini
[root@localhost ~]#vim /usr/local/php/php.ini
修改:
default_charset = "utf-8”(修改)
file_uploads = On
upload_max_filesize = 2M
max_file_uploads = 20
post_max_size = 8M
short_open_tag = On(修改)

[root@localhost ~]#tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz -C /usr/src/
[root@localhost ~]#cp /usr/src/ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php- 5.3.x/ZendGuardLoader.so /usr/local/php/lib/php/
[root@localhost ~]#vim /usr/local/php/php.ini
添加:
zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
zend_loader.enable=1
[root@localhost ~]#vim /usr/local/httpd/conf/httpd.conf 修改:
LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
DirectoryIndex index.php index.html
[root@localhost ~]#service httpd stop
[root@localhost ~]#service httpd start
[root@localhost ~]#netstat -anpt |grep httpd
驗證:
[root@localhost ~]#cd /usr/local/httpd/htdocs/
[root@localhost htdocs]#mv index.html index.html_back

1、驗證PHP與Apache連接:
[root@localhost htdocs]#vim index.php
添加:
<?php
phpinfo( );
?>

[root@localhost htdocs]#curl http://192.168.1.1/ &

1、驗證PHP與MySQL連接:
[root@localhost htdocs]#mv index.php index.php_back
[root@localhost htdocs]#vim index.php
添加:
<?php
$link=mysql_connect(‘localhost‘,‘root‘,‘123456‘);
if($link) echo "恭喜你,數據庫連接成功啦!!";
mysql_close();
?>
或者
<?php
$link=mysql_connect("localhost","root","123");
if(!$link) echo "FAILD!連接錯誤,用戶名密碼不對";
else echo "OK!可以連接";
?>

----------------------------
安裝phpMyAdmin
[root@localhost ~]#tar -zxvf phpMyAdmin-4.2.5-all-languages.tar.gz -C /usr/src/
[root@localhost ~]#cd /usr/src/
[root@localhost ~]#cp -r phpMyAdmin-4.2.5-all-languages/ /usr/local/httpd/htdocs/phpMyAdmin
[root@localhost ~]#cd /usr/local/httpd/htdocs/phpMyAdmin
[root@localhost ~]#cp config.sample.inc.php config.inc.php
[root@localhost ~]#vim config.inc.php
修改:
$cfg[‘blowfish_secret‘] = ‘a8b7c6d‘;


驗證:
[root@localhost ~]#firefox http://192.168.1.1/phpMyAdmin &
修改處解釋:
在config.inc.php中
找到 $cfg[‘PmaAbsoluteUri‘]
修改你將用於讓虛機用戶訪問的phpMyAdmin的網址
如:$cfg[‘PmaAbsoluteUri‘] = ‘http://ip/phpmyadmin/‘; 或$cfg[‘PmaAbsoluteUri‘] = ‘http://ip:8899‘ (寫出訪問phpMyAdmin的絕對URL)
還有這些更改的地方:
$cfg[‘Servers‘][$i][‘host‘] = ‘localhost‘;(通常用默認,也有例外)
$cfg[‘Servers‘][$i][‘auth_type‘] = ‘cookie‘; // Authentication method (config, http or cookie based)?
用cookie。因為是網絡上使用所以這裏選擇cookie
$cfg[‘Servers‘][$i][‘user‘] = ‘root‘; // MySQL user
$cfg[‘Servers‘][$i][‘password‘] = ‘‘; // MySQL password (only needed自己機裏不用設置)
註:$cfg[‘blowfish_secret‘] = ‘‘;
本機的話不需要設置,但是網絡的話需要設置成cookie:
$cfg[‘blowfish_secret‘] = ‘cookie‘;
設置完畢。

3、打開IE,輸入http://ip/phpmyadmin/(當然你設置不同就用那個網址。),輸入用戶名和密碼後,用phpmyadmin瀏覽相應的mysql數據庫;
如果設置$cfg[‘Servers‘][$i][‘auth_type‘] = ‘cookie‘; 所以顯示會要求輸入帳號

4、$cfg[‘DefaultLang‘] = ‘zh‘; (這裏是選擇語言,zh代表簡體中文的意思)
---------------------------------------------------

安裝Discuz論壇
我把論壇的zip壓縮包Discuz_X1.5_SC_UTF8.zip放在了/root目錄,所以回到root的用戶目錄,把壓縮包解壓出來。
[root@linux ~]# unzip Discuz_X1.5_SC_UTF8.zip
[root@linux ~]# ls
anaconda-ks.cfg Discuz_X1.5_SC_UTF8.zip install.log.syslog upload
bbs install.log readme utility
解壓出來得到一個upload文件夾,把upload裏面的文件都移到/var/www/html/目錄。
[root@linux ~]# mv upload/* /var/www/html/
[root@linux ~]# ls /var/www/html
admin.php crossdomain.xml home.php plugin.php static
……
cp.php group.php misc.php source userapp.php

[root@linux ~]# chmod -R 777 /var/www/html/ 給論壇的所有文件都添加可讀可寫可執行的權限(註意:這裏我是為了方便,把論壇
的所有文件何目錄都設成777是不科學的,實際情況並不需要全部777,把 /config/、/data/、/uc_client/data、/uc_server/data設置成
777就可以了)
[root@linux ~]# ls -l /var/www/html
total 104
-rwxrwxrwx 1 root root 2413 Oct 20 16:15 admin.php
drwxrwxrwx 7 root root 4096 Oct 20 16:15 api
-rwxrwxrwx 1 root root 741 Oct 20 16:15 api.php
……………..
[root@linux ~]# mysqladmin -u root password 123456 設置mysql的root用戶密碼為123456
[root@linux ~]# mysql -u root -p
Enter password: (這裏輸入你設置的密碼,輸入是看不見的)
Welcome to the MySQL monitor. Commands end with ; or \g.
已經進入mysql了
mysql> grant all on *.* to root@”%” identified by “123456”; 授權,允許root用戶使用密碼123456訪問數據庫。

在瀏覽器中輸入:http://192.168.56.200/install 進行安裝

PHP安裝-phpMyAdmin+Discuz