日韩av黄I国产麻豆传媒I国产91av视频在线观看I日韩一区二区三区在线看I美女国产在线I麻豆视频国产在线观看I成人黄色短片

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) >

快速安装LNMP环境

發(fā)布時(shí)間:2023/12/20 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 快速安装LNMP环境 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

?現(xiàn)在,我們可以快速全自動(dòng)搞定?CentOS + Nginx + PHP + MySQL?的安裝了

比網(wǎng)上流傳的什么一鍵安裝包要好得多,強(qiáng)烈推薦此法安裝,適合所有菜鳥(niǎo)和高手
這個(gè)裝完已經(jīng)包含 php 的一些常用擴(kuò)展, PDO,eaccelerator,memcache,tidy等等

先新建一個(gè) repo

# vi /etc/yum.repos.d/centos.21andy.com.repo

放入如下內(nèi)容

[21Andy.com]
name=21Andy.com Packages for Enterprise Linux 5 – $basearch
baseurl=http://www.21andy.com/centos/5/$basearch/
enabled=1
gpgcheck=0
protect=1

啟用 EPEL repo
i386

rpm -ihv http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm

x86_64

rpm -ihv http://download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm

接著導(dǎo)入key

rpm –import /etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL

好了,一鍵安裝

# yum install nginx php-fpm mysql-server

爽吧!

# APC 和 eAccelerator 有沖突,2選1

yum -y install php-pecl-apc

看下我的完整安裝,只要一句

yum -y install nginx mysql-server php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator

?

最后只要 yum -y update 一下,全是最新的
別忘了開(kāi)機(jī)啟動(dòng)

chkconfig ?mysqld on
chkconfig php-fpm on
chkconfig nginx on

補(bǔ)充:所有的配置文件都在 /etc 目錄下,包括 nginx, php-fpm, mysql 的配置文件,請(qǐng)自行查找設(shè)置,以下為我的 nginx 的配置范例

先新建一個(gè)?/www?目錄,網(wǎng)站和日志也全放在這里
別忘了建日志存放目錄,你在配置文件中 access_log 用到的?/www/logs

注意:fastcgi_params 要加入這一行
# vim /etc/nginx/fastcgi_params

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

# vi /etc/nginx/nginx.conf

user nobody nobody;worker_processes 8; #這里根據(jù)你的CPU和內(nèi)存配置, 設(shè)置2到10都OK

?

error_log? /www/logs/nginx_error.log? crit;

pid? ? ? ? /usr/local/nginx/logs/nginx.pid;

#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;

events {
use epoll;
worker_connections 51200;
}

http {
include? ? ? ?mime.types;
default_type? application/octet-stream;

#charse? gb2312; # 默認(rèn)編碼,可以不設(shè)置

server_names_hash_bucket_size 128;
client_header_buffer_size 16k;
large_client_header_buffers 4 16k;
client_max_body_size 8m;

sendfile on;
tcp_nopush? ? ?on;

keepalive_timeout 60;

tcp_nodelay on;

fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;

gzip on;
gzip_min_length? 1k;
gzip_buffers? ? ?4 16k;
gzip_http_version 1.0;
gzip_comp_level 5;
gzip_types? ? ? ?text/plain text/javascript application/x-javascript text/css application/xml;
gzip_vary on;

#limit_zone? crawler? $binary_remote_addr? 10m;
server {
listen 80;
server_name localhost;
root? /www;
location /status {
stub_status on;
access_log? off;
}
location / {
# 這里是把所有不存在的文件和目錄,全都轉(zhuǎn)到 index.php 處理
try_files $uri $uri/ /index.php?q=$uri&$args;
}

# 這里分開(kāi)放到 server.conf 是為了再開(kāi) server 的時(shí)候方便,統(tǒng)一調(diào)用,放到/etc/nginx/ 目錄下
include server.conf;

log_format? access? ‘$remote_addr – $remote_user [$time_local] “$request” ‘
‘$status $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” $http_x_forwarded_for’;
access_log? /www/logs/access.log? access;
}

server {
listen 80;
server_name www.21andy.com 21andy.com *.21andy.com;
root? /www/21andy.com;
if ($host !~* 21andy\.com$) {
return 444;
}
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
include server.conf; # 這里復(fù)用了,這段就省了
access_log? /www/logs/21andy.com_access.log? access;
}
}

# vi /etc/nginx/server.conf

index index.html index.htm index.php;#limit_conn? ?crawler? 20;

?

location ~ /\.ht {
deny all;
}

location ~ .*\.(sqlite|sq3)$ {
deny all;
}

location ~ .*\.php$ {
fastcgi_pass? unix:/tmp/php-cgi.sock;
#fastcgi_pass? 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|ico)$ {
expires? ? ? 30d;
access_log? ?off;
}

按以上操作,環(huán)境就順利成功了。。。location ~ .*\.(js|css)?$ {
expires? ? ? 30d;
access_log? ?off;
}

轉(zhuǎn)載于:https://blog.51cto.com/oakcdrom/830482

總結(jié)

以上是生活随笔為你收集整理的快速安装LNMP环境的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。