腾讯云CentOS7安装LNMP

来源:互联网 发布:苹果双系统删除windows 编辑:程序博客网 时间:2024/06/13 21:27
LNMP = Linux + Nginx + MySQL+ PHP

安装Nginx

#yum install nginx #配置文件处于/etc/nginx#systemctl start nginx #启动nginx#systemctl enable nginx.service # 设置为开机启动

安装MySQL

#rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm#yum repolist enabled | grep “mysql.-community.”#yum -y install mysql-community-server #安装社区版,快可3分钟,慢或40分钟#systemctl start mysqld # 启动mysql#mysql_secure_installation # mysql安全安装,root密码初始为空,自己设置#mysql -uroot -pmysql>create database test; #创建wordpress数据库mysql>use test;mysql>quit #或者exit

安装PHP

3.1 安装php-fpm
#yum install php-fpm php-mysql
#systemctl start php-fpm # 启动php-fpm
#systemctl enable php-fpm # 设置开机启动

#mkdir /usr/www#chown -R apache:apache /usr/www

3.2 修改Nginx配置文件

打开/etc/nginx下的nginx.conf,其中server部分修改如下:

server {    listen       80 default_server;    listen       [::]:80 default_server;    server_name  ffflipped.cn;    root         /usr/www;    # Load configuration files for the default server block.    include /etc/nginx/default.d/*.conf;    location / {        index index.php;        try_files $uri $uri/ /index.php?$args;    }    rewrite /wp-admin$ $scheme://$host$uri/ permanent;    location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {                access_log off; log_not_found off; expires max;    }    location ~ \.php$ {        try_files $uri =404;        fastcgi_split_path_info ^(.+\.php)(/.+)$;        fastcgi_pass 127.0.0.1:9000;        fastcgi_index index.php;        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;        include fastcgi_params;    }}

保存后重载nginx

#systemctl reload nginx

在/usr/www 目录中创建 index.php

测试:ip或者解析好的域名下,就可以看到 index.php 的内容

原创粉丝点击