Set up php development environment under ubuntu (nginx+ of cgi php5fpm+memcached+xdebug)

  • 2020-05-09 19:47:49
  • OfStack

Since it is only a development environment, we choose the relatively simple installation mode of apt-get, but there is a problem in the middle.

Install nginx first

The installation and configuration of nginx is very simple. nginx itself is very lightweight.

Just sudo apt-get install nginx

His configuration file is in /etc/nginx/, and the website project path is in /var/www. After installation, 1 must make sure that the startup account of nginx has access to the website directory, otherwise an error will be reported.

Step 2, install cgi

There are a lot of cgi programs under linux. In this case, I chose php5-fpm for  . In fact, there is a pit here.

Once installed, add cgi's forward configuration to nginx's servers


location ~ .*\.php?$
{
include fastcgi_params;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}

The red marks are important to note and are different from other materials on the Internet

Once you've saved it, reload the nginx configuration,  


sudo php5-fpm stop;
sudo php5-fpm start;
sudo service nginx reload ;

After the above steps, you can basically ensure that php runs without any problems. Right

Then install memcached


sudo apt-get install memcached 

After installing the Memcache server, we need to start the service:


memcached -d -m 128 -p 11111 -u root

xdebug installation


sudo apt-get install php5-dev php5-cli
# Among them php5-dev In order to install xdebug So it has to be installed. 
sudo apt-get install php5-xsl
#Xinc Need to be xsl extension
sudo apt-get install php-pear
#pecl install That must be 
sudo pecl install xdebug
# The installation xdebug , the installation completes if the compilation is successful 

Then add it to the php configuration item


zend_extension=xdebug.so

then


sudo php5-fpm stop;
sudo php5-fpm start;

You can do it on phpinfo(); You see the xdebug option


Related articles: