Ubuntu 新服务器设置(PHP应用使用)

前端之家收集整理的这篇文章主要介绍了Ubuntu 新服务器设置(PHP应用使用)前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

API 服务器调教

中文语言调教

sudo apt-get install language-pack-zh-hans

sudo vim /etc/default/locale

# vim /etc/default/locale 输入以下内容
LANG="en_US.UTF-8"
LANGUAGE="zh_CN.utf8"
LC_ALL="zh_CN.utf8"

安装 PHP

sudo apt-get install -y software-properties-common python-software-properties
sudo add-apt-repository ppa:ondrej/PHP
sudo apt-get update

sudo apt-get install -y PHP7.1 PHP7.1-MysqL PHP7.1-curl PHP7.1-mbstring PHP7.1-gd PHP7.1-xml PHP7.1-soap PHP-pear PHP7.1-dev PHP7.1-zip PHP7.1-fpm

7.2有一个问题: Warning: ini_set(): Headers already sent. You cannot change the session module's ini settings at this time in /home/CPC-API/library/Zend/Session.PHP on line 205

sudo apt-get install -y PHP7.2 PHP7.2-MysqL PHP7.2-curl PHP7.2-mbstring PHP7.2-gd PHP7.2-xml PHP7.2-soap PHP-pear PHP7.2-dev PHP7.2-zip

sudo apt-get remove "PHP7.2*"

安装 Nginx

参考:http://nginx.org/en/linux_packages.html

wget http://Nginx.org/keys/Nginx_signing.key

sudo apt-key add Nginx_signing.key

sudo vim /etc/apt/sources.list

####### 加入以下内容 ##########
deb http://Nginx.org/packages/ubuntu/ xenial Nginx     # 16.04 是 xenial,其他版本ubuntu自行查看替换xenial
deb-src http://Nginx.org/packages/ubuntu/ xenial Nginx # 16.04 是 xenial,其他版本ubuntu自行查看替换xenial
sudo apt-get update
sudo apt-get install Nginx

安装 MysqL 5.7

wget https://dev.MysqL.com/get/MysqL-apt-config_0.8.9-1_all.deb
sudo dpkg -i MysqL-apt-config_0.8.9-1_all.deb
sudo apt-get update 
sudo apt-get install MysqL-server
sudo service MysqL stop

修改 MysqL 配置
vi /etc/MysqL/MysqL.conf.d MysqLd.cnf

sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION'

slow_query_log=ON
long_query_time=30

max_allowed_packet=500M
max_connections=1024

sudo service MysqL restart

安装mongoDB

sudo apt-get install mongodb

安装PHP mongoDB拓展

sudo apt-get install pkg-config
sudo pecl install mongodb  # 如果提示出错,尝试sudo apt-get remove "PHP7.2*"

apache2/PHP.ini fpm/PHP.ini cli/PHP.ini

PHP.ini中添加 extension=mongodb.so

echo "extension=mongodb.so" >> /etc/PHP/7.1/apache/PHP.ini
sudo echo "extension=mongodb.so" >> /etc/PHP/7.1/cli/PHP.ini 
sudo echo "extension=mongodb.so" >> /etc/PHP/7.1/cli/PHP.ini

修改一个容易导致内存溢出的问题PHP.ini

修改 pcre.recursion_limit=5000

PHP.ini文件调整

max_input_vars = 20000

post_max_size = 50M

修改 /etc/PHP/7.1/fpm/PHP-fpm.conf

emergency_restart_threshold = 10
emergency_restart_interval = 1m

修改 PHP-FPM pool.d中的www文件

listen = 127.0.0.1:9000
listen.allowed_clients = 127.0.0.1
pm.max_children = 51
pm.start_servers = 3
pm.min_spare_servers = 2
pm.max_spare_servers = 4
pm.max_requests = 1000

slowlog = /var/log/$pool.log.slow
request_slowlog_timeout = 5s

重启Nginx或apache还有fpm

其他软件

sudo apt-get install -y git tig tree zsh nload tmux

安装oh-my-zsh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

1

1

1

1

1

1

1
1

1

1

1

1
1
1
1

1

1

1

猜你在找的Ubuntu相关文章