当前位置:Gxlcms > PHP教程 > php之Ubuntu服务器设置方法

php之Ubuntu服务器设置方法

时间:2021-07-01 10:21:17 帮助过:25人阅读

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-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有一个问题: 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.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

安装 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

安装mongoDB

sudo apt-get install mongodb

安装PHP mongoDB拓展

sudo apt-get install pkg-configsudo 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.inisudo 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)"

以上就是php之Ubuntu服务器设置方法的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行