Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Build LNMP environment

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Build LAMP environment

I. introduction of the environment

Second, dependent software must be installed

3. Compile and install Nginx-1.6.3

Fourth, binary installation of MYSQL-5.5.33

Fifth, compile and install PHP-5.3.27

Check whether nginx is connected to mysql nginx and php

I. introduction of the environment

Set up this environment, all services are installed in a virtual machine, here to introduce my virtual machine

CentOS-6.7-x86_64 ensures that the virtual machine can access the Internet normally.

IP:192.168.6.36

Hostname:yuci

Close iptbales selinux

Second, dependent software must be installed

All installed through yum

Lrzsz # software has nothing to do with this environment. After installation, you can drag and drop the package directly through xshell.

Pcre

Pcre-devel

Openssl-devel

Yum-y install lrzsz pcre pcre-devel openssl-devel

Rpm-qa lrzsz pcre pcre-devel openssl-devel

3. Compile and install Nginx-1.6.3

Create a directory dedicated to storing software packages

Mkdir-p / home/yuci/tools

Create a nginx user and check

Useradd-s / sbin/nologin/-M nginx

Id nginx

Extract the nginx package (lrzsz is installed, so you can drag and drop the software directly to this directory)

Tar zxf nginx-1.6.3.tar.gz

To start compiling and installing nginx, type the command in the nginx directory

. / configure-- prefix=/application/nginx-1.6.3-- user=nginx\

-- group=nginx-- with-http_ssl_module\

-- with-http_stub_status_module\

& & make & & make install

Create a soft connection to keep the software version while making it easy to operate

Ln-s / application/nginx-1.6.3/ / application/nginx

Start the nginx service

/ application/nginx/sbin/nginx

The browser enters the IP address, and the nginx is built successfully.

Fourth, binary installation of MYSQL-5.5.33

Extract the mysql installation package

Tar zxf mysql-5.5.33-linux2.6-x86_64.tar.gz

Cut to the / application directory, where all services in the lamp environment will be installed for easy management

Move mysql to the / application directory and keep the mysql version number

Mv / home/yuci/tools/mysql-5.5.33-linux2.6-x86_64. / mysql-5.5.33

Create a soft connection for mysql for easy management

Ln-s / application/mysql-5.5.33/ / application/mysql

Create a mysql user

Useradd-s / sbin/nologin/-M mysql

Id mysql

Initialize mysql

/ application/mysql/scripts/mysql_install_db-basedir=/application/mysql/-datadir=/application/mysql/data/-user=mysql

Authorize mysql to change its primary group to mysql user

Chown-R mysql:mysql / application/mysql

Copy the mysql configuration file and select small.

Cp support-files/my-small.cnf / etc/my.cnf

Modify the startup script mysqld_safe of mysql, because the default installation path for mysql is / usr/local/mysql, but now mysql is in the / application directory, so change it through the sed command

Sed-I-I

Start mysql, start the script mysql_safe, and put it into the background for execution

/ application/mysql/bin/mysqld_safe &

Check whether mysql is started through the port

Lsof-I: 3306

It is troublesome to start through mysqld_safe every time, so you can configure variables by modifying / etc/profile.

Vim / etc/profile

PATH= "/ application/mysql/bin:$PATH"

Source / etc/profile # refresh takes effect

Copy the mysql startup script and rename it to mysqld.

Replace the path in the mysql startup script and replace / usr/local/mysql with / application/mysql.

Add execution permissions to the script mysqld

Cp support-files/mysql.server / etc/init.d/mysqld

Sed-I-I

Chmod + x / etc/init.d/mysqld

Use the killall command to kill the running mysql service and repeat until the prompt for mysqld: no process killed appears

Killall mysqld

Start mysql and check

/ etc/init.d/mysqld start

Set mysql to boot

Chkconfig mysqld on

Set the root password of mysql to 123456, and log in to mysql

Mysqladmin-uroot password "123456"

Mysql-uroot-p123456

Fifth, compile and install PHP-5.3.27

It is too troublesome to install PHP. Let's confirm the process first.

1) confirm that nginx, mysql service has been started

2) install via yum

Freetype-devel

Libjpeg-devel # due to the problem of version upgrade, yum installed libjpeg-devel, but actually installed libjpeg-turbo-devel

Libpng-devel

Gd

Gd-devel

Libcurl-devel

Libxslt-devel

3) compile and install libiconv-1.14 software because it cannot be successfully installed through yum

4) download a new epel source via wget

5) install libmcrypt libmcrypt-devel package

6) install the mhash encryption extension library

7) install the mcrypt encryption extension library

8) compile and install PHP-5.3.7

1)

Before installing PHP, you should first make sure that both the nginx and mysql services are started

Lsof-I: 80

Lsof-I: 3306

2)

Various lib library files required to install php, in which the installation of gd-devel failed and gd gd-devel was installed at the same time.

Yum-y install freetype-devel libjpeg-devel libpng-devel gd gd-devel libcurl-devel libxslt-devel

Rpm-qa freetype-devel libjpeg-turbo-devel libpng-devel gd gd-devel libcurl-devel libxslt-devel

(libjpeg-devel = = libjpeg-turbo-devel)

3)

Install libiconv, this software cannot be installed through yum, can only be compiled and installed

Extract the software-> cut to its directory-> execute the command, compile and install

Tar zxf libiconv-1.14.tar.gz

Cd libiconv-1.14

. / configure-- prefix=/usr/local/libiconv & & make & & make install

4)

Install the epel source because of the libmcrypt libraries that will be installed later. An intermediary library can't do without a source.

Wget-O / etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo

5)

Install the libmcrypt libmcrypt-devel package and check

Yum-y install libmcrypt-devel

Rpm-qa libmcrypt*

6)

Install the mhash encryption extension library and check

Yum-y install mhash mhash-devel

Rpm-qa mhash mhash-devel

7)

Install the mcrypt encryption extension library and check

Yum-y install mcrypt

Rpm-qa mcrypt

8)

Compile and install PHP-5.3.7 and place the php installation package in the specified / home/yuci/tools directory

Tar zxf php-5.3.27.tar.gz

Cd php-5.3.27

Create files, do not create PHP compilation will report an error

Touch ext/phar/phar.phar

Create a soft connection file

Ln-s / application/mysql/lib/libmysqlclient.so.18 / usr/lib64/

Officially compile and install PHP. The compilation path is as follows, and you can execute it in the PHP directory.

. / configure\

-- prefix=/application/php5.3.27\

-- with-mysql=/application/mysql\

-- with-iconv-dir=/usr/local/libiconv\

-- with-freetype-dir\

-- with-jpeg-dir\

-- with-png-dir\

-- with-zlib\

-- with-libxml-dir=/usr\

-- enable-xml\

-- disable-rpath\

-- enable-safe-mode\

-- enable-bcmath\

-- enable-shmop\

-- enable-sysvsem\

-- enable-inline-optimization\

-- with-curl\

-- with-curlwrappers\

-- enable-mbregex\

-- enable-fpm\

-- enable-mbstring\

-- with-mcrypt\

-- with-gd\

-- enable-gd-native-ttf\

-- with-openssl\

-- with-mhash\

-- enable-pcntl\

-- enable-sockets\

-- with-xmlrpc\

-- enable-zip\

-- enable-soap\

-- enable-short-tags\

-- enable-zend-multibyte\

-- enable-static\

-- with-xsl\

-- with-fpm-user=nginx\

-- with-fpm-group=nginx\

-- enable-ftp

Make & & make install

See the following screen, which indicates that the installation is successful. Continue with the operation.

Create a soft connection for php

Ln-s / application/php5.3.27/ / application/php

Configure PHP parsing file, php.ini

Ls-l php.ini*

Copy the configuration file to the php installation directory and rename it php.ini

Cp php.ini-production / application/php/lib/php.ini

Php process management file takes effect (php-fpm.conf process management)

Cp php-fpm.conf.default php-fpm.conf

Start php-fpm, check if it starts, check the php-fpm port

/ application/php/sbin/php-fpm

Ps-ef | grep php-fpm

Ss-lntup | grep php-fpm

6. Edit the nginx.conf file

Filter the file, it is also convenient to look at, edit as follows

Cd / application/nginx/conf

Egrep-v "# | ^ $" nginx.conf.default > nginx.conf

Check whether nginx is connected to mysql nginx and php

Create two phpinifo.php,mysql.php files under this directory, with the following contents

Check syntax and load smoothly

/ application/nginx/sbin/nginx-t

/ application/nginx/sbin/nginx-s reload

Enter separately in the browser

192.168.6.36/phpinfo.php

192.168.6.36/mysql.php

The great task has been completed

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report