#0 nginx
配置信息在
cd /etc/nginx/
sudo vim nginx.conf
cd /etc/nginx/sites-available
sudo vim default
#重启nginx
sudo systemctl restart nginx
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/top/public;
add_header X-Frame-Options "SAMEORIGIN";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options "nosniff";
# Add index.php to the list if you are using PHP
index index.html index.htm index.php;
server_name locoroco;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
error_page 404 /index.php;
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
fastcgi_split_path_info ^(.+\.php)(/.+)$;
#fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_index index.php;
include snippets/fastcgi-php.conf;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
location ~ /\.(?!well-known).* {
deny all;
}
}
#1 安装php7.2及相关组件
- 安装
php7.2-zip
#install zip
sudo apt-get install php7.2-zip -y
#restart php
sudo systemctl restart php7.2-fpm
### more action
systemctl restart php7.2-fpm #重启
systemctl start php7.2-fpm #启动
systemctl stop php7.2-fpm #关闭
systemctl status php7.2-fpm #检查状态
###
#查看可用模块
php -m
卸载php7
#一、删除php的相关包及配置
sudo apt-get autoremove php7*
#二、删除关联
sudo find /etc -name "*php*" |xargs rm -rf
#三、清除dept列表
sudo apt purge `dpkg -l | grep php| awk '{print $2}' |tr "\n" " "`
#四、检查是否卸载干净(无返回就是卸载完成)
dpkg -l | grep php7.2
#或者直接
sudo apt-get purge php7.*
2# 安装composer
sudo php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
sudo php -r "if (hash_file('sha384', 'composer-setup.php') === '48e3236262b34d30969dca3c37281b3b4bbe3221bda826ac6a9a62d6444cdb0dcd0615698a5cbe587c3f0fe57a54d8f5') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
sudo php composer-setup.php
sudo php -r "unlink('composer-setup.php');"
#之前只是当前目录可用,拷贝到全局
sudo mv composer.phar /usr/local/bin/composer
#改为Laravel-china镜像
sudo composer config -g repo.packagist composer https://packagist.laravel-china.org
3# phpstorm配置
安装后启动链接在/usr/local/bin/phpstorm
#新增组
sudo groupadd www-pub
#将自己[locoroco]加入该组
sudo usermod -a -G www-pub locoroco
###
#查看用户加入的组
sudo groups locoroco
#locoroco : locoroco adm cdrom sudo dip plugdev lpadmin sambashare www-pub
###
#修改/var/www 下的的权限Change the ownership of everything under /var/www to root:www-pub
sudo chown -R root:www-pub /var/www/
#自己加的
sudo usermod -a -G www-pub www-data
#Change the permissions of all the folders to 2775
#chmod 2775 /var/www ## 2=set group id, 7=rwx for owner (root), 7=rwx for group (www-pub), 5=rx for world (including apache www-data user)
#Set group ID (SETGID) bit (2) causes the group (www-pub) to be copied to all new files/folders created in that folder. Other options are SETUID (4) to copy the user id, and STICKY (1) which I think lets only the owner delete files.
#There's a -R recursive option, but that won't discriminate between files and folders, so you have to use find, like so:
sudo find -type d -exec chmod 2775 {} +
#Change all the files to 0664
sudo find /var/www -type f -exec chmod 0664 {} +
#Change the umask for your users to 0002
#查看当前用户umask
umask
#默认是0022
#临时设置:重启后就失效了
umask 0002
#永久设置
sudo vim ~/.profile
#reboot 重启让权限生效
4#修改host文件
sudo vim /etc/hosts
5#Laravel目录权限
cd /var/www/top
sudo chmod -R 777 storage
sudo chmod -R 777 bootstrap/cache
6#解决 Laravel/Lumen 出现 "Please provide a valid cache path" 问题
storage下面的文件夹缺失,新建
mkdir -p storage/framework/views
mkdir -p storage/framework/cache
mkdir -p storage/framework/sessions
注意这些目录要有读写权限.
7#修改文件上传大小限制
#1
vim /etc/php/7.2/fpm/php.ini
#PHP可接受的最大POST数据
post_max_size = 20M
#文件上传允许的最大值
upload_max_filesize = 20M
#每个脚本的最大执行时间,秒钟(0则不限制,不建议设0)
max_execution_time = 300
#2
vim /etc/nginx/sites-available/default
#客户端最大上传大小 20M
client_max_body_size 20m
#3 restart
sudo systemctl restart php7.2-fpm
sudo systemctl restart nginx
8#彻底删除mysql、php
#先卸载
sudo apt-get remove mysql-common
sudo apt-get autoremove --purge mysql-server-5.0
#再用dpkg --list|grep mysql查看,还剩什么就卸载什么
dpkg --list|grep mysql
#最后清楚残留数据:
dpkg -l |grep ^rc|awk '{print $2}' |sudo xargs dpkg -P
9#安装的时候选择5.7
wget https://dev.mysql.com/get/mysql-apt-config_0.8.1-1_all.deb
sudo dpkg -i mysql-apt-config_0.8.1-1_all.deb
#在安装的过程中,会要求选择mysql版本,选择mysql5.7版本后,点击“OK”。
sudo apt-get update
sudo apt-get install mysql-server
修改mysql密码
vim /etc/mysql/debian.cnf
show databases;
use mysql;
update user set authentication_string=PASSWORD("自定义密码") where user='root'; //自定义密码指想要修改成的密码
update user set plugin="mysql_native_password"; //此处不是自定义密码,用户无需修改
flush privileges;
quit;
设置远程访问
##将42行中的bind-address = 127.0.0.1注释
vim /etc/mysql/mysql.conf.d/mysqld.cnf
#进入mysql
grant all on *.* to root@'%' identified by 'root' with grant option;
##上面不起作用就用下面这句
grant all on *.* to user_name@'%' identified by 'user_password';
##更新权限
flush privileges;
##重启
service mysql restart