1. 程式人生 > >ubuntu 14.04 Apache搭建wordpress部落格

ubuntu 14.04 Apache搭建wordpress部落格

安裝相關檔案

#安裝apache
[email protected]:~$ dpkg -l|grep apache
[email protected]:~$ sudo apt-get install apache2
[email protected]:~$ dpkg -l|grep apache
ii  apache2                                               2.4.7-1ubuntu4.20                                   amd64        Apache HTTP Server
ii  apache2-bin                                           2.4.7-1ubuntu4.20                                   amd64        Apache HTTP Server (binary files and modules)
ii  apache2-data                                          2.4.7-1ubuntu4.20                                   all          Apache HTTP Server (common files)

#安裝php5
[email protected]:~$ dpkg -l|grep php5
ii  php5-common                                           5.5.9+dfsg-1ubuntu4.25                              amd64        Common files for packages built from the php5 source
ii  php5-fpm                                              5.5.9+dfsg-1ubuntu4.25                              amd64        server-side, HTML-embedded scripting language (FPM-CGI binary)
ii  php5-json                                             1.3.2-2build1                                       amd64        JSON module for php5
ii  php5-mysql                                            5.5.9+dfsg-1ubuntu4.25                              amd64        MySQL module for php5

[email protected]:~$ sudo apt-get install php5

#安裝Mysql
[email protected]:~$ dpkg -l|grep mysql-server
ii  mysql-server                                          5.5.60-0ubuntu0.14.04.1                             all          MySQL database server (metapackage depending on the latest version)
ii  mysql-server-5.5                                      5.5.60-0ubuntu0.14.04.1                             amd64        MySQL database server binaries and system database setup
ii  mysql-server-core-5.5                                 5.5.60-0ubuntu0.14.04.1                             amd64        MySQL database server binaries
#我已經安裝有  安裝命令sudo apt-get install mysql-server

[email protected]:~$ sudo apt-get install libapache2-mod-php5

[email protected]:~$ sudo vim /etc/apache2/apache2.conf 
#在最後加上ServerName localhost:80
[email protected]:~$ sudo service apache2 restart 
 * Restarting web server apache2
   ...done.

#其他模組安裝
[email protected]:~$ sudo apt-get install libapache2-mod-php5
[email protected]:~$ sudo apt-get install libapache2-mod-auth-mysql
[email protected]:~$ sudo apt-get install php5-mysql
[email protected]:~$ sudo apt-get install php5-gd

  • 前兩個很容易明白,要想apache能夠解析PHP,就需要藉助這兩個模組來找到php engine。
  • 第三個在php操作mysql資料庫時用到
  • 第四個GD庫。

 

 

測試


安裝完apache2,根目錄在/var/www/html下,可以通過http://localhost/測試一下是否好用。

 

去官網安裝安裝phpadmin與wordpress,下載後解壓縮到/var/www/html

[email protected]:~/下載$ ls

phpMyAdmin-4.8.3-all-languages.zip  wordpress-4.9.8.tar.gz

#unzip 解壓縮 phpMyAdmin到/var/www/html

[email protected]:~/下載$ sudo tar -xzf wordpress-4.9.8.tar.gz -C /var/www/html/

[email protected]:~/下載$ cd /var/www/html/
[email protected]:/var/www/html$ ls
!  index.html  phpmyadmin  phpMyAdmin-4.8.3-all-languages  test.html  wordpress

瀏覽器訪問phpmyadminip/phpMyAdmin-4.8.3-all-languages

登入賬號為root,密碼為mysql設定的密碼

 

建立資料庫,語言選utf8_general_ci,如果你擅長SQL語句,可以直接用SQL語句建立資料庫 create database wordpress;

 

瀏覽器輸入ip/wordpress 

資料庫名稱填剛建立的,資料庫使用者名稱,資料庫密碼,下面預設

出現如下錯誤 

 

[email protected]:/var/www/html$ cd wordpress/

[email protected]:/var/www/html$ sudo cp  wp-config-sample.php wp-config.php
[email protected]:/var/www/html$ sudo 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', 'database_name_here');#database_name_here填資料庫名稱

/** MySQL database username */
define('DB_USER', 'username_here');#username_here資料庫使用者名稱稱

/** MySQL database password */
define('DB_PASSWORD', 'password_here');#/資料庫密碼  

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

#儲存退出

#wordpress安裝完成

 

 

參考部落格:https://blog.csdn.net/YhL_Leo/article/details/50520915

 

我的部落格:http://wuyujun.iok.la/wordpress/