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

Construction of stand-alone LAMP Environment for linux

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Construction of LAMP stand-alone environment

one。 Prepare the system environment.

1. System environment: CentOS_6.5,32 bit

[root@localhost ~] # cat / etc/redhat-release

CentOS release 6.5 (Final)

[root@localhost ~] # uname-r

2.6.32-431.el6.i686

two。 Software version

Httpd-2.2.31

Mysql-5.1.72

Php-5.5.32

3. Turn off firewall iptables and selinux

3.1 turn off Firewall iptables

[root@localhost tools] # chkconfig-- level 2345iptables off

[root@localhost tools] # chkconfig-- listiptables

Iptables 0:off 1:off 2:off 3:off 4:off 5:off 6:off

[root@localhost tools] # service iptables stop

[root@localhost tools] # service iptablesstatus

Iptables: Firewall is not running.

3.2 close selinux

[root@localhost tools] # vim/etc/selinux/config # modify the configuration as shown in the following figure

4. Create a new software management folder and upload related software

4.1 create a software management folder

[root@localhost tools] # mkdir-p/home/jeff/tools/

[root@localhost tools] # ll / home/jeff/

Total 4

Drwxr-xr-x. 5 root root 4096 May 16 10:16tools

4.2 upload related software

[root@localhost /] # cd / home/jeff/tools/

Use rz command to upload related software. If you cannot use this command, install the lrzsz software.

two。 Install related softwar

1. Install apache softwar

1.1 decompress apache

Root@localhost tools] # tar-zxvf httpd-2.2.31.tar.gz

[root@localhost tools] # ll

Total 63248

-rw-r--r-- 1 root root 10364427 Feb 22 14:51 Discuz_X3.1_SC_GBK.zip

Drwxr-xr-x 11 1000 1000 4096 Jul 16 2015 httpd-2.2.31

-rw-r--r-- 1 root root 7583841 May 16 10:11 httpd-2.2.31.tar.gz

-rw-r--r-- 1 root root 4984397 Feb 22 13:52libiconv-1.14.tar.gz

-rw-r--r-- 1 root root 24044338 Feb 22 10:47 mysql-5.1.72.tar.gz

-rw-r--r-- 1 root root 17773092 Feb 22 11:22 php-5.5.32.tar.gz

1.2 enter the apache software directory and configure (install apr, apr-util, prce, gcc gcc-c++ first)

[root@localhost tools] # cd httpd-2.2.31

[root@localhost httpd-2.2.31] #. / configure\

-- prefix=/usr/local/apache2.2.31\

-- with-apr=/usr/local/apr\

-- with-apr-util=/usr/local/apr-util\

-- with-pcre=/usr/local/pcre\

-- enable-deflate\

-- enable-expires\

-- enable-headers\

-- enable-modules=most\

-- enable-so\

-- with-mpm=worker\

-- enable-rewrite

1.3 compilation and installation

[root@localhost httpd-2.2.31] # make & makeinstall

1.4 start and check the installation of apache

1.4.1 start apache

[root@localhost bin] #. / apachectl start # start apache

Httpd: Could not reliably determine theserver's fully qualified domain name, using:: 1 for ServerName

1.4.2 check apache startup

[root@localhost bin] # ps-ef | grep http* # View apache process

Root 17464 1 0 11:45? 00:00:00/usr/local/apache2.2.31/bin/httpd-k start

Daemon 17465 17464 0 11:45? 00:00:00/usr/local/apache2.2.31/bin/httpd-k start

Daemon 17466 17464 0 11:45? 00:00:00/usr/local/apache2.2.31/bin/httpd-k start

Daemon 17467 17464 0 11:45? 00:00:00/usr/local/apache2.2.31/bin/httpd-k start

Daemon 17468 17464 0 11:45? 00:00:00 / usr/local/apache2.2.31/bin/httpd-k start

Root 17552 3284 0 11:45 pts/1 00:00:00 grep httpd

[root@localhost bin] # netstat-lntp | grep 80 # View apache listening port

Tcp 0 0: 80: * LISTEN 17464/httpd

Check with the browser:

If the following page appears on http://localhost, apache is installed successfully.

two。 Install mysql softwar

2.1 decompress mysql

[root@localhost tools] # tar-zxvfmysql-5.1.72.tar.gz

[root@localhost tools] # ll

Total 67372

Drwxr-xr-x 12 1000 1000 4096 May 16 11:42 httpd-2.2.31

-rw-r--r-- 1 root root 7583841 May 16 10:11httpd-2.2.31.tar.gz

Drwxrwxrwx 32 7155 wheel 4096 Sep 10 2013 mysql-5.1.72

-rw-r--r-- 1 root root 24044338 Feb 22 10:47mysql-5.1.72.tar.gz

-rw-r--r-- 1 root root 17773092 Feb 22 11:22php-5.5.32.tar.gz

2.2 establish user groups for the corresponding users of mysql

[root@localhost mysql-5.1.72] # groupadd-g 800mysql # create mysql user group

[root@localhost mysql-5.1.72] # useradd-gmysql-u 800-M-s / sbin/nologin mysql # create mysql user

[root@localhost mysql-5.1.72] # cat / etc/group | grep mysql # check the creation of mysql groups

Mysql:x:800:

[root@localhost mysql-5.1.72] # cat / etc/passwd | grep mysql # check the creation of mysql users

Mysql:x:800:800::/home/mysql:/sbin/nologin

#-s / sbin/nologin forbids the user to log in and strengthens security.

#-g mysql specifies that it belongs to the mysql group.

#-M means that the user's home directory is not created.

2.3 enter the mysql software directory and compile and install it

2.3.1 enter the mysql software directory

[root@localhost tools] # cd mysql-5.1.72 # enter the mysql installation directory

2.3.2 configure mysql (install ncurses-devel before configuration)

[root@localhost mysql-5.1.72] #. / configure\

-- prefix=/usr/local/mysql5.1.72\

-- with-unix-socket-path=/usr/local/mysql5.1.72/tmp/mysql.sock\

-- localstatedir=/usr/local/mysql5.1.72/data\

-- enable-assembler\

-- enable-thread-safe-client\

-- with-mysqld-user=mysql\

-- with-big-tables\

-- without-debug\

-- with-pthread\

-- enable-assembler\

-- with-extra-charsets=complex\

-- with-readline\

-- with-ssl\

-- with-embedded-server\

-- enable-local-infile\

-- with-plugins=partition,innobase\

-- with-plugin-PLUGIN\

-- with-mysqld-ldflags=-all-static\

-- with-client-ldflags=-all-static

2.3.3 compile and install

[root@localhost mysql-5.1.72] # make & makeinstall

2.4 get mysql profile

[root@localhost mysql-5.1.72] # cdsupport-files

[root@localhost support-files] # cp-amy-small.cnf / etc/my.cnf

2.5 create soft connections for easy maintenance and upgrade

[root@localhost local] # ln-s / usr/local/mysql5.1.72//usr/local/mysql

2.6.Create mysql database files

[root@localhost local] # mkdir-p/usr/local/mysql/data # create a directory of mysql data files

[root@localhost local] # chown-R mysql:mysql/usr/local/mysql5.1.72 # authorizes mysql users to access the installation directory of mysql

[root@localhost local] # / usr/local/mysql/bin/mysql_install_db-- user=mysql # installs mysql database files

2.7 start the mysql database

[root@localhost bin] # cp / home/jeff/tools/mysql-5.1.72/support-files/mysql.server/usr/local/mysql/bin/

# copy the command path from the mysql startup script to mysql

[root@localhost bin] # chmod 700/usr/local/mysql/bin/mysql.server # makes the script executable

[root@localhost bin] # / usr/local/mysql/bin/mysql.server start # start the database

Starting MySQL. SUCCESS!

2.8Checkup mysql database startup

[root@localhost bin] # netstat-lnt | grep 3306 # check mysql listening port

Tcp 0 0 0.0.0.0 3306 0.0.0.015 * LISTEN

[root@localhost bin] # ps-ef | grep "mysql*" # check the mysql process

Root 3085 1 0 14:43 pts/3 00:00:00 / bin/sh/usr/local/mysql5.1.72/bin/mysqld_safe-datadir=/usr/local/mysql5.1.72/data--pid-file=/usr/local/mysql5.1.72/data/localhost.pid

Mysql 3200 3085 0 14:43 pts/3 00:00:00 / usr/local/mysql5.1.72/libexec/mysqld--basedir=/usr/local/mysql5.1.72-datadir=/usr/local/mysql5.1.72/data--user=mysql-log-error=/usr/local/mysql5.1.72/data/localhost.err--pid-file=/usr/local/mysql5.1.72/data/localhost.pid-socket=/usr/local/mysql5.1.72/tmp/mysql.sock--port=3306

Root 3239 18040 0 14:47 pts/3 00:00:00 grep mysql*

[root@localhost bin] # / usr/local/mysql/bin/mysql-uroot # enter mysql

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 1

Server version: 5.1.72 Source distribution

Copyright (c) 2000, 2013, Oracle and/or itsaffiliates. All rights reserved.

Oracle is a registered trademark of OracleCorporation and/or its

Affiliates. Other names may be trademarks oftheir respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c 'toclear the current input statement.

Mysql >

2.9 configure the global path to the mysql command

[root@localhost bin] # echo 'exportPATH=$PATH:/usr/local/mysql/bin' > > / etc/profile

[root@localhost bin] # tail-1 / etc/profile # check

Export PATH=$PATH:/usr/local/mysql/bin

Source / etc/profile # to make it effective

2.10 configure / etc/init.d/mysqldstart mode to start the database

[root@localhost bin] # cp/usr/local/mysql/bin/mysql.server / etc/init.d/mysqld

# copy the mysql startup script to / etc/init.d/

Chmod 700 / etc/init.d/mysqld # Grant 700 permissions, that is, the script can be executed

[root@localhost bin] # / etc/init.d/mysqld start

Starting MySQL. SUCCESS!

2.11 set Boot self-start

[root@localhost bin] # chkconfig-- add mysqld

[root@localhost bin] # chkconfig mysqld on

[root@localhost bin] # chkconfig-- list mysqld

Mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off

2.12 mysql security configuration, setting login password

[root@localhost bin] # mysqladmin-urootpassword '123456' # set password: 123456

3. Install PHP softwar

3.1 check the lib libraries required to install PHP

[root@localhost tools] # rpm-qa zlib libxmllibjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devel libjpeg-develfreetype-devel libpng-devel gd-devel curl-devel # check lib library installation

Install the required lib libraries

[root@localhost tools] # yum install zliblibxml libjpeg freetype libpng gd curl libiconv zlib-devel libxml2-devellibjpeg-devel freetype-devel libpng-devel gd-devel curl-devel-y

Install the libiconv library

[root@localhost tools] # wget http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.14.tar.gz

[root@localhost tools] # tar-zxvflibiconv-1.14.tar.gz

[root@localhost tools] # cd libiconv-1.14.tar.gz

[root@localhost libiconv-1.14] #. / configure-prefix=/usr/local/libiconv

[root@localhost libiconv-1.14] # make

[root@localhost libiconv-1.14] # make install

3.2 decompress the php software

[root@localhost tools] # tar-zxvfphp-5.5.32.tar.gz

[root@localhost tools] # ll

Total 67376

Drwxr-xr-x 14 1001 1001 4096 Feb 2 21:36 php-5.5.32

-rw-r--r-- 1 root root 17773092 Feb 22 11:22php-5.5.32.tar.gz

3.3 configuration

. / configure\

-- prefix=/usr/local/php5.5.32\

-- with-apxs2=/usr/local/apache/bin/apxs\

-- with-mysql=/usr/local/mysql\

-- with-xmlrpc\

-- with-openssl\

-- with-zlib\

-- with-freetype-dir\

-- with-gd\

-- with-jpeg-dir\

-- with-png-dir\

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

-- enable-short-tags\

-- enable-sockets\

-- enable-soap\

-- enable-mbstring\

-- enable-static\

-- enable-gd-native-ttf\

-- with-curl\

-- with-xsl\

-- enable-ftp\

-- with-libxml-dir

3.4 compile and install

[root@localhost php-5.5.32] # make

Build complete.

Don't forget to run 'make test'.

[root@localhost php-5.5.32] # make install

3.5 generate configuration file

[root@localhost php-5.5.32] # ls php.ini*

Php.ini-development php.ini-production

[root@localhost php-5.5.32] # ln-s/usr/local/php5.5.32 / usr/local/php

[root@localhost php-5.5.32] # cpphp.ini-production / usr/local/php/lib/php.ini

3.6 configure apache to support php

3.6.1 modify apache configuration file

Execute the following command to edit the main configuration file httpd.conf for apache:

[root@localhost /] # cd / usr/local/apache/conf

[root@localhost conf] # cp httpd.confhttpd.conf.20160516.bak

[root@localhost conf] # vim httpd.conf

# add the following:

ServerName 127.0.0.1:80

Go to line 311, the next line of the # AddTypeapplication/x-gzip .tgz line plus two lines of parsing support for PHP:

# AddType application/x-httpd-php .php .php3

AddType application/x-httpd-php .php .phtml

AddType application/x-httpd-php-source .phps

Modify the default home page file, adding an index.php in this example:

DirectoryIndex index.php index.html

3.7 check and start apache

Check the syntax of the apache configuration file

[root@localhost conf] # / usr/local/apache/bin/apachectl-t

Syntax OK

Restart the apache service

[root@localhost conf] # / usr/local/apache/bin/apachectl graceful

[root@localhost conf] # netstat-lntp | grep 80

Tcp 0 0: 80: * LISTEN 8989/httpd

# check whether port 80 of httpd service is enabled

3.8Test the php environment

After entering the specified default site directory, edit index.php to add:

Enter the default apache site directory

[root@localhost conf] # cd/usr/local/apache/htdocs/

[root@localhost conf] # vimindex.php

# Note the above code is a simple php file code that displays php configuration information. It is best to type it manually to prevent errors.

# by accessing and refreshing the browser http://ip, if you can see the phpinfo information, as shown in the figure below, it shows that the php environment is configured with ok

At this point, the LAMP stand-alone environment has been built!

Attachment: http://down.51cto.com/data/2367706

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

Database

Wechat

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

12
Report