ubuntu使用二进制包安装lnmp环境

本文涉及的产品
RDS AI 助手,专业版
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
RDS MySQL DuckDB 分析主实例,基础系列 4核8GB
简介:

apt-get install mysql-server

apt-get install nginx

apt-get install php5-fpm

安装php相应的支持库

apt-get install php5-fpm php5-cli php5-curl php5-gd mcrypt php5-mcrypt php5-mysql

#下面的只是记录一下

apt-get php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl


nginx的配置的多中版本:

其一:

server {

listen 80 default_server;

listen [::]:80 default_server ipv6only=on;


root /usr/share/nginx/html;

index index.php index.html index.htm;


# Make site accessible from http://localhost/

server_name localhost;


location / {

try_files $uri $uri/ /index.php;

}


location /doc/ {

alias /usr/share/doc/;

autoindex on;

allow 127.0.0.1;

allow ::1;

deny all;

}


#

error_page 500 502 503 504 /50x.html;

location = /50x.html {

root /usr/share/nginx/html;

}


location ~ \.php$ {

# With php5-fpm:

        try_files $uri =404;

fastcgi_pass unix:/var/run/php5-fpm.sock;

fastcgi_index index.php;

include fastcgi_params;

}


# deny access to .htaccess files, if Apache's document root

# concurs with nginx's one

#

location ~ /\.ht {

deny all;

}

}



nginx配置其二:

server {

        listen 80;

        listen [::]:80 default_server ipv6only=on;


        root /usr/share/nginx/html;

        index index.php index.html index.htm;


        # Make site accessible from http://localhost/

        server_name _;


        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;

        }


        # Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests

        #location /RequestDenied {

        #       proxy_pass http://127.0.0.1:8080;

        #}


        #error_page 404 /404.html;


        # redirect server error pages to the static page /50x.html

        #

        error_page 500 502 503 504 /50x.html;

        location = /50x.html {

                root /usr/share/nginx/html;

        }


        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        location ~ .php$ {

                try_files $uri =404;

                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;

        }


        # deny access to .htaccess files, if Apache's document root

        # concurs with nginx's one

        #

        location ~ /.ht {

                deny all;

        }

}



nginx配置其三:

server {

listen 80;


server_name example.com;

root /var/www/example.com;


index index.html index.htm index.php;


access_log /var/log/nginx/example.com.access.log;

error_log /var/log/nginx/example.com.error.log;


location = /favicon.ico { log_not_found off; access_log off; }

location = /robots.txt  { log_not_found off; access_log off; }


location ~* .(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|css|rss|atom|js|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {

expires max; log_not_found off; access_log off;

}


location ~ \.php?$ {

include /etc/nginx/fastcgi_params;

fastcgi_pass php;

}

}


nginx配置其四:

location ~ .php$ {

try_files $uri =404; #增加

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; #反注释

}


nginx配置其五:

 location / {

        try_files $uri $uri/ =404;

    }


    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;

    location = /50x.html {

        root /usr/share/nginx/html;

    }


    location ~ \.php$ {

        try_files $uri =404;

        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        fastcgi_pass unix:/var/run/php5-fpm.sock;

        fastcgi_index index.php;

        include fastcgi_params;

    }

}


nginx配置其六:

server {

    listen 80 default_server;

    listen [::]:80 default_server ipv6only=on;


    root /usr/share/nginx/html;

    index index.php index.html index.htm;


    server_name server_domain_name_or_IP;


    location / {

        try_files $uri $uri/ =404;

    }


    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;

    location = /50x.html {

        root /usr/share/nginx/html;

    }


    location ~ \.php$ {

        try_files $uri =404;

        fastcgi_split_path_info ^(.+\.php)(/.+)$;

        fastcgi_pass unix:/var/run/php5-fpm.sock;

        fastcgi_index index.php;

        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

        include fastcgi_params;

    }

}





以上内容适合老版本的ubuntu,ubuntu16.04以后的版本如下:

更新系统、安装软件包:


apt update

apt install nginx mysql-server mysql-client php-fpm php-mysql php7.0-mbstring

加强mysql安全性

mysql_secure_installation


PHP fix_pathinfo 潜在安全漏洞修复

打开 /etc/php/7.0/fpm/php.ini,找到

;cgi.fix_pathinfo=1

修改为

cgi.fix_pathinfo=0

加强安全性。

完成后,重启 php 使设置生效:

systemctl restart php7.0-fpm



server {

    listen 80;

    listen [::]:80;

 

    # listen [::]:443 ssl http2;

    # listen 443 ssl http2;

 

    # include ssl.conf;

    # ssl_certificate /path/to/crt;

    # ssl_certificate_key /path/to/key;

 

    root /var/www/html;

    index index.html index.htm index.php;

 

    server_name server_domain_or_IP;

 

    location ~ /\. { return 404; }

  

    location / {

        try_files $uri $uri/ =404;

    }

 

    location ~ \.php$ {

        include snippets/fastcgi-php.conf;

        fastcgi_pass unix:/run/php/php7.0-fpm.sock;

    }

 

    location ~ /\.ht {

        deny all;

    }

}




ssl.conf配置文件内容


ssl_session_cache        shared:SSL:10m;

ssl_session_timeout      10m;

 

ssl_session_tickets      on;

 

ssl_stapling             on;

ssl_stapling_verify      on;

#ssl_trusted_certificate /path/to/pem;

 

ssl_protocols TLSv1 TLSv1.1 TLSv1.2;

ssl_ciphers EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH:ECDHE-RSA-AES128-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA128:DHE-RSA-AES128-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES128-GCM-SHA128:ECDHE-RSA-AES128-SHA384:ECDHE-RSA-AES128-SHA128:ECDHE-RSA-AES128-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA128:DHE-RSA-AES128-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES128-GCM-SHA384:AES128-GCM-SHA128:AES128-SHA128:AES128-SHA128:AES128-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4;

ssl_prefer_server_ciphers on;














本文转自ting2junshui51CTO博客,原文链接:http://blog.51cto.com/ting2junshui/1729673 ,如需转载请自行联系原作者



相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
相关文章
|
6月前
|
Ubuntu 安全 iOS开发
Nessus Professional 10.10 Auto Installer for Ubuntu 24.04 - Nessus 自动化安装程序
Nessus Professional 10.10 Auto Installer for Ubuntu 24.04 - Nessus 自动化安装程序
796 5
|
6月前
|
Ubuntu 编译器 开发工具
在Ubuntu系统上搭建RISC-V交叉编译环境
以上步骤涵盖了在Ubuntu系统上搭建RISC-V交叉编译环境的主要过程。这一过程涉及了安装依赖、克隆源码、编译安装工具链以及设置环境变量等关键步骤。遵循这些步骤,可以在Ubuntu系统上搭建一个用于RISC-V开发的强大工具集。
692 22
|
6月前
|
NoSQL Ubuntu MongoDB
在Ubuntu 22.04上安装MongoDB 6.0的步骤
这些步骤应该可以在Ubuntu 22.04系统上安装MongoDB 6.0。安装过程中,如果遇到任何问题,可以查阅MongoDB的官方文档或者Ubuntu的相关帮助文档,这些资源通常提供了解决特定问题的详细指导。
667 18
|
6月前
|
Ubuntu 编译器 计算机视觉
Ubuntu 20.04环境下无法找到#include<opencv/cv.h>文件 - 解决方案。
希望这些信息能帮助你解决遇到的问题。
370 10
|
7月前
|
Ubuntu 安全 关系型数据库
安装MariaDB服务器流程介绍在Ubuntu 22.04系统上
至此, 您已经在 Ubuntu 22.04 系统上成功地完成了 MariadB 的标准部署流程,并且对其进行基础但重要地初步配置加固工作。通过以上简洁明快且实用性强大地操作流程, 您现在拥有一个待定制与使用地强大 SQL 数据库管理系统。
423 18
|
7月前
|
Ubuntu 安全 关系型数据库
安装MariaDB服务器流程介绍在Ubuntu 22.04系统上
至此, 您已经在 Ubuntu 22.04 系统上成功地完成了 MariadB 的标准部署流程,并且对其进行基础但重要地初步配置加固工作。通过以上简洁明快且实用性强大地操作流程, 您现在拥有一个待定制与使用地强大 SQL 数据库管理系统。
539 15
|
7月前
|
存储 Ubuntu 自动驾驶
运行Udacity的MPC控制项目指南(project_10)在Ubuntu 18.04环境下
以上步骤应该能够帮助您成功设置并运行Udacity MPC控制项目,在此过程中您将学习如何应用模型预测控制理论去指导车辆沿着轨迹自主驾驶,在模拟环境下测试其效果。这个过程不但涵盖了理论知识也有实践操作,对于学习自动驾驶车辆控制系统非常有帮助。
224 15
|
7月前
|
存储 Ubuntu iOS开发
在Ubuntu 22.04系统上安装libimobiledevice的步骤
为了获取更多功能或者解决可能出现问题,请参考官方文档或者社区提供支持。
715 14
|
Kubernetes Ubuntu 安全
Ubuntu 20.04 环境下初始化k8s集群
Ubuntu 20.04 环境下初始化k8s集群
1315 0
|
Ubuntu Java 关系型数据库
Ubuntu 环境初始化
安装 java8 sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer 安装 mysql sudo apt install mysql-server-5.
1653 0
下一篇
开通oss服务