Construction of the LNMP architecture
- centos6.8-i686
- Mysql
- Php
- Nginx
Install some necessary rpm and PHP components (new system) before building
Yum Install wget gcc vim* libxml2 libxml2-devel OpenSSL openssl-devel Curl libcurl-devel Libjpeg-turbo libjpeg-turbo-devel Libpng libpng-devel FreeType Freetype-devel
MySQL and lamp MySQL installation is the same
Download
cd/usr/local/src/wget http://MIRRORS.SOHU.COM/MYSQL/MYSQL-5.1/ mysql-5.1.73-linux-i686-glibc23.tar.gz
Initialize Tar
tar zxvf/usr/local/src/mysql-5.1. 73-linux-i686-icc-glibc23.tar.gz // unzip MV Mysql-5.1. 73-linux-i686-icc-glibc23/usr/local/mysql // nudge position useradd-s/sbin/nologin mysql // build mysql user cd/usr/local/mysql mkdir-p/data/mysql // Create DataDir, the database file will be placed in this area chown-r mysql:mysql/data/mysql // change permissions./scripts/mysql_install_db--user=mysql--datadir=/data /mysql--user define the owner of the database,--datadir define where the database is installed
Verify the echo $?
Problems
(1) Error:./bin/mysqld:error while loading shared libraries:libstdc++.so.5:cannot
Open Shared Object file:
Solve:
Yum Install-y compat-libstdc++-33
(2) Error:./scripts/mysql_install_db:./bin/my_print_defaults:/lib/ld-linux.so.2:bad
ELF interpreter:no such file or directory
This is because your system version is inconsistent with the MySQL version. For example, your system is 32-bit, the result you download
A 64-bit package. So, the solution is to download the appropriate package.
Configuration
Copy configuration file
CP SUPPORT-FILES/MY-LARGE.CNF/ETC/MY.CNF
Copy the startup script file and modify its properties
CP support-files/mysql.server/etc/init.d/755/etc/init.d/mysqld
Modifying startup Scripts
vim/etc/init.d/mysqld Modified Place "Datadir=/data/mysql" (the directory defined when the database was previously initialized)
Add the startup script to the system service entry, set boot up and start MySQL
Chkconfig--add mysqld chkconfig mysqld on service mysqld start
Problems
If not, please check the error log under/data/mysql/, which is usually the hostname. Err.
The command to check if MySQL starts is:
PS aux |grep mysqld
Php
Download
cd/usr/local/srcwget http://au1.php.net/distributions/php-5.4.44.tar.bz2
Unzip
tar jxf php-5.4. . tar. bz2
Create user
Useradd-s/sbin/nologin PHP-FPM
Configuration Compilation
CD php-5.4. -
./configure--prefix=/usr/local/php-fpm--with-config-file-path=/usr/local/php/etc--enable-fpm-- WITH-FPM-USER=PHP-FPM--with-fpm-group=php-fpm--with-mysql=/usr/local/mysql--with-mysql-sock=/tmp/mysql.sock-- with-libxml-dir --with-gd--with-jpeg-dir --with-png-dir --with-freetype-dir -- with-iconv-dir --with-zlib-dir --with-mcrypt--enable-soap--enable-gd-native-ttf--enable- FTP --enable-mbstring--enable-exif--enable-zend-multibyte--disable-ipv6--with-pear--with-curl-- With-openssl
error Message
Yum List | grep The component Name # has been installed almost all at first, if you have not installed the Yum Install -y package Name
Compile and install this time is longer
Make Make Install
there may be errors in this step
Yum Install -y libtool-ltdl-devel
Modifying a configuration file
CP php.ini-production/usr/local/php/etc/php.ini
Cp/usr/local/php-fpm/etc/{php-fpm.conf.default php-fpm.conf}
Check that the configuration file is correct
/usr/local/php/sbin/php-fpm-t
#会出现
Test is successful
#代表配置文件正确
start php-fpm and add to boot boot
#先拷贝一个文件
CP /usr/local/src/php-5.3. /sapi/fpm/init.d.php-fpm/etc/init.d/php-755chmod755 /etc/init.d/ php-fpm# Start service php---add php-fpm# join boot chkconfig php-ps aux | grep php-fpm
Nginx
Download
cd/usr/local/src/wget http://nginx.org/download/nginx-1.8.0.tar.gz
Unzip
tar zxvf nginx-1.8. 0. tar. gz
Configuration Compilation
./configure--prefix=/usr/local/nginx--with-pcre
There may be an error missing Pcre component
Yum Install -y pcre-devel
Compiling and installing
Make Make Install
start Nginx
/usr/local/nginx/sbin/nginx
Check whether the service is started
PS aux | grep Nginx
Test PHP-FPM parsing
Modify the configuration file first
vim/usr/local/nginx/conf/nginx.conf
#找到
Location/{
root html;
index index.html index.htm index.php ;
}
#添加index. php
#找到
Location ~ \.php$ {
root HTML;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
/usr/local/nginx/html$fastcgi _script_name;
Include Fastcgi_params;
}
#修改成/usr/local/nginx/html
Reload
/usr/local/nginx/sbin/nginx-s Reload
Test
Create a PHP file
vim/usr/local/nginx/html/1. php
#在里面写
<?php
Phpinfo ();
?>
#保存退出
Open Browser Input ip/1.php
An info message appears stating that the parse was successful
Construction of the LINUX:LNMP architecture