Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to build the debugging Environment for linux php

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "how to build the linux php debugging environment". The content of the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn how to build the linux php debugging environment.

The construction method of linux php debugging environment: 1, download and install MySQL;2, open php-fpm, monitor port 9000; 3, decompress, compile and install PHP; 4, modify the configuration file and install Nginx.

This article operating environment: ubuntu 16.04system, PHP7.1 version, Dell G3 computer.

How to set up the debugging environment for linux php?

Rapid Construction of PHP Development Environment for Linux

The environment built is LNMP:

1. Install MySQL

This is very simple. I'm using Ubuntu, so use the apt source, download the deb file and follow the new installation documentation in the following order: a. Join the apt library b. Update apt library c. Install d. Run MySQL

Download:

Https://dev.mysql.com/downloads/repo/apt/

Documentation:

Https://dev.mysql.com/doc/mysql-apt-repo-quick-guide/en/#apt-repo-fresh-install

2 、 PHP

Open php-fpm here and listen for port 9000.

Related documentation:

Http://php.net/manual/zh/install.unix.nginx.php

a. download

Https://www.php.net/downloads.phpwget https://www.php.net/distributions/php-7.1.33.tar.gz

Randomly choose an image to download to the local or get to the download address and then download to the local wget

b. Extract, compile, install

Tar zxf php-x.x.xcd.. / php-x.x.x./configure-prefix=/usr/local/php-- enable-fpm-- enable-pdo-- with-pdo-mysql-- enable-mysqlnd-- with-mysqli-- with-opensslmakesudo make install

If there is a simplified control, you must add-- prefix, so that the installation directory will be there.

Among them, the problems that will be encountered when executed sequentially are those that do not exist in pcre, zlib and libxml2, so Baidu goes directly to the official website to obtain the latest version of the tar.gz format installation package, and then decompress, compile and install.

Swoole's getting started manual

Https://linkeddestiny.gitbooks.io/easy-swoole/content/book/chapter01/install.html./configure-- prefix=/usr/local/php\-- with-config-file-path=/etc/php\-- enable-fpm\-- enable-pcntl\-- enable-mysqlnd\-- enable-opcache\-- enable-sockets\-- enable-sysvmsg\-- enable-sysvsem\-enable-sysvshm\-- enable-shmop\-- enable-zip\-- enable-soap\-- enable- Xml\-- enable-mbstring\-- disable-rpath\-- disable-debug\-- disable-fileinfo\-- with-mysqli=mysqlnd\-- with-pdo-mysql=mysqlnd\-- with-pcre-regex\-- with-iconv\-- with-zlib\-- with-mcrypt\-- with-gd\-- with-openssl\-with-mhash\-with-xmlrpc\-- with-curl\-- with-imap-ssl

C, after the installation, the configuration file (the official document moved the brick over), every line should not be forgotten.

Sudo cp php.ini-development / usr/local/php/lib/php.inicp / usr/local/php/etc/php-fpm.conf.default / usr/local/php/etc/php-fpm.confcp sapi/fpm/php-fpm / usr/local/php/bin

Interlude: prevent the file from existing, prevent Nginx from sending the request to the backend PHP-FPM module to avoid malicious script injection attacks

The modified parameter vim / usr/local/php/lib/php.ini is: cgi.fix_pathinfo=0

As I am not familiar with vim, I suggest sudo atom or sudo sublime to open it with graphical interface software.

D, the following is different from the PHP manual: (the following function is to let fpm read and configure PHP-FPM user groups and users and open port 9000 to listen.)

In fact, according to the manual, / usr/local/etc/php-fpm.conf has no user group configuration option at all. If you add it manually, you will report that the file cannot be found, which is very depressing and should be set up in this way.

To create a web user:

Groupadd www-datauseradd-g www-data www-data

Open php-fpm.conf

Vim / usr/local/php/etc/php-fpm.conf

Find the bottom line:

Include=NONEl/etc/php-fpm.d/*.conf

Change the NONE to the real path:

Include=/usr/local/php/etc/php-fpm.d/*.conf

Then add user group and user information to the regular matching profile:

Cd / usr/local/php/etc/php-fpm.dsudo cp www.conf.default www.confvim / usr/local/php/etc/php-fpm.d/www.conf

Find the user settings and change the content as follows:

; Unix user/group of processes; Note: The user is mandatory. If the group is not set, the default user's group; will be used.user = www-datagroup = www-data

Turn on FPM

/ usr/local/bin/php-fpm

E. Check whether it is successful:

Netstat-tln | grep 9000

If you see TCP 9000 LISTEN, the configuration is successful. If there is no output, port 9000 is not listening. Please try again.

3. Install Nginx

What about the Nginx Chinese documents? I stepped on it.

Http://www.nginx.cn/installhttp://www.nginx.cn/doc/setup/nginx-ubuntu.html

These two versions are too old, PHP5 or so, or too many parameters, there are always all kinds of problems with installation, and I don't like apt to install, at least the version is not so free to choose, and I have to delete it with apt, so I use the simplest way to install is download, compile, install.

download

Http://nginx.org/en/download.html

Choose a version you like and download it.

Tar-zxvf cd. / configure-- prefix=/usr/local/nginxmake make install

If you prompt some zlib and other software in configure that there is no Baidu download tar package, it is

Installation directory answer:

After installation, go to / usr/local/nginx

Configuration file: / usr/local/nginx/conf/nginx.conf

Virtual host file directory: / usr/local/nginx/html

Execution file: / usr/local/nginx/sbin/nginx

What the configuration file needs to do is to add index.php b. A.index.html after it. Those that meet the .php rules are handed over to port 9000.

The port uses the default nginx:80 php:9000 virtual host directory with the default / usr/local/nginx/html

A total of two places are configured:

Location / {root html; index index.html index.php index.htm;} # location ~\. Php$ {# root html;# fastcgi_pass 127.0.0.1 location 9000scape # fastcgi_index index.php;# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;# include fastcgi_params;#}

All right, now go execute the directory.

Sudo. / nginx-s reopen

Start nginx

Create a new test.php browser in the html directory and type localhost/text.php to see that the configuration is successful.

PHP extension installation:

Reference manual

Http://php.net/manual/zh/install.pecl.phpize.php

The execution process is as follows: the ext of the PHP source package used at compile time is entered into the relevant extension directory, and phpize generates the configure file,. / configure, make & & make install

Cd / home/username/php7.0.29/extcd curlphpize./configure-- with-php-config=/usr/local/php/bin/php-configmakemake install

An autoconf error may occur. If it is ubuntu, run it directly, and then go to lib.php/ini to remove the extended comments:

Sudo apt-get install autoconf

Linux simple and commonly used instructions:

1. Find the httpd.conf file in the root directory:

Find /-name httpd.conf

2. Show that the file (including subdirectories) in the / usr/src directory contains the line of magic, which is looking for the contents of the file:

Grep-r magic / usr/src

3. VIM editor looks for content

Trailing mode: / content Enter

4. The process of php-fpm shuts down

Sudo pkill php-fpm

5. MySQLI installation

. / configure-with-php-config=/usr/local/php/bin/php-config-with-mysqli=/usr/bin/mysql_config

Php_config can't find it.

Sudo apt-get install libmysqlclient-dev

Later encountered a make error, mysqli.lo does not exist, because a .h file could not be found, resulting in compilation failure icon:

Solution:

Https://www.cnblogs.com/xiaoqian1993/p/6277771.html

6. Apt install resource consumption for ubuntu installation

Could not get lock / var/lib/dpkg/lock! Sudo rm / var/cache/apt/archives/locksudo rm / var/lib/dpkg/lock

7. Simple scheduled tasks

Ubuntu timer task: 1. Switch the compiler of crontab in ubuntu to VIM export EDITOR=vim and restart crontab / etc/init.d/cron stop / etc/init.d/cron start 2 after modification, and set to append one hello to / home/hello.txt text every minute to create tesh.sh content: echo hello > > / home/hello.txt create file hello.txt (pay attention to the user, group, The allocation of read and write execution permissions for other users. Add .sh to the scheduled task command line and enter crontab-e to edit the text as * / 1 * sh / home/test.sh

Linux add environment variables:

Since the / usr/local/php in the linux environment variable value does not belong to it, the one in / usr/local/bin is globally accessible, so now add php to the global variable.

Add sudo vim / etc/profile// to the directory where the execution file of mysql and PHP is located, add two lines of PATH=$PATH:/usr/local/php/bin:/usr/local/mysql/binexport PATH// to the end, and then execute the following instructions to make it effective source / etc/profile

Or add a shortcut form:

Ln-s / usr/local/mysql/bin/mysql_config / usr/local/bin/mysql_config

Nginx.conf | laravel

# user www-data;worker_processes 1 home/www/laravel/public events {worker_connections 1024;} http {include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; # gzip on; # server {listen 8080; server_name localhost; index index.html index.htm index.php; location / {root / home/www/laravel/public Autoindex on; try_files $uri $uri/ / index.php?$query_string;} # pass the PHP scripts to FastCGI server listening on 127.0.0.1 index.php?$query_string; 9000 # location ~\ .php$ {root / home/www/laravel/public; fastcgi_pass 127.0.0.1 index.php?$query_string; 9000; fastcgi_index index.php Fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;}} server {listen 80; server_name localhost; index index.html index.htm index.php; location / {root / home/www; autoindex on; try_files $uri $uri/ / index.php?$query_string } # pass the PHP scripts to FastCGI server listening on 127.0.0.1 root 9000 # location ~\ .php$ {root / home/www; fastcgi_pass 127.0.0.1 root 9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params }}}

Composer installation

Https://pkg.phpcomposer.com/#how-to-install-composer thank you for reading, the above is the content of "how to build the linux php debugging environment". After the study of this article, I believe you have a deeper understanding of how to build the linux php debugging environment, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report