Home  >  Article  >  Backend Development  >  How to set up Ubuntu server in php

How to set up Ubuntu server in php

小云云
小云云Original
2018-03-01 10:29:281553browse

API Server Tuning

Chinese Language Tuning

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"

Installing PHP

sudo apt-get install -y software-properties-common python-software-propertiessudo 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 has a problem: 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*"

Install nginx

Reference: http://nginx.org/en/linux_packages.html

wget http://nginx.org/keys/nginx_signing.keysudo apt-key add nginx_signing.keysudo vim /etc/apt/sources.list####### 加入以下内容 ##########deb http://nginx.org/packages/ubuntu/ xenial nginx     # 16.04 是 xenial,其他版本ubuntu自行查看替换xenialdeb-src http://nginx.org/packages/ubuntu/ xenial nginx # 16.04 是 xenial,其他版本ubuntu自行查看替换xenial
sudo apt-get updatesudo apt-get install nginx

Install mysql 5.7

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

Install mongoDB

sudo apt-get install mongodb

Install PHP mongoDB extension

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

apache2/php.ini fpm/php.ini cli/php.ini

Add extension=mongodb.so

to php.ini
echo "extension=mongodb.so" >> /etc/php/7.1/apache/php.inisudo echo "extension=mongodb.so" >> /etc/php/7.1/cli/php.ini 
sudo echo "extension=mongodb.so" >> /etc/php/7.1/cli/php.ini

Modify a problem that can easily lead to memory overflow php.ini

Modify pcre.recursion_limit=5000

php.ini file adjustment

max_input_vars = 20000

post_max_size = 50M

Modify /etc/php/7.1/fpm/php-fpm.conf

emergency_restart_threshold = 10
emergency_restart_interval = 1m

Modify PHP - www file in FPM pool.d

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

Restart nginx or apache and fpm

Other software

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

Install oh-my-zsh

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

The above is the detailed content of How to set up Ubuntu server in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn