前言
又到了写博客的时间,今天总结一下在ubuntu 14.04 x86下配置LNMP及wordpress,环境是我们上一篇中已经安装好的,如果没有像上文一样配置过的话,请注意修改系统的LL_ALL与LC_CTYPE,不然会卡在MySQL的安装上,最后尽管只安装了这么少的东西,128mb内存的压力依旧巨大,这里只复习下配置过程,写博客什么的,还是呆在这个域名里就好。所以配置完后,拍个快照,就恢复到只安装了ss的状态。
安装
步骤:
1.安装配置MySQL与php5-mysql
2.安装配置nginx与php-fpm
3.下载wordpress,配置路径
4.安装配置phpmyadmin
5.配置wordpress
相关依赖会自动安装
命令:
apt-get install mysql-server php5-mysql
输出如下
安装后会提示输入MySQL的root密码,因为已经配置好语言环境,所以不用担心乱码了。
然后是nginx与php-fpm
apt-get install nginx php-fpm
这里不列出自动安装的依赖了,安装完成后,直接访问vps的ip地址就可以看到index.html了,接下来开始配置
修改/etc/php5/fpm/php.ini,将cgi.fix_pathinfo的注释解除并设置为0
vim的搜索技巧
在命令模式下按/或者?可以向下或者向上搜索,输入匹配单词后按回车确认,接下来按n可以找到下一个匹配项目
然后修改/etc/php5/fpm/pool.d/www.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on;root /usr/share/nginx/html; index index.html index.htm;# Make site accessible from http://localhost/ server_name localhost;location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ =404; # Uncomment to enable naxsi on this location # include /etc/nginx/naxsi.rules } # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests #location /RequestDenied { # proxy_pass http://127.0.0.1:8080; #} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # #error_page 500 502 503 504 /50x.html; #location = /50x.html { # root /usr/share/nginx/html; #} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 # #location ~ \.php$ { # fastcgi_split_path_info ^(.+\.php)(/.+)$; # # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini # # # With php5-cgi alone: # fastcgi_pass 127.0.0.1:9000; # # With php5-fpm: # fastcgi_pass unix:/var/run/php5-fpm.sock; # fastcgi_index index.php; # include fastcgi_params; #} # deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #} } |
去掉所有注释后如下,可以看到仅仅配置了根目录与错误404页面
1 2 3 4 5 6 7 8 9 10 11 12 |
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; root /usr/share/nginx/html; index index.html index.htm; server_name localhost; location / { try_files $uri $uri/ =404; } } |
让我们首先在域名解析处绑定好一个域名(banwa.wbuntu.com)到服务器,然后再具体配置如下
先下载wordpress
wget http://wordpress.org/latest.tar.gz
解压
tar -zxvf latest.tar.gz
创建文件夹,复制文件,最后修改权限
mkdir -p /var/www
cp -r ~/wordpress/* /var/www
chown –R www-data:www-data /var/www
接下来配置/etc/nginx/sites-available/default
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
server { listen 80; root /var/www; index index.php index.html index.htm; server_name banwa.wbuntu.com; location / { try_files $uri $uri/ /index.php?q=$uri&$args; } error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 location ~ \.php$ { try_files $uri =404; #fastcgi_pass 127.0.0.1:9000; # With php5-fpm: fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } |