评论

收藏

[Linux] linux部署一个laravel应用

服务系统 服务系统 发布于:2021-08-03 11:11 | 阅读数:232 | 评论:0

一.部署nginx

1.安装
yum install nginx
systemctl enable nginx
systemctl start nginx
2.配置
server {
<p>listen 80;</p>
<p>server_name xxxx;   # 此为必修改项,请替换为服务器公网 IP 或域名</p>
<p>root /data/website/blog/public; # 此为必修改项,请注意指向站点根目录的 public 子目录</p>
<p>add_header X-Frame-Options "SAMEORIGIN";</p>
<p>add_header X-XSS-Protection "1; mode=block";</p>
<p>add_header X-Content-Type-Options "nosniff";</p>
<p>index index.html index.htm index.php;</p>
<p>charset utf-8;</p>
<p>location / {</p>
<space1bdfdf19705d9d112c7332dca190357cCode 0>
}
需要重启nginx systemctl restart nginx
二.部署php

1.安装php环境
yum install epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum install -y php php-devel php-fpm php-cli安装相关模块
yum install php-bz2 php-soap  php-zip php-opcache php-xmlrpc php-calendar  php-json php-bcmath php-exif php-dom php-gettext \
php-gd php-json php-mbstring php-mysqli php-mysqlnd php-pdo php-pdo_mysql php-pdo_sqlite php-readline  php-posix php-redis php-simplexml  \
php-soap php-sqlite3 php-xml php-xmlreader php-xmlrpc php-xmlwriter php-zip安装swoole模块需要将swoole.so模块配置到php.ini文件中
pecl install swoole
phpize
2.配置php
www.conf配置
[www]
<p>user = nginx</p>
<p>group = nginx</p>
<p>listen = 127.0.0.1:9000</p>
<p>listen.backlog = 8129</p>
<p>listen.allowed_clients = 127.0.0.1</p>
<p>listen.owner = nginx</p>
<p>listen.group = nginx</p>
<p>listen.mode = 0666</p>
<p>pm = static</p>
<p>pm.max_children = 10</p>
<p>pm.start_servers = 5</p>
<p>pm.min_spare_servers = 5</p>
<p>pm.max_spare_servers = 5</p>
<p>pm.process_idle_timeout = 10s</p>
<p>pm.max_requests = 1024</p>
<p>request_slowlog_timeout = 4</p>
<p>slowlog = var/log/slow.log</p>
<p>request_terminate_timeout = 0</p>
rlimit_files = 65535
php.ini配置
[PHP]
<p>engine = On</p>
<p>short_open_tag = On</p>
<p>precision = 14</p>
<p>output_buffering = 4096</p>
<p>zlib.output_compression = Off</p>
<p>implicit_flush = Off</p>
<p>unserialize_callback_func =</p>
<p>serialize_precision = -1</p>
<p>disable_functions =</p>
<p>disable_classes =</p>
<p>zend.enable_gc = On</p>
<p>expose_php = off</p>
<p>max_execution_time = 300</p>
<p>max_input_time = 60</p>
<p>memory_limit = 4096M</p>
<p>error_reporting = E_ALL</p>
<p>display_errors = Off</p>
<p>display_startup_errors = On</p>
<p>log_errors = On</p>
<p>log_errors_max_len = 1024</p>
<p>ignore_repeated_errors = Off</p>
<p>ignore_repeated_source = Off</p>
<p>report_memleaks = On</p>
<p>html_errors = On</p>
<p>variables_order = "GPCS"</p>
<p>request_order = "GP"</p>
<p>register_argc_argv = Off</p>
<p>auto_globals_jit = On</p>
<p>post_max_size = 50M</p>
<p>auto_prepend_file =</p>
<p>auto_append_file =</p>
<p>default_mimetype = "text/html"</p>
<p>default_charset = "UTF-8"</p>
<p>doc_root =</p>
<p>user_dir =</p>
<p>enable_dl = Off</p>
<p>file_uploads = On</p>
<p>upload_max_filesize = 1024M</p>
<p>max_file_uploads = 20</p>
<p>allow_url_fopen = On</p>
<p>allow_url_include = Off</p>
<p>cgi.fix_pathinfo = 0</p>
<p>default_socket_timeout = 60</p>
<p>extension=redis.so</p>
<p>extension=swoole.so</p>
<p>extension=bcmath.so</p>
<p>zend_extension=/usr/local/php/lib/php/extensions/no-debug-non-zts-20170718/opcache.so</p>
<p>[CLI Server]</p>
<p>cli_server.color = On</p>
<p>[Date]</p>
<p>[filter]</p>
<p>[iconv]</p>
<p>[intl]</p>
<p>[sqlite3]</p>
<p>[Pcre]</p>
<p>[Pdo]</p>
<p>[Pdo_mysql]</p>
<p>pdo_mysql.cache_size = 2000</p>
<p>pdo_mysql.default_socket=</p>
<p>[Phar]</p>
<p>[mail function]</p>
<p>SMTP = localhost</p>
<p>smtp_port = 25</p>
<p>mail.add_x_header = Off</p>
<p>[ODBC]</p>
odbc.allow_persistent = On
三.安装composer
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');"
php composer-setup.php
php -r "unlink('composer-setup.php');"
mv composer.phar /usr/local/bin/composer
四.部署一个laravel应用
mkdir /data/website && cd /data/website
composer create-project --prefer-dist laravel/laravel blog "5.8.*"
cd  /data/website/blog
chmod -R 755 storage/
chmod -R 755 bootstrap/cache

关注下面的标签,发现更多相似文章