设为首页 收藏本站
查看: 472|回复: 0

[经验分享] ubuntu使用二进制包安装lnmp环境

[复制链接]

尚未签到

发表于 2018-5-1 10:14:41 | 显示全部楼层 |阅读模式
  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;

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-454317-1-1.html 上篇帖子: ubuntu 解锁or sudo or 登录不需要输入密码 下篇帖子: percona在ubuntu上的安装
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表