日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

快速安装LNMP环境

發布時間:2023/12/20 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 快速安装LNMP环境 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

?現在,我們可以快速全自動搞定?CentOS + Nginx + PHP + MySQL?的安裝了

比網上流傳的什么一鍵安裝包要好得多,強烈推薦此法安裝,適合所有菜鳥和高手
這個裝完已經包含 php 的一些常用擴展, PDO,eaccelerator,memcache,tidy等等

先新建一個 repo

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

放入如下內容

[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

接著導入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 一下,全是最新的
別忘了開機啟動

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

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

先新建一個?/www?目錄,網站和日志也全放在這里
別忘了建日志存放目錄,你在配置文件中 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; #這里根據你的CPU和內存配置, 設置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; # 默認編碼,可以不設置

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 / {
# 這里是把所有不存在的文件和目錄,全都轉到 index.php 處理
try_files $uri $uri/ /index.php?q=$uri&$args;
}

# 這里分開放到 server.conf 是為了再開 server 的時候方便,統一調用,放到/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; # 這里復用了,這段就省了
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;
}

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

轉載于:https://blog.51cto.com/oakcdrom/830482

總結

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

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。