Before installing lnmp written several articles about the environment, in retrospect feel some relatively old or not good operation, so this update
1. Install Nginx
1) mounted reliance
yum install gcc gcc-c++ openssl openssl-devel cyrus-sasl-md5
2) Download nginx
wget http://nginx.org/download/nginx-1.12.0.tar.gz
3) decompression and enter the installation directory
tar zxvf nginx-1.12.0.tar.gz cd nginx-1.12.0
4) compile and install
./configure --prefix=/usr/local/nginx --with-http_ssl_module
make && make install -j2
5) to start the service and view
/ Sr / local / nginx / sbin / nginx
PS -ef | grep nginx
6) added to boot from the start
Vim / etc / the rc.local
add the following code:
/ usr / local / Nginx / sbin / /usr/local/nginx/conf/nginx.conf & Nginx -C
7) Join the global environment variables
vim / etc / Profile Export = $ the PATH: / usr / local / nginx / sbin save and exit with immediate effect: Source / etc / Profile
8) verification environment variables
nginx -v nginx version: nginx/1.12.0
2. Install PHP
1) installation dependencies
yum -y install bzip2
2) Download PHP
wget https://www.php.net/distributions/php-7.2.28.tar.bz2 tar txvf php-7.2.28.tar.bz2 cd php-7.2.28
3) create a user www
www groupadd useradd -g www -s / sbin / nologin www # View www user id www
4) compile and install
./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7 --enable-sockets --enable-fpm --enable-cli --enable-mbstring --enable-pcntl --enable-soap --enable-opcache --disable-fileinfo --disable-rpath --with-mysqli --with-pdo-mysql --with-iconv-dir --with-openssl --with-fpm-user=www --with-fpm-group=www --with-curl --with-mhash --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-zip --with-zlib --enable-simplexml --with-libxml-dir
make && make install
Description:
--prefix = / usr / local / php7 # install directory will --with-config-file-path = / usr / local / php7 # php.ini configuration file path --enable-sockets # Open Socket --enable- fpm fpm # enable extended --enable-cli # enable command line mode (after php 4.3.0 from this module can be turned on by default so do not add this command) --enable-mbstring # enable mbstring library --enable-pcntl # enable pcntl (CLI / CGI only) --enable-# enable the SOAP the SOAP --enable-opcache # open opcache cache --disable-fileinfo # disable fileinfo (due after 5.3+ is no longer ongoing maintenance, but it is enabled by default, so it is still banned) (1G server memory or less directly related to it) --disable-rpath # disable passing additional runtime library search path. --with-mysqli # enable mysqli extension --with-pdo-mysql # Enable extensions pdo --with-iconv-dir # Enable XMLRPC-EPI character encoding conversion expand --with-fpm-group = www # fpm group set belongs --with-openssl # openssl extension enabled (requires openssl openssl- devel) --with-fpm-user = user www # set fpm belongs --with-curl # Enable curl extension --with-mhash # open mhash not reverse php based encryption mathematical principles of discrete extensions # GD --with-gd GD image manipulation # Enable Extended --with-jpeg-dir # enable support for jpeg images (libjpeg required) --with-png-dir # turn on the png image support (libpng required) --with-dir # FreeType-open FreeType # compression --enable-zip # enabled ZIP - with-zlib # enable zlib support # xml # enabled --enable-simplexml to simplexml support enabled --with-libxml-dir # support for libxml2
5) set up a profile
cp / opt / php 7.2 . 28 /php.ini-production / usr / local / php7 / php.ini cp /usr/local/php7/etc/php-fpm.conf. default / usr / local / php7 / etc / php fpm.conf cp /usr/local/php7/etc/php-fpm.d/www.conf. default /usr/local/php7/etc/php-fpm.d/www.conf
php-fpm.conf modified as follows:
[ Global ] ; the Pid File ; Note: The default prefix IS / usr / local / PHP7 / var ; the Default the Value: none # canceled note below PID = RUN / php-fpm.pid
6) Start simple configuration command
# Copy startup script to the init.d directory $ cp PHP - 7.2 . 19 /sapi/fpm/init.d.php-fpm /etc/init.d/php- FPM # increased execute permissions $ chmod + the X-/ etc / the init .d / php-fpm
php-fpm operation command:
/ usr / local / PHP7 / sbin / PHP- . FPM start # pkill. - 9 PHP- FPM # stop /etc/init.d/php- FPM Start # Start. /etc/init.d/php- FPM STOP # stop /etc/init.d/php- FPM # status status /etc/init.d/php-fpm restart # restart
7) is added from the start
/ Sbin / chkconfig php-fpm on # to complete restart again from the start
8) php-fpm of service
# In CentOS 7 we can use to better manage system services systemctl after # so we want PHP - FPM support # because PHP 7.2 source package which contains the required script file systemctl # we can just copy the past, let's start configuration # php to download the source package $ CD php - 7.2 . . 19 / SAPI / FPM # replicated therein php -fpm.service to / usr / lib / systemd / System / $ CP php -fpm.service / usr / lib / systemd / System / # php enable reuse systemctl - FPM is configured from the start $ enable php systemctl - FPM # reboot own test to see php server whether -fpm successful operation
systemctl enable xxxxxx # Configure from the start
systemctl stop xxxxx # stop service
systemctl start xxxx # open service
systemctl status xxxx # View state
9) nginx configuration support
Vi $ / usr / local / nginx / conf / nginx.conf ... HTTP { ... Server { ... # put [ 1 ] replaced [ 2 ] # let nginx support php file # [ 1 ] LOCATION / { HTML the root; index index.htm index.html; } # [ 2 ] LOCATION / { the root HTML; index the index.php index.html index.htm; } ... # to [ 1 ] into [ 2 ] # arranged listener php port # NOTE: make / scripts into DOCUMENT_ROOT $ # [ . 1 ] #location ~ \ .php $ { # the root HTML; # fastcgi_pass 127.0 . 0.1 : 9000 ; # fastcgi_index the index.php; # fastcgi_param SCRIPT_FILENAME / $ fastcgi_script_name scripts; # the include fastcgi_params; #} # [ 2 ] LOCATION ~ \ $ {.php the root HTML; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } ... }