THINKPHP5 summary of issues encountered during the deployment of the server

Source: Internet
Author: User
Tags ftp client free ssl free ssl certificate ssl certificate
This article brings to you the content is about THINKPHP5 in the process of deploying the server in the summary of the problems, there is a certain reference value, the need for a friend can refer to, I hope you have some help.

Recently deployed TP5 encountered a lot of pits, a variety of circumstances will have some problems, the following is my record of the drainage pit road

First of all, the simplest LNMP one-click installation package, I use 1.5 stable version

Install command :wget http://soft.vpser.net/lnmp/lnmp1.5.tar.gz-cO lnmp1.5.tar.gz && tar zxf lnmp1.5.tar.gz && CD lnmp1.5 &&/install.sh lnmp (install + compile one click)

If you need to install LNMPA or lamp, replace the parameter lnmp behind the./install.sh with Lnmpa or lamp. To change the site and database directory, custom nginx parameters, PHP parameter module, open Lua and so on need to run the./install.sh command before you modify the lnmp.conf file in the installation package directory, detailed can see the lnmp.conf file parameter description.

First hint: Provide the Always database (I use 3), directly enter the number of digital return can

Second hint: Enter a database password

Third tip: Whether to enable InnoDB, direct enter or y enter

Fourth tip: Select PHP version (default 5.6) My default version

Fifth hint: I chose not to install by default (my default)

Sixth tip: Select the Apache version (I choose the default)

Seventh tip: If Nginx:ok,mysql:ok,php:ok is displayed

and Nginx, MySQL, PHP are both running,80 and 3306 ports are present, and prompted the installation of the use of time and install LNMP V1.5 completed! Enjoy it. Then the instructions have been installed successfully.
Some systems may be stuck in the install LNMP V1.5 completed! Enjoy it. Do not exit automatically, you can press CTRL + C to exit.

Install the next start to use it, according to the add Virtual Host Tutorial , add a virtual host can use SFTP or FTP server upload site code, the domain name to the VPS or server IP, the resolution can be used.

Eighth Hint: Installation failed

If a similar hint appears, there is one or several unsuccessful installations that indicate that the installation failed!! Need to use WINSCP or other similar tools, the/root directory below the Lnmp-install.log download down to the LNMP support forum post note your system distribution name and version number, 32-bit or 64-bit information, And the Lnmp-install.log compression to the attachment form to the forum, we will find errors through the log, and give the corresponding solution
The default LNMP is to not install an FTP server, such as an FTP server: https://lnmp.org/faq/ftpserver.html

Add a virtual Host: LNMP package is very convenient

LNMP vhost Add//Adding a virtual host

Enter your virtual domain name, mine is www.tp5api.cn

Here to ask whether to add more domain names, directly and then enter the domain name to bind, I went directly to skip the

The directory will be created if the site directory does not exist. You can also enter a directory that already exists or the directory you want to set ( Note that to enter the full path must be full path to/start!!!). ). If you do not enter a direct return, use the default directory:/home/wwwroot/domain name

Turn on pseudo-static, facilitate SEO optimization

The default already has Discuz, DISCUZX, DISCUZX2 (Discuz x two level directory), WordPress, Wp2 (wordpress two level directory), Typecho, Typecho2 (Typecho two level directory), Sablog, Emlog, Dabr, Phpwind, Dedecms, Drupal, Ecshop, Shopex and other commonly used nginx pseudo-static configuration file, you can directly enter the name to use, if it is a level two directory will need to correspond to the name of the two level directory in the configuration file.

Whether to turn on the error log

If you enable the need to enter the name of the log you want to set, the default log directory is:/home/wwwlogs/The default file name is: Domain name. Log enter confirmation, you will be asked whether to add the database and database users.

If you want to add, you need to verify the root password of MySQL (note: Enter the password will not be displayed)
Prompt Enter database name: After entering the names of the databases to be created, the database user name to be created will be the same name as the database, enter confirm.
Prompt enter password for MySQL user database name: After entering the password to be set, enter confirm.

If an FTP server is installed, ask if you want to add an FTP account

If you need to add input y, do not add the input n carriage.

Prompt enter the FTP account name: Enter the username to be created, enter to confirm.
Tip Enter password for FTP account: After entering the password to set, enter confirm.

Next is the 1.4 new Add SSL feature

If you need to add input y, do not add the input n carriage.
Added SSL is selected for prompt

There are two options, and the 1 option is to use your own prepared SSL certificate and key.

> > Prompts you to enter the full path and file name of the SSL certificate to be entered after the Certificate file.
> > Prompt enter full path to SSL Certificate key file: Enter input to enter the complete paths and file names of the key files, enter to confirm.

The 2 option is to automatically generate SSL certificates and other information using the Letsencrypt certificate from the free SSL certificate provider.

You need to enter a mailbox to confirm the return.

Prompt press any key to start create Virtul host ... , enter confirm to start creating the virtual host.

Add the domain name, directory, pseudo-static, log, database, FTP and other related information that will prompt you to add, such as:

# #伪静态管理 # #

Lnmpa or lamp can be delegated directly using the website root directory. htaccess to set pseudo-static rules (specific rules can go to the program website to find Google Baidu), but under the LNMP, you need to use Nginx pseudo-static rules.
Pseudo-static can be added or deleted at any time, if you have forgotten or not added pseudo-static after adding the virtual host, you can add pseudo-static by modifying the configuration file.
Virtual Host configuration file in:/usr/local/nginx/conf/vhost/domain name. conf

Pseudo-static rules files need to be placed under/usr/local/nginx/conf/.
To edit a virtual host profile, you can use VI, Nano, or WINSCP, and the latter 2 tools are simpler for beginners.

For example, before we add a virtual host, the first half of the configuration is displayed as follows:

In Root/home/wwwroot/www.vpser.net, this line is added below:
Include wordpress.conf;
The above wordpress.conf is a pseudo-static file, such as the need for other pseudo-static files themselves created and uploaded to/usr/local/nginx/conf/below and include pseudo-static. conf; Add to save, execute:/etc/init.d/nginx Restart Restart effective, if the error may be added wrong or false static rules.

1.4 and previous versions of Pseudo-static files are in the/usr/local/nginx/conf/directory
1.5 and later versions of Pseudo-static files are in the/usr/local/nginx/conf/rewrite directory
Pseudo-static file name with 2 is the pseudo-static level two directory, you can modify the name of the two-level directory or copy it to the virtual host configuration file according to your own requirements.

# #上传网站程序 # #

If you have installed the FTP server can directly use the FTP client through your FTP information to upload websites or sftp and other software upload site, set up the relevant permissions to start installation.
After uploading the site, it is recommended to do: Chown www:www-r/path/to/dir to the site directory to set permissions,/path/to/dir replaced with your site directory.
For security, you can remove some directories, such as upload files, that do not require PHP to execute permissions, refer to: http://www.vpser.net/security/lnmp-remove-nginx-php-execute.html

# #已存在虚拟主机添加ssl证书开启https # #

To add an HTTPS site to an existing virtual host, you can execute:lnmp SSL Add command to add SSL certificate, there are two ways to use a self-contained SSL certificate, the second is to adopt let ' sencrypt free certificate. The process of adding the process is the same as the previous procedure for adding a virtual host, but it will only take one more step to fill out the SSL certificate and key or directly select Let ' sencrypt to generate the certificate automatically.
If it is 1.* version upgrade to 1.4 or change version of the need reference: https://lnmp.org/faq/upgrade1-4.html instructions, if there is a hint is unsafe or does not show the small green lock above the link is also noted.

# #列出网站 (Virtual host) # #

Execution:lnmp vhost list

# #删除网站 (Virtual host) # #

Execution:lnmp vhost del

Deleting a Web site lists the currently existing virtual hosts and prompts you for the virtual host domain name you want to delete in the enter confirmation.

Here just delete the virtual host profile, and the Web site file will not be deleted without deleting it yourself.

LNMP 1.2 needs to be executed: chattr-i/Site Directory/.user.ini before the site directory can be deleted.

chown:changing ownership of '/home/wwwroot/default/.user.ini ' may be prompted when performing chown or chmod operations on a site directory belonging to a master group or permission: Operation not Permitted, do not need to listen to, if there is obsessive-compulsive disorder can refer to the first chattr-i operation.

# #默认网站 (Virtual host) # #

LNMP Default Web Site configuration file:/usr/local/nginx/conf/nginx.conf
Lnmpa Default Web site configuration files:/usr/local/nginx/conf/nginx.conf and/usr/local/apache/conf/extra/httpd-vhosts.conf
Lamp Default Web Site configuration file:/usr/local/apache/conf/extra/httpd-vhosts.conf

# #防跨目录设置 # #

LNMP 1.1 and previous versions use php.ini inside, open_basedir settings

LNMP 1.2 and later anti-cross-directory features use the. User.ini, which can be modified under the root of the Web site to modify the value of the Open_basedir inside the. User.ini to set restricted access to the directory or remove to remove anti-cross directory settings.

The. User.ini file cannot be modified directly, such as to be repaired or deleted first: chattr-i/Site Directory/.user.ini
You can use WINSCP file management, the Vim editor, or the Nano editor to make modifications.
Delete the words rm-f/Site Directory/.user.ini can.
After the modification is done: chattr +i/Site Directory/.user.ini
The. User.ini does not require a restart normally for 5 minutes or so, or it can be restarted php-fpm immediate effect.
If you want to change the site directory must be in accordance with the above method to modify the anti-cross-directory settings, otherwise definitely error!!

LNMP 1.4 If you do not want to use anti-cross directory or modify. User.ini's anti-cross directory directory also needs to be/usr/local/nginx/conf/fastcgi.conf inside the Fastcgi_param php_admin_value " open_basedir= $document _root/:/tmp/:/proc/"; Add # or delete a row before the line, you need to restart Nginx.

LNMP 1.4 can also be removed directly using the./remove_open_basedir_restriction.sh in the lnmp1.4/tools/directory.
In thinkphp, CodeIgniter, Laravel and other frameworks, the site directory is generally under public, but the public program to call the public in the parent directory across directories, because the LNMP default is not allowed cross-directory access, Therefore, it is necessary to remove the anti-cross Directory access settings, and sometimes these framework class program tips 500 error may be caused by this problem.

Lnmpa or Lamp mode version 1.2 above the anti-cross directory settings used for the corresponding Apache virtual host profile (LNMP Admin tool added if the file is/usr/local/apache/conf/vhost/domain name. conf) in the Php_admin The _value open_basedir parameter is set. If you do not need to set a limit that can be commented on in front of # or modify the directory yourself.
Restart Apache to take effect.

# #pathinfo设置 # #

The settings for each version pathinfo versions on LNMP are basically the same:

Lnmp v1.1, modify the configuration file for the corresponding virtual host (/usr/local/nginx/conf/vhost/domain name. conf)
get rid of # # # # pathinfo.conf front, put try_files $uri = 404; Precede with # comment out.

1.2,1.3,1.4,1.5 and above, modify the corresponding virtual host configuration file (/usr/local/nginx/conf/vhost/domain name. conf)
Include enable-php.conf; replace with include enable-php-pathinfo.conf;

1.4 Version multiple PHP version enabled PathInfo, enter the/usr/local/nginx/conf directory, a copy of enable-php-pathinfo.conf named Enable-php7.2-pathinfo.conf, will enable-php7.2.conf file Fastcgi_pass This line of the full copy to replace the enable-php7.2-pathinfo.conf file Fastcgi_pass this line, save, and then modify the virtual host as the previous method Include enable-php7.2-pathinfo.conf; Just a few other versions, and so on.

1.5 Version multiple PHP version open PathInfo words, can be in Lnmp vhost Add is selected to enable PathInfo, if there are multiple PHP version will prompt you to choose, you can also directly modify the virtual host configuration file will include enable-php.conf; Replace with include enable-php7.2-pathinfo.conf; Save

Modifying pathinfo requires the restart of Nginx to take effect.

# #数据库管理 # #

For more than 1.3 versions, you can choose to create a database when you add a virtual host, or you can use LNMP database add to add databases at the prompt, adding a user name and database name with the same name.
Add databases Command: LNMP database add
Edit database User password command: LNMP db edit
Delete Database command: Lnmp db del
List all databases commands: LNMP Database list

This information is in the https://lnmp.org/faq/lnmp-vhost-add-howto.html (LNMP official website to find)

A lot of things are copied directly, to my level of writing is not better than the official website manual

If someone uses the pagoda TP5 error open_base_dir, site Settings inside there is a security protection, turned off can (pit me for a long time)

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.