簡單架設一個LAMP架構的基礎網站
web服務器的實現,在LAMP架構下,分爲三層:
1、web服務器響應客戶端請求的接入層(http)
2、使用應用業務的應用層(PHP)
3、後端提供數據服務的數據層(MySQL)
這三層已經能夠滿足基本需要了。
這三層分別使用http2.2、hph5.3和mysql5.1來實現。
# yum -y install httpd
# vim /etc/httpd/conf/httpd.conf
ServerName 192.168.1.33:80
# service httpd configtest
Syntax OK
# vim /var/www/html/index.html 編寫後即可成爲默認訪問頁面
<h1>/var/www/html/index.html</h1>
# chkconfig httpd on
# /etc/init.d/httpd start
Starting httpd: [ OK ]
實現httpd啓動完成
在客戶端使用IP:192.168.1.33訪問,出現主頁面上的內容就可以使用web網站了。
安裝並啓動hph
# yum install php
# vim /etc/httpd/conf/httpd.conf
DirectoryIndex index.php index.html index.html.var
# service httpd configtest
Syntax OK
# vim /var/www/html/index.php
寫入下面的內容
<?php
phpinfo();
?>
# /etc/init.d/httpd restart
如果在網頁中使用IP地址可以訪問到php返回內容,就說明可以使用php了。
安裝並啓動mysql
# yum install mysql mysql-server php-mysql
# /etc/init.d/mysqld start
# mysql 可以直接使用默認用戶root連接進入mysql
在主頁中編寫如下腳本,來測試與mysql的連接性
[root@www mysql]# vim /var/www/html/index.php
<?php
$link=mysql_connect(localhost,root,'');
if ($link)
echo "Sueccess...";
else
echo "Failure...";
?>
# /etc/init.d/httpd restart
客戶端訪問,出現Sueccess...就說明已經完成php與mysql的連接。
這樣一個LAMP架構就簡單地在一個服務器中實現了。
安裝wordpress
[root@www ~]# unzip wordpress-3.1-RC1.zip
[root@www html]# mv /root/wordpress-3.1-RC1/wordpree/* /var/www/html/
提供主配置文件
[root@www html]# cp wp-config-sample.php wp-config.php
[root@www html]# vim wp-config.php
// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wpdb'); 數據庫爲wpdb
/** MySQL database username */
define('DB_USER', 'root'); 用戶爲root
/** MySQL database password */
define('DB_PASSWORD', ''); 密碼爲空
# setenforce 0
在瀏覽器上就可以查看到wordpress頁面
在初始化頁面提供用戶名密碼,郵件,就可以登錄了。