在Ubuntu上安裝 nginx, MySQL, PHP (LEMP),phpmyadmin和WordPress

來源:互聯網
上載者:User

標籤:

轉載自 http://www.cnblogs.com/eecs/p/3963869.html

1)更新 Apt-Get

終端命令:sudo apt-get update

2)安裝MySql

終端命令: sudo apt-get install mysql-server php5-mysql

3)安裝Nginx

sudo apt-get install nginx

nginx不會自己啟動,你需要啟動它sudo service nginx start

命令如下所示,如果nginx安裝成功了,可以在瀏覽器裡訪問

 

 

 

4)安裝php

sudo apt-get install php5-fpm

 

5)配置PHP

輸入sudo nano /etc/php5/fpm/php.ini

找到cgi.fix_pathinfo=1,把1改成0,去掉;號

接著配置www.conf檔案

sudo nano /etc/php5/fpm/pool.d/www.conf

找到listen關鍵字,改成listen = /var/run/php5-fpm.sock

啟動php-fpm

sudo service php5-fpm restart

 

 

6)配置nginx

sudo nano /etc/nginx/sites-available/default

開啟之後是這樣

改成

 

# pass the PHP scripts to FastCGI server listening on the php-fpm socket

location ~ \.php$ {

try_files $uri =404;

fastcgi_pass unix:/var/run/php5-fpm.sock;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME documentrootfastcgi_script_name;

include fastcgi_params;

}

 

 

7)測試安裝成功

sudo nano /usr/share/nginx/html/info.php

 

檔案中輸入

<?php

phpinfo();

?>

儲存後重啟nginx

sudo service nginx restart

輸入網址能看到php資訊頁面即說明安裝成功。

8)安裝phpmyadmin

sudo apt-get install phpmyadmin

sudo ln -s /usr/share/phpmyadmin/ /usr/share/nginx/html/phpmyadmin

9)安裝WordPress

原理同上,不再贅述,/usr/share/nginx/html 即可本台伺服器的預設訪問位置。在下面部署網站,url上通過 xxxx/you_folder_name 訪問

允許固定連結的url改寫,修改conf

location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
#try_files uriuri/ =404;
try_files uriuri/ /index.php?q=uri&args;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location /wp-blog/ {
try_files uriuri/ /wp-blog/index.php?$args;
}

 

關於上傳許可權配置

sudo chown -R www-data your-foldersudo chmod -R 775 your-folder

 wordpress訪問加速的一些設定

一篇禁用Google fonts的文章 http://www.wpyou.com/disable-goole-fonts.html

禁止Google fonts 和 avatar頭像

/**
* 刪除Google fonts 或者直接安裝 Disable Google Fonts外掛程式
*/
function coolwp_remove_open_sans_from_wp_core() {
wp_deregister_style( ‘open-sans‘ );
wp_register_style( ‘open-sans‘, false );
wp_enqueue_style(‘open-sans‘,‘‘);
}
add_action( ‘init‘, ‘coolwp_remove_open_sans_from_wp_core‘ );

一些外掛程式記錄

Disable Google Fonts

googlefonts to 360

Remove Open Sans font from WP core

Useso take over Google

WP CN Excerpt

 

//disable gravator

建立緩衝目錄

在wp-content 的同級目錄建立一個檔案夾,命名為 avatar ,設定該檔案夾的許可權為 0755 (如果 0755 不行,就試一下 0777)。

設定預設頭像

準備一張大小適合的預設頭像,命名為"default.jpg" ,放在 avatar 檔案夾裡面。

添加緩衝代碼

將下面的代碼複製到模板的 functions.php 檔案中即可

function my_avatar($avatar) {  $tmp = strpos($avatar, ‘http‘);  $g = substr($avatar, $tmp, strpos($avatar, "‘", $tmp) - $tmp);  $tmp = strpos($g, ‘avatar/‘) + 7;  $f = substr($g, $tmp, strpos($g, "?", $tmp) - $tmp);  $w = get_bloginfo(‘wpurl‘);  $e = ABSPATH .‘avatar/‘. $f .‘.jpg‘;  $t = 1209600; //設定14天, 單位:秒  if ( !is_file($e) || (time() - filemtime($e)) > $t ) { //當頭像不存在或檔案超過14天才更新    copy(htmlspecialchars_decode($g), $e);  } else  $avatar = strtr($avatar, array($g => $w.‘/avatar/‘.$f.‘.jpg‘));  if (filesize($e) < 500) copy($w.‘/avatar/default.jpg‘, $e);  return $avatar;}add_filter(‘get_avatar‘, ‘my_avatar‘);

  

在Ubuntu上安裝 nginx, MySQL, PHP (LEMP),phpmyadmin和WordPress

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.