1.首先更新ubuntu软件源
sudo apt-get update
--对软件源进行更新的时候可能出现问题
echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf > /dev/null
2.安装nginx
sudo apt-get install nginx
3.安装mysql
sudo apt install mysql-server mysql-client(备注:设置好密码)
4.安装php7.0(https://www.cnblogs.com/niuben/p/13329434.html)
sudo apt-get install python-software-properties
sudo apt-get update
sudo apt-add-repository ppa:ondrej/php
sudo apt update
sudo apt install php7.2 php7.2-fpm php7.2-cgi php7.2-common php7.2-curl php7.2-mysql php7.2-mcrypt php7.2-mbstring(备注:若要安装其他版本php,则类似改版本号就行)
安装bmatch扩展 支持bcdiv()函数
sudo apt-get install php7.2-bcmath
5.nginx配置
[https://blog.csdn.net/lgyaxx/article/details/79507525 ]
6.重启nginx
sudo nginx -s reload
service mysql restart (数据库)
7.安装git
sudo apt-get install git
git config --global user.name "你的用户名"
git config --global user.email "你的注册邮箱"
git config --global --list
ssh-keygen -C "你的注册邮箱" -t rsa
登录GitHub填入client端生成的公钥
ssh-add ~/.ssh/id_rsa (ssh-agent bash)
8.安装composer
1.安装Redis服务
sudo apt-get install redis-server
2.启动服务
/etc/init.d/redis-server start
3.连接服务
redis-cli
4.安装phpredis扩展
sudo apt-get install php-redis
1.安装防火墙(Ubuntu默认安装)
sudo apt-get install ufw
2.查看防火墙状态
sudo ufw status
3.开启/关闭防火墙
sudo ufw enable|disable
4.打开或关闭某个端口
sudo ufw allow|deny [service]
https://www.cnblogs.com/OnlyDreams/p/7210914.html
nginx配置
server {
listen 80;
listen [::]:80;
root /var/www/larabbs/public;
index index.php;
server_name xxx.cn xxx.cn;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
tp项目区别(location)
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=$1 last;
break;
}