在ubuntu上apt安装软件非常方便,有很多软件已经在ubuntu官网仓库中,我们可以直接进行安装,接着我们就来操作下。
先更新ubuntu仓库列表,再更新软件包,接着安装nginx
sudo apt-get update sudo apt-get upgrade sudo apt-get install nginx
启动nginx
sudo /etc/init.d/nginx start check version #查看nginx版本 nginx -v
安装mysql
apt-get install mysql-server
注:在安装过程中,会要求你输入MySQL的root账号的密码。
安装php以及相关组件,这里要说明下,php-fpm是一个独立管理php的工具,安装了这个就不需要再装php-cgi模块了。
sudo apt-get install php5 php5-gd php5-fpm php5-mysql php5-apc php5-pear php5-dev php5-curl php5-imap php5-mcrypt php5-snmp php5-xmlrpc
配置php
vi /etc/php5/fpm/php.ini 找到: ;cgi.fixpathinfo=1 改为: cgi.fixpathinfo=0
配置nginx
修改nginx的配置文件:
sudo vi /etc/nginx/sites-available/default
修改主机名
server_name localhost;
修改index的一行,添加index.php
index index.php index.html index.htm;
修改root的目录为你自己的网站目录,并在index后面添加默认首页:
root /www; index index.html index.php index.htm;
去掉下面部分的注释用于支持 php 脚本,对照下面的来改:
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; }
解决php-fpm与nginx的小bug,解决在php-fpm传递php文件时形成的路径错误,在fastcgi_params文件内最下面添加一行
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
最后重新启动nginx,php5-fpm
/etc/init.d/nginx restart /etc/init.d/php5-fpm restart
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:https://www.sulao.cn/post/36
相关推荐
- ubuntu22.04编译安装postgresql17.5
- ubuntu使用deb包安装指定版本内核
- ubuntu修改grub引导切换到指定内核的方法
- ubuntu使用nvbandwidth测试单节点gpu带宽性能
- ubuntu24.04LTS添加apt源
- ubuntu下使用qperf工具测试RDMA网络带宽和延迟
- ubuntu22.04关闭自动更新和禁止unattended-upgrades服务开机启动
- ubuntu22.04使用nccl-tests进行单机多卡通信测试
- ubuntu22.04编译安装hwloc/libevent/ucx/openpmix/openmpi
- ubuntu安装openvpn并配置连接
评论列表