- 資訊首頁(yè) > 互聯(lián)網(wǎng) >
- LNMP的安裝
一、LNMP的安裝
##先要下載,并根據不同系統進(jìn)行安裝:
wget -c http://soft.vpser.net/lnmp/lnmp1.2.
tar
.gz
tar
zxvf lnmp1.2.
tar
.gz
cd
lnmp1.0
./
install
.sh
#開(kāi)始進(jìn)行安裝操作
以上為下載及進(jìn)入安裝過(guò)程,以下為安裝前簡(jiǎn)易設置,切記輸入個(gè)其它域名及牢記mysql密碼:
+------------------------------------------------------------------------+
| LNMP V1.2
for
Ubuntu Linux Server, Written by Licess |
+------------------------------------------------------------------------+
| A tool to auto-compile &
install
LNMP/LNMPA/LAMP on Linux |
+------------------------------------------------------------------------+
| For
more
information please visit http://www.lnmp.org ; |
+------------------------------------------------------------------------+
Please setup root password of MySQL.(Default password: root)
Please enter: vpsmm.com
#輸入mysql的root密碼
MySQL root password: vpsmm.com
===========================
Do you want to
enable
or disable the InnoDB Storage Engine?
Default
enable
,Enter your choice [Y/n]: n
#是否安裝InnoDB
You will disable the InnoDB Storage Engine!
===========================
You have 5 options
for
your DataBase
install
.
1: Install MySQL 5.1.73
2: Install MySQL 5.5.42 (Default)
3: Install MySQL 5.6.23
4: Install MariaDB 5.5.42
5: Install MariaDB 10.0.17
Enter your choice (1, 2, 3, 4 or 5): 3
#選擇mysql版本
You will Install MySQL 5.6.23
===========================
You have 5 options
for
your PHP
install
.
1: Install PHP 5.2.17
2: Install PHP 5.3.29
3: Install PHP 5.4.41 (Default)
4: Install PHP 5.5.25
5: Install PHP 5.6.9
Enter your choice (1, 2, 3, 4 or 5): 5
#選擇php版本
You will
install
PHP 5.6.9
===========================
You have 3 options
for
your Memory Allocator
install
.
1: Don't
install
Memory Allocator. (Default)
2: Install Jemalloc
3: Install TCMalloc
Enter your choice (1, 2 or 3): 1
#小夜用不上,所以選擇1
You will
install
not
install
Memory Allocator.
#按任意鍵,設置完成,正式進(jìn)入安裝,預計20-40分鐘完成
常見(jiàn)lnmp管理命令:
#1.2版本以后,不需要再執行/root/lnmp了,可以在任意位置執行lnmp命令
lnmp
#會(huì )出現一些提示信息
lnmp restart
#重啟
lnmp vhost add
#添加網(wǎng)站綁定
二,域名綁定詳解
其實(shí)所謂的域名綁定,就是通過(guò)命令的形式,簡(jiǎn)易創(chuàng )建一個(gè)conf文件到/usr/local/nginx/conf/vhost下面,這個(gè)過(guò)程完全可以手工創(chuàng )建conf,或者,平時(shí)修改目錄、域名等,直接修改conf文件,效果完全一樣:
lnmp vhost add
#執行lnmp添加網(wǎng)站命令
+-------------------------------------------+
| Manager
for
LNMP, Written by Licess |
+-------------------------------------------+
Please enter domain(example: www.lnmp.org): vpsmm.com
#輸入綁定的主域名
======================================
Your domain: vpsmm.com
======================================
Do you want to add
more
domain name? (y/n) y
#是否綁定其它域名
Enter domain name(example: lnmp.org *.lnmp.org): www.vpsmm.com
#輸入其它域名
domain list: www.vpsmm.com
Please enter the directory
for
the domain: vpsmm.com
(Default directory: /home/wwwroot/vpsmm.com):
#默認創(chuàng )建的網(wǎng)站文件所在目錄
Virtual Host Directory: /home/wwwroot/vpsmm.com
===========================
Allow Rewrite rule? (y/n)
===========================
y
#是否添加偽靜態(tài)文件
Please enter the rewrite of programme:
wordpress,discuz,typecho,sablog,dabr rewrite was exist.
(Default rewrite: other):typecho
#小夜用的typecho程序
===========================
You choose rewrite=typecho
===========================
===========================
Allow access_log? (y/n)
===========================
n
#是否啟用日志文件
======================================================
Create database and MySQL user with same name (y/n)
======================================================
y
#是否創(chuàng )建mysql數據庫
verify your current MySQL root password: ****
#輸入安裝時(shí)的mysql數據庫root密碼
Warning: Using a password on the
command
line interface can be insecure.
MySQL root password correct.
Enter database name: vpsmm_user
#創(chuàng )建數據庫用戶(hù)名
Your will create a database and MySQL user with same name: vpsmm_user
Please enter password
for
mysql user vpsmm_user: vpsmmpasswd
Your password: vpsmmpasswd
#創(chuàng )建相應密碼
Press any key to start create virtul host...
Create Virtul Host directory......
set
permissions of Virtual Host directory......
You
select
the exist rewrite rule:/usr/
local
/nginx/conf/typecho.conf
Gracefully shutting down php-fpm .
done
Starting php-fpm
done
Test Nginx configure
file
......
nginx: the configuration
file
/usr/
local
/nginx/conf/nginx.conf syntax is ok
nginx: configuration
file
/usr/
local
/nginx/conf/nginx.conf
test
is successful
Restart Nginx......
Warning: Using a password on the
command
line interface can be insecure.
Warning: Using a password on the
command
line interface can be insecure.
User vpsmm_user create Sucessfully.
Warning: Using a password on the
command
line interface can be insecure.
Warning: Using a password on the
command
line interface can be insecure.
Warning: Using a password on the
command
line interface can be insecure.
Database: vpsmm_user create Sucessfully.
Warning: Using a password on the
command
line interface can be insecure.
Warning: Using a password on the
command
line interface can be insecure.
GRANT ALL PRIVILEGES ON vpsmm_user Sucessfully.
Warning: Using a password on the
command
line interface can be insecure.
FLUSH PRIVILEGES Sucessfully.
================================================
Virtualhost infomation:
Your domain: vpsmm.com
Home Directory: /home/wwwroot/vpsmm.com
Rewrite: typecho
Enable log: no
Database username: vpsmm_user
Database userpassword: vpsmmpasswd
Database Name: vpsmm_user
Create
ftp
account: no
#以上為新創(chuàng )建網(wǎng)站的一些信息
================================================
三、自定義偽靜態(tài)規則
如果lnmp默認的偽靜態(tài)規則不能滿(mǎn)足你的需要,或者,你要自行定義偽靜態(tài)規則,可以新建一個(gè)conf文件,放置于 /usr/local/nginx/conf 下,在域名配置文件,即:/usr/local/nginx/conf/vhost/legcloud.com.conf 里引用。
server
{
listen 80;
server_name legcloud.com www.legcloud.com;
#綁定的域名
index index.html index.htm index.php default.html default.htm default.php;
#首頁(yè)文件
root /home/legcloud.com;
#網(wǎng)站存放目錄
include wordpress.conf;
#偽靜態(tài)規則文件,可自定義成你需要的
location ~ .*\.(php|php5)?$
{
try_files $uri =404;
fastcgi_pass unix:/tmp/php-cgi.sock;
fastcgi_index index.php;
include fcgi.conf;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
access_log off;
}
修改設置以后,一定要重新載入lnmp或者,重新載入nginx,以下任決命令都一樣:
/root/lnmp reload
#使用lnmp重新載入配置
/etc/init.d/nginx reload
#只重新載入nginx配置,我一般用這個(gè)
<p class="yahei pxtitle id=" lnmp-4"="" style="margin-top: 0px; margin-right: 350px; margin-bottom: 15px; padding: 0px 0px 10px 25px; font-family: 'Open Sans', Georgia, 'Trebuchet MS', Trebuchet, 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, 'Microsoft Yahei', sans-serif; border-bottom-width: 1px; border-bottom-style: dotted; border-bottom-color: rgb(153, 153, 153); font-size: 26px; line-height: 40px; white-space: normal;">四、自定義404、503等常見(jiàn)錯誤
不管是404還是503等常見(jiàn)錯誤,還是設置/usr/local/nginx/conf/vhost/legcloud.com.conf文件來(lái)完成:
listen 80;
server_name legcloud.com www.legcloud.com;
index index.html index.htm index.php default.html default.htm default.php;
root /home/legcloud.com;
error_page 404 /404.php;
#放在這里,可自定義文件名,再重載nginx就可以了
include wordpress.conf;
五、判斷當前域名并自動(dòng)301到主域名
if
($host != 'vpsmm.com' ) {rewrite ^/(.*)$ http://www.vpsmm.com/$1 permanent;}
#判斷當前域名,如果不是則自動(dòng)301到主域名,放置于error_page ...;上下均可。
六、關(guān)閉或開(kāi)啟FSO等php函數
lnmp最新版,默認禁用了一些函數,例如fso等,可修改/usr/local/php/etc/php.ini
disable_functions = passthru,
exec
,system,chroot,scandir....
#----這是禁用函數,把不想禁用的刪除即可----如果自用主機,最簡(jiǎn)單的修改方案:
disable_functions =
; passthru,
exec
,system,chroot,scandir....
#----設置為全部開(kāi)啟
修改后,使用/etc/init.d/php-fpm restart,重新啟動(dòng)php
七、升級PHP和NGINX版本
cd
lnm0.9
#進(jìn)入lnmp安裝目錄
./upgrade_nginx.sh
#升級nginx,只要輸入你要升級的版本即可(可見(jiàn)nginx.org)
./upgrade_php.sh
#升級php,只要輸入你要升級的版本即可(可見(jiàn)php.net)
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng )、來(lái)自本網(wǎng)站內容采集于網(wǎng)絡(luò )互聯(lián)網(wǎng)轉載等其它媒體和分享為主,內容觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如侵犯了原作者的版權,請告知一經(jīng)查實(shí),將立刻刪除涉嫌侵權內容,聯(lián)系QQ:712375056。
Copyright ? 2009-2022 56dr.com. All Rights Reserved. 特網(wǎng)科技 特網(wǎng)云 版權所有 特網(wǎng)科技 粵ICP備16109289號
域名注冊服務(wù)機構:阿里云計算有限公司(萬(wàn)網(wǎng)) 域名服務(wù)機構:煙臺帝思普網(wǎng)絡(luò )科技有限公司(DNSPod) CDN服務(wù):阿里云計算有限公司 百度云 中國互聯(lián)網(wǎng)舉報中心 增值電信業(yè)務(wù)經(jīng)營(yíng)許可證B2
建議您使用Chrome、Firefox、Edge、IE10及以上版本和360等主流瀏覽器瀏覽本網(wǎng)站