Nginx+PHP+mysql

本文详细介绍如何在服务器上部署LNMP(Linux+Nginx+MySQL+PHP)环境,包括安装及配置Nginx、MySQL和PHP5等步骤,以及通过PHPMyAdmin进行数据库管理。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

首先添加必要的apt源,并使用下面的命令使服务器保持最新:


apt-get update
apt-get upgrade


安装mysql服务器
apt-get install mysql-server


配置mysql相关
mysql_secure_installation


安装nginx
apt-get install nginx


添加脚本到系统默认运行级别
/usr/sbin/update-rc.d -f nginx defaults


现在可以运行nginx了
/etc/init.d/nginx start




Installing PHP5
apt-get install php5-fpm php5-mysql


Configuring Nginx
vi /etc/nginx/nginx.conf


worker_processes  4;
keepalive_timeout  2;




vi /etc/nginx/sites-available/default


server {
        listen   80; ## listen for ipv4; this line is default and implied
        listen   [::]:80 default_server ipv6only=on; ## listen for ipv6
                                   
        root /usr/share/nginx/www;
        index index.php index.html index.htm;
                                   
        # Make site accessible from http://localhost/
        server_name localhost;
                                   
        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/www;
        }
                                   
        # 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;
        }
}




/etc/init.d/nginx reload




vi /etc/php5/fpm/php.ini


cgi.fix_pathinfo=0




/etc/init.d/php5-fpm reload




vi /usr/share/nginx/www/phpinfo.php




<?php
phpinfo();
?>


aptitude install nginx
aptitude install php5-fpm
aptitude install php5-mysql
service php5-fpm restart
service nginx restart
aptitude install mysql-server mysql-client


/etc/init.d/nginx start
/etc/init.d/nginx stop
/etc/init.d/nginx reload
/etc/init.d/php5-fpm reload
service php5-fpm restart
service nginx restart


最后安装PHPMyAdmin,使用下面的命令安装:


apt-get install phpmyadmin
注意会提示你选择Apache或者lighttpd服务器,我们用的是Nginx,所以这里按Esc退出选择,然后会提示你输入数据库root密码,输入后按OK确定。


安装完成后,phpmyadmin所有代码文件都默认位于/usr/share/phpmyadmin路径下,假设我们的Web主路径位于/var/www下,接下来做个链接就可以了:


ln -s /usr/share/phpmyadmin/ /home/www/
资源下载链接为: https://pan.quark.cn/s/22ca96b7bd39 在 IT 领域,文档格式转换是常见需求,尤其在处理多种文件类型时。本文将聚焦于利用 Java 技术栈,尤其是 Apache POI 和 iTextPDF 库,实现 doc、xls(涵盖 Excel 2003 及 Excel 2007+)以及 txt、图片等格式文件向 PDF 的转换,并实现在线浏览功能。 先从 Apache POI 说起,它是一个强大的 Java 库,专注于处理 Microsoft Office 格式文件,比如 doc 和 xls。Apache POI 提供了 HSSF 和 XSSF 两个 API,其中 HSSF 用于读写老版本的 BIFF8 格式(Excel 97-2003),XSSF 则针对新的 XML 格式(Excel 2007+)。这两个 API 均具备读取和写入工作表、单元格、公式、样式等功能。读取 Excel 文件时,可通过创建 HSSFWorkbook 或 XSSFWorkbook 对象来打开相应格式的文件,进而遍历工作簿中的每个 Sheet,获取行和列数据。写入 Excel 文件时,创建新的 Workbook 对象,添加 Sheet、Row 和 Cell,即可构建新 Excel 文件。 再看 iTextPDF,它是一个用于生成和修改 PDF 文档的 Java 库,拥有丰富的 API。创建 PDF 文档时,借助 Document 对象,可定义页面尺寸、边距等属性来定制 PDF 外观。添加内容方面,可使用 Paragraph、List、Table 等元素将文本、列表和表格加入 PDF,图片可通过 Image 类加载插入。iTextPDF 支持多种字体和样式,可设置文本颜色、大小、样式等。此外,iTextPDF 的 TextRenderer 类能将 HTML、
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值