CentOS7 under Laravel deployment with Nginx forwarding

Source: Internet
Author: User
Tags intl mcrypt pear

This article describes the content is about CentOS7 under the Laravel deployment and Nginx forwarding, has a certain reference value, now share to everyone, have the need for friends can refer to

This article is for personal note only

  • Build PHP Operating Environment

    • Run service php-fpm start PHP-FPM services, run PS aux | grep PHP-FPM verifies that the PHP-FPM service is installed successfully.

    • If you are installing the source using the second scenario, use the following script

      Yum install php72-php-cli.x86_64 php72-php-common.x86_64 php72-php-fpm.x86_64 php72-php-devel.x86_64 php72-php-gd.x86_64 php72-php-intl.x86_64 php72-php-mbstring.x86_64 php72-php-pecl-mcrypt.x86_64 php72-php-mysqlnd.x86_64 php72-php-opcache.x86_64 php72-php-pdo.x86_64 Php72-php-pear.noarch php72-php-xml.x86_64- Y
    • has PHP source

    • It is also possible that some users will not be able to access these two files, at this point can be swapped in the following way (7.2), so later part of the tutorial may also be different, you need to pay attention to

      Yum Install EPEL-RELEASE-YRPM-UVH http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
    • PHP Source Compare old

    • Php:

    • Determine if there is a Yum source for PHP:
      Yum Search PHP

    • The system itself comes with a yum source of PHP, but the version is too old, or 5.4, in order to install the latest source here is ready to install a new Yum source.

    • To install the Yum source for PHP:

      RPM-UVH HTTPS://MIRROR.WEBTATIC.COM/YUM/EL7/EPEL-RELEASE.RPMRPM-UVH https://mirror.webtatic.com/yum/el7/ webtatic-release.rpm
    • Run Yum search PHP now to find out more options

    • Install PHP and some related plugins (php-cli for Shell-related, php-common for common functions, php-devel for compilation, PHP-FPM for service, PHP-GD for image processing, php-intl for internationalization, Php-mbstring is related to multi-string processing, Php-mcrypt is related to encryption, PHP-MYSQLND is related to MySQL, Php-opcache is related to performance acceleration, PHP-PDO is related to data objects, Php-pear is related to PHP application extension , Php-xml is XML-related) (install php7.1 here) using the first script, use the first one:
      Yum install php71w-cli.x86_64 php71w-common.x86_64 php71w-fpm.x86_64 php71w-devel.x86_64 php71w-gd.x86_64 php71w-intl.x86_64 php71w-mbstring.x86_64 php71w-mcrypt.x86_64 php71w-mysqlnd.x86_64 php71w-opcache.x86_64 php71w-pdo.x86_64 Php71w-pear.noarch php71w-xml.x86_64-y

    • Run php–version to see if PHP is installed and configured to complete. The presence of similar version information indicates that the installation of the PHP configuration is complete,

    • PHP version

    • PHP-FPM Test

  • Installation of peripheral services (Nginx/composer/git/mysql/redis)

      • These services can be installed basically in the basic Yum source, if there is no composer, can run cd/tmp
        curl–sshttps://getcomposer.org/installer| Php
        MV Composer.phar/usr/local/bin/composer to complete composer installation

  • Service Code Preparation

      • In order to facilitate the deployment and update of PHP services, I use git to download and update the project.

      • Go to the folder where you want to deploy the service, run git clone git address (example: Git clone root@www.temp.com:/git/php/markingphp)

      • Download PHP code

      • At this time the project permissions for the root, if this run PHP-FPM may be insufficient permissions, the author here for the simple and static resources of the PHP project Nginx management, the project permissions changed to Nginx, and the php-fpm of the operation of the authority changed to Nginx.

  • PHP and project-related configuration

      • Nginx error Log

      • Service forwarding failed

      • Initialize MySQL

      • Run Chown NGINX:NGINX-RF folder name (example: Chown nginx:nginx-rf markingphp)

      • Run RPM-QL php17w-fpm.x86_64 get PHP-FPM installation Address

      • Get PHP-FPM Installation Address

      • Try to learn that/etc/php-fpm.d/www.conf is a configuration file

      • PHP-FPM configuration file

      • change user = Apache and group = pache to user = Nginx Group = Nginx can change 127.0.0.1:9000 to desired port if necessary

      • For server information security and project size control, the GIT project did not upload the project configuration and project reference Library, so a new project configuration file needs to be re-created and configured

      • Project structure

      • Configuration file

      • Run composer UPDATE-VVV Download library

      • Failed to download library

      • If the library fails to download, it may be the reason for the library being wall, change Composer.json add domestic source to run again.


    "Repositories": {    "packagist": {"       type": "Composer",       "url": "Https://packagist.phpcomposer.com"    }}
      • Domestic source

      • Run PHP artisan serve to test the current project library is complete, the following shows the project library download is complete.

      • Try to start a project test

      • Initialize Project MySQL table (PHP artisan Migrate:refresh)

      • Configure Nginx to forward the 80 port service to the PHP-FPM service,

      server {       listen;       Location/{          root/php/markingphp/public/;          Index index.php index.html index.jsp;       }       Location ~. php{             root html;             Fastcgi_pass 127.0.0.1:9000;             Fastcgi_index index.php;             Fastcgi_param Script_filenamedocument_root$fastcgi_script_name;           Include Fastcgi_params;      }    }
      • Run Curl localhost to determine if the service is forwarding properly.

      • Run vim/var/log/nginx/error.log check nginx log will find the log prompt permission is insufficient, but we have the file permissions to the Nginx.

      • Finally learned that because of SELinux, this time just run Setenforce 0 to turn off SELinux (temporary), and then modify the configuration file/etc/selinux/config, will selinux= Enforcing changed to selinux=disabled so that the next restart of SELinux is still off. If you run curl localhost again, you will see that the service is working properly.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.