虛擬機(jī)上架設(shè)wordpress站點(diǎn)

打算做一個(gè)創(chuàng)客相關(guān)的站點(diǎn),現(xiàn)在域名備案還沒來及做。本文記錄一下在域名備案完成前,在虛擬機(jī)上架設(shè)wordpress的步驟。

系統(tǒng)的環(huán)境

宿主機(jī)為HP probook 4441s筆記本。i5 cpu+8G RAM。win7 64位。虛擬機(jī)軟件為vm10。
虛擬機(jī)系統(tǒng):debian7.7 dual core+1G ram+20G HDD
宿主機(jī)IP:192.168.199.103;虛擬機(jī)IP:192.168.199.137

debian系統(tǒng)安裝和配置

安裝(略)

配置

配置升級源

修改系統(tǒng)源

vim /etc/apt/sources.list
屏蔽掉
deb cdrom:[Debian GNU/Linux 7.7.0 _Wheezy_ - Official amd64 CD Binary-1 20141018-13:06]/ wheezy main
這句的下面添加四句

deb http://mirrors.163.com/debian wheezy main non-free contrib
deb-src http://mirrors.163.com/debian wheezy main non-free contrib

deb http://mirrors.163.com/debian wheezy-updates main non-free contrib
deb-src http://mirrors.163.com/debian wheezy-updates main non-free contrib

然后升級索引,升級系統(tǒng)
apt-get update apt-get upgrade

安裝工具軟件

apt-get install mlocate vim

安裝lemp環(huán)境

安裝nginx

nginx是作為webserver。
apt-get install nginx
檢查系統(tǒng)進(jìn)程
ps -ef|grep nginx

安裝mysql-server

雖然perconaserver和mariadbserver大有取代mysqlserver的呼聲。但是mysql5.x還是值得信賴的。
apt-get install mysql-server mysql-devel

為了安全起見,可以再執(zhí)行
/usr/bin/mysql_secure_installation

安裝php

安裝php5主體,php5連接mysql的部分, 搭配nginx的php5組件以及php5的優(yōu)化組件。其余的必須php5-xml等擴(kuò)展需要用的時(shí)候再安裝。
apt-get install php5 php5-mysql php5-fpm php5-apc

注意:默認(rèn)的php5-fpm是以sock文件方式運(yùn)行的,而不是socket方式運(yùn)行。所以沒有占用9000端口

搭配nginx和php

現(xiàn)在nginx+mysqlserver+php5都已經(jīng)安裝完畢?,F(xiàn)在可以配置nginx和php5了。
nginx的默認(rèn)配置文件<em>sudo vim /etc/nginx/sites-available/default</em>里面定義了一個(gè)默認(rèn)站點(diǎn)我們現(xiàn)在修改它。其中

#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;=====>注釋取消掉
#}=====>注釋取消掉

而后重啟<strong>nginx</strong>和<strong>php-fpm</strong>
/etc/init.d/nginx restart /etc/init.d/php5-fpm restart

而后在<em>/usr/share/html</em>文件夾中建立一個(gè)info.php
<?php phpinfo(); ?>
在筆記本上訪問 <em>http://192.168.199.137/info.php</em>可以看到phpinfo函數(shù)返回的相關(guān)信息。至此nginx已經(jīng)能夠解析php頁面了。

建立wordpress站點(diǎn)

wordpress中文站下載wp的源代碼包
cd /usr/local/src wget --no-check-certificate https://cn.wordpress.org/wordpress-4.0.1-zh_CN.tar.gz tar -xf wordpress-4.0.1-zh_CN.tar.gz

建立一個(gè)專門的網(wǎng)站目錄轉(zhuǎn)移過去
mkdir -p /data/www/beginmaker.com mv wordpress/* /data/www/beginmaker.com/

設(shè)置權(quán)限這樣安裝時(shí)候程序有權(quán)限在目錄中生成wp-config.php文件
chown -R www-data:www-data /data/www/beginmaker.com

為了管理方便。我們對站點(diǎn)單獨(dú)建立一個(gè)nginx配置文件<em>/etc/nginx/sites-available/beginmaker.com</em>

`
server {
listen 80; ## listen for ipv4; this line is default and implied

root /data/www/beginmaker.com;
index index.html index.htm index.php;

server_name beginmaker.com www.beginmaker.com beginmaker.cc www.beginmaker.cc;

location / {
        # First attempt to serve request as file, then
        # as directory, then fall back to displaying a 404.
        try_files $uri $uri/ /index.html;
        # Uncomment to enable naxsi on this location
        # include /etc/nginx/naxsi.rules
}

location /doc/ {
    alias /usr/share/doc/;
    autoindex on;
    allow 127.0.0.1;
    allow ::1;
    deny all;
}

location ~ \.php$ {
    fastcgi_split_path_info ^(.+\.php)(/.+)$;
    fastcgi_pass unix:/var/run/php5-fpm.sock;
    fastcgi_index index.php;
    include fastcgi_params;
}

}
`

連接過去以生效
ln -sf /etc/nginx/sites-available/beginmaker.com /etc/nginx/sites-enabled/beginmaker.com
接下去修改筆記本的hosts文件。將beginmaker.com的解析指向到192.168.199.137上。

接下去訪問 http://beginmaker.com/即可打開wordpress安裝界面。

我們可以用mysql的root賬戶進(jìn)行連接。也可以新建一個(gè)專門的賬戶
`

登錄到mysql后臺

create database if not exists beginmakerwp default charset utf8 collate utf8_general_ci;
grant all privileges on beginmakerwp.* to beginmakeruser@localhost identified by '密碼';
flush privileges;
`

安裝過程至此結(jié)束。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容