Get the App
SLTechnology News&Howtos  ›  Development  › 

Example Analysis of PHP Environment Construction

Shulou Source: shulou.com Published: 2022-06-03 17:42:25 11月13日 Update

This article is to share with you the content of a sample analysis of building a PHP environment. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.

Apache

1. Download address:

Http://httpd.apache.org/

two。 Configuration change [all'\ 'replace' /']:

Open the httpd.conf file and change the installation path of apache

Change the project file path

Enable the rewrite extension

3. Add a connection to PHP:

LoadModule php5_module "C:/Wamp/php56/php5apache2_4.dll" AddHandler application/x-httpd-php .phpPHP initial Dir "C:/Wamp/php56"

4. Installation commands:

Cd to the apache root directory, execute httpd.exe-k install-n "service name"

5. Uninstall command:

Stop the apache service and execute httpd.exe-k uninstall-n "service name"

PHP

1. Download address:

Http://php.net/downloads.php

two。 Configuration changes:

Open the php.ini file and add: extension_dir = ext before the php extension

Open the extension of php as needed

3. Environment variables:

Computer > Properties > Environment variables > Path > php path

MySQL

1. Download address:

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

two。 Configuration changes:

None for the time being

3. Environment variables:

Computer > Properties > Environment variables > Path > MySQL path

Memcache

1. Download address:

Http://memcached.org/

two。 Configuration changes:

Copy the php_memcache extension to the ext folder in PHP

Add php_memcache extensions to php.ini

3. Installation commands:

Cd to this directory of memcache, execute memcache.exe-d install

4. Uninstall command:

Stop the memcache service and execute memcache.exe-d uninstall

Composer

1. Download address:

Https://getcomposer.org/download/

two。 Configuration changes:

Openssl extension and PHP environment variables need to be enabled.

Put the composer.phar file in the PHP root directory

And first create a bat file: @ php "% ~ dp0composer.phar"% *

Execute composer-- version to view the current version

Upgrade composer selfupdate

3. Modify the current project to use a domestic composer image:

Composer config repo.packagist composer https://packagist.phpcomposer.com

Globally valid:

Composer config-g repo.packagist composer https://packagist.phpcomposer.com

Nginx

1. Web operation mechanism:

User > browser > Domain name > DNS > IP > Nginx > php-fpm > xxx.php > html > browser display

2. Nginx configuration file

/ usr/local/nginx/conf/nginx.conf

User: root

Directory: / home/wwwroot/

3. Php-fpm configuration file

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

User = www

So it is necessary to authorize www users

Chmod-R 777 / home/wwwroot

Setfacl-R-m u:www:rwx runtime

Setfacl-R-m d:u:www:rwx runtime

3. Nginx configuration

#... Server {#... Root/ home/wwwroot/project/web/; location / {index index.html index.php; try_files $uri @ rewrite;} location @ rewrite {rewrite ^ / (.*) $/ index.php/$1 last;} location ~\ .php (/ | $) {fastcgi_pass 127.0.0.1 rewrite; 9000 Fastcgi_split_path_info ^ (. +\ .php) (. *) $; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params;}}

4. Nginx reloads the configuration file:

/ usr/local/nginx/sbin/nginx-s reload

Thank you for reading! This is the end of this article on "example Analysis of PHP Environment Building". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, you can share it for more people to see!

Tags: Files configurations environments variables addresses commands paths services users examples analysis content properties more root directories browsers directories articles computers projects Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information macOS Xiaomi OPPO Reno NVidia