LNMP source code compilation and installation, common error sorting
Introduction:
The establishment of the Lnmp environment is still very simple. Previously, due to blog migration and other reasons, many blog posts were lost. Record this time.
Lnmp: Linux, Nginx, Mysql, and PHP
Lnmp is a Web environment. Linux is the underlying operating system. Nginx provides web Services, Mysql provides database services, and PHP is responsible for parsing PHP code.
It is strongly recommended that the host machine memory be greater than or equal to 1 GB. Otherwise, we recommend that you install lower versions of Mysql and PHP !!!
I. Nginx
: Http://nginx.org/download/nginx-1.8.0.tar.gz # Now the latest stable version has been developed to 1.8.0
Shell> yum-y install gcc-c ++ make wget zlib-devel pcre-devel openssl-devel
Shell> wget http://nginx.org/download/nginx-1.8.0.tar.gz
Shell> tar zxf nginx-1.8.0.tar.gz
Shell> cd nginx-1.8.0
Shell>./configure -- prefix =/usr/local/nginx; make install # -- prefix parameter specifies Nginx installation path
Shell>/usr/local/nginx/sbin/nginx # Start Nginx
Shell> netstat-anpt | grep nginx # confirm whether to start
Tcp 0 0 0.0.0.0: 80 0.0.0.0: * LISTEN 7520/nginx
Shell> curl-I http: // 127.0.0.1 # access successful
HTTP/1.1 200 OK
Server: nginx/1.8.0
Date: Fri, 07 Aug 2015 12:08:14 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Fri, 07 Aug 2015 12:04:38 GMT
Connection: keep-alive
ETag: "55c49ed6-264"
Accept-Ranges: bytes
Shell> iptables-I INPUT-p tcp -- dport 80-j ACCEPT
Shell> service iptables save
# Nginx can be accessed through a browser over the Internet now
Ii. Install MySQL (portal :)
Iii. PHP
: Http://cn2.php.net/distributions/php-5.6.11.tar.gz
Shell> yum-y install epel-release
Shell> yum-y install gd-devel libtool libjpeg-devel libpng-devel freetype-devel libxml2-devel zlib-devel bzip2-devel libcurl-devel libxslt-devel openssl-devel glibc-devel glib2-devel libmcrypt-devel
Shell> wget http://cn2.php.net/distributions/php-5.6.11.tar.gz
Shell> tar zxf php-5.6.11.tar.gz
Shell> cd php-5.6.11
Shell>./configure -- prefix =/usr/local/php -- with-config-file-path =/usr/local/php \
-- With-mysql =/usr/local/mysql/-- with-mysqli =/usr/local/mysql/bin/mysql_config \
-- With-gd -- with-xsl -- with-bz2 -- with-zlib -- with-curl -- with-pear -- without-iconv -- with-mcrypt \
-- With-gettext -- with-openssl -- with-libxml-dir -- with-png-dir -- with-jpeg-dir -- with-freetype-dir \
-- With-libdir = lib64 -- enable-ftp -- enable-fpm -- enable-exif -- enable-soap -- enable-bcmath -- enable-calendar \
-- Enable-sockets -- enable-mbstring -- enable-gd-native-ttf -- disable-rpath -- disable-debug
# What do you do with these heap parameters? You don't have to worry too much about them. You can solve most of the requirements. Several explanations are needed.
# -- Prefix = Specify the installation path
# -- With-config-file-path specifies the storage location of php. ini
# -- With-mysql specifies the Mysql installation path
# -- Enable-fpm Nginx depends on php. Without it, your Nginx cannot parse php.
Shell> make; make install
Shell & gt; cp/usr/local/src/php-5.6.11/php. ini-production/usr/local/php. ini
Shell> cp/usr/local/src/php-5.6.11/sapi/fpm/init. d. php-fpm/etc/init. d/php-fpm
Shell> chmod a + x/etc/init. d/php-fpm
Shell> cat/usr/local/php/etc/php-fpm.conf.default>/usr/local/php/etc/php-fpm.conf
Shell> chkconfig -- add php-fpm # add startup
Shell> chkconfig -- level 35 php-fpm on
Shell> service php-fpm start # start php-fpm
Shell> netstat-anpt | grep php-fpm
Tcp 0 0 127.0.0.1: 9000 0.0.0.0: * LISTEN 71992/php-fpm
4. Enable Nginx to support PHP
Shell> vim/usr/local/nginx/conf/nginx. conf # modify the configuration file so that it can parse PHP
Server {
Listen 80;
Server_name localhost;
Location /{
Root html;
Index. php index.html index.htm; # add index. php
}
Error_page 500 502 503 x.html;
Location =/50x.html {
Root html;
}
Location ~ \. Php $ {# Remove the entire Annotation
Root html;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param SCRIPT_FILENAME/usr/local/nginx/html $ fastcgi_script_name; # change it to your own root directory.
Include fastcgi_params;
}
}
# Of course, this only enables Nginx to support PHP. More configurations are available in actual work.
# Create a test page (echo "<? Php phpinfo ();?> ">/Usr/local/nginx/html/info. php), restart Nginx and php-fpm for testing! (For a long time before testing, remember to use iptables-I input-I io-j ACCEPT)
V. Error Summary: (record some common errors and solutions)
1. If gcc is not installed, an error is reported (yum-y install gcc)
Checking for OS
+ Linux 2.6.32-504. el6.x86 _ 64 x86_64
Checking for C compiler... not found
./Configure: error: C compiler cc is not found
2. If pcre-devel is not installed, an error is returned (yum-y install pcre-devel)
./Configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using -- without-http_rewrite_module
Option, or install the PCRE library into the system, or build the PCRE library
Statically from the source with nginx by using -- with-pcre = <path> option.
3. If zlib-devel is not installed, an error is returned (yum-y install zlib-devel)
./Configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using -- without-http_gzip_module
Option, or install the zlib library into the system, or build the zlib library
Statically from the source with nginx by using -- with-zlib = <path> option.
# Above is the error message about Nginx
4. If gcc-c ++ is not installed, an error is returned (yum-y install gcc-c ++)
CMake Error: your CXX compiler: "CMAKE_CXX_COMPILER-NOTFOUND" was not found. Please set CMAKE_CXX_COMPILER to a valid compiler path or name.
# Mysql Error
5. No libxml2-devel is installed causing an error (yum-y install libxml2-devel)
Configure: error: xml2-config not found. Please check your libxml2 installation.
6. No bzip2-devel is installed, causing an error (yum-y install bzip2-devel)
Configure: error: Please reinstall the BZip2 distribution
7. If libcurl-devel is not installed, an error is returned (yum-y install libcurl-devel)
Configure: error: Please reinstall the libcurl distribution-
Easy. h shoshould be in <curl-dir>/include/curl/
8. If libjpeg-devel is not installed, an error is returned (yum-y install libjpeg-devel)
Configure: error: Invalid Lib. h not found.
9. If libpng-devel is not installed, an error is returned (yum-y install libpng-devel)
Configure: error: png. h not found.
10. If freetype-devel is not installed, an error is returned (yum-y install freetype-devel)
Configure: error: freetype-config not found.
11. If libmcrypt-devel is not installed, an error is reported (yum-y install epel-release; yum-y install libmcrypt-devel)
Configure: error: mcrypt. h not found. Please reinstall libmcrypt.
12. If libmysqlclient. so.18 is not found, an error is returned (ln-s/usr/local/mysql/lib/usr/local/mysql/lib64)
Configure: error: Cannot find libmysqlclient under/usr/local/mysql /.
Note that the MySQL client library is not bundled anymore!
13. Keep up with an error. I guess (ln-s/usr/local/mysql/lib/libmysqlclient. so.18/usr/lib64 /)
Configure: error: Don't know how to define struct flock on this system, set -- enable-opcache = no
14. If libxslt-devel is not installed, an error is reported (yum-y install libxslt-devel)
Configure: error: xslt-config not found. Please reinstall the libxslt> = 1.1.0 distribution
This article permanently updates the link address: