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

LAMP environment-installation and configuration of a single-tier architecture

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

Share

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

Environment description

Set up nat conversion on the router

The system used in the Lamp environment is Red Hat Enterprise Linux 5.8x86x64

Kernel version 2.6.18-308.el5

The hostname provided by Lamp is www.fangyu.com

Because the test platform does not use DNS, use the local / etc/hosts file

Required software package

Httpd-2.2.29.tar.bz2

Mysql-5.5.28-linux2.6-x86_64.tar.gz

Php-5.3.29.tar.bz2

Wordpress-3.3.1-zh_CN.zip

Xcache-3.1.0.tar.gz

# install the pcre-devel package before installing http, because the rewirte module of httpd depends on pcre-devel

[root@station1 ~] # yum-y install pcre-devel

[root@station1 ~] #

# install http

[root@station1 ~] # tar xf httpd-2.2.29.tar.bz2

[root@station1 ~] # cd httpd-2.2.29

[root@station1 httpd-2.2.29] #. / configure-- prefix=/usr/local/apache\

>-- sysconfdir=/etc/httpd\

>-- enable-so\

>-- enable-rewirte\

>-- enable-ssl\

>-- enable-modules=most\

>-- enable-mods-shared=most\

>-- with-mpm=prefork

[root@station1 httpd-2.2.29] #

[root@station1 httpd-2.2.29] # make & & make install

# start httpd and test after installation is complete

[root@station1 httpd-2.2.29] # cd / usr/local/apache/bin

[root@station1 bin] #. / apachectl start

[root@station1 bin] # netstat-tnlp | grep: 80

Tcp 0 0: 80: * LISTEN 23458/httpd

[root@station1 bin] #

# client browser testing

# configure PATH search path

# here echo should use single quotation marks, otherwise $PATH will record the result in this file

[root@station1] # echo 'export PATH=$PATH:/usr/local/apache/bin' > / etc/profile.d/httpd.sh [root@station1 ~] # cat / etc/profile.d/httpd.sh export PATH=$PATH:/usr/local/apache/bin [root@station1 ~] # source / etc/profile.d/httpd.sh [root@station1 ~] #

# install Mysql database and use general binary software package

# create the users required to install Mysql

[root@station1] # groupadd-r-g 3306 mysql

[root@station1] # useradd-r-g 3306-u 3306 mysql

[root@station1] # tar xf mysql-5.5.28-linux2.6-x86_64.tar.gz-C / usr/local/

[root@station1 ~] # cd / usr/local/

[root@station1 local] # ln-s mysql-5.5.28-linux2.6-x86_64 mysql

[root@station1 local] # cd mysql

# modify owners and groups

[root@station1 mysql] # chown-R mysql:mysql. /

[root@station1 mysql] # ll

Total 76

Drwxr-xr-x 2 mysql mysql 4096 Sep 16 15:56 bin

-rw-r--r-- 1 mysql mysql 17987 Aug 29 2012 COPYING

Drwxr-xr-x 4 mysql mysql 4096 Sep 16 15:56 data

Drwxr-xr-x 2 mysql mysql 4096 Sep 16 15:55 docs

Drwxr-xr-x 3 mysql mysql 4096 Sep 16 15:56 include

-rw-r--r-- 1 mysql mysql 7604 Aug 29 2012 INSTALL-BINARY

Drwxr-xr-x 3 mysql mysql 4096 Sep 16 15:56 lib

Drwxr-xr-x 4 mysql mysql 4096 Sep 16 15:56 man

Drwxr-xr-x 10 mysql mysql 4096 Sep 16 15:56 mysql-test

-rw-r--r-- 1 mysql mysql 2552 Aug 29 2012 README

Drwxr-xr-x 2 mysql mysql 4096 Sep 16 15:56 scripts

Drwxr-xr-x 27 mysql mysql 4096 Sep 16 15:56 share

Drwxr-xr-x 4 mysql mysql 4096 Sep 16 15:56 sql-bench

Drwxr-xr-x 2 mysql mysql 4096 Sep 16 15:56 support-files

[root@station1 mysql] #

# create a directory where Mysql stores data files

[root@station1 mysql] # mkdir / mysql_data

[root@station1 mysql] # chown-R mysql:mysql / mysql_data

[root@station1 mysql] #

# initialize the database and specify the user and data file location

[root@station1 mysql] # scripts/mysql_install_db-user=mysql-datadir=/mysql_data/

Installing MySQL system tables...

OK

Filling help tables...

OK

To start mysqld at boot time you have to copy

Support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER!

To do so, start the server, then issue the following commands:

. / bin/mysqladmin-u root password' new-password'

. / bin/mysqladmin-u root-h station1.example.com password' new-password'

Alternatively you can run:

. / bin/mysql_secure_installation

Which will also give you the option of removing the test

Databases and anonymous user created by default. This is

Strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:

Cd. ;. / bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl

Cd. / mysql-test; perl mysql-test-run.pl

Please report any problems with the. / bin/mysqlbug script!

[root@station1 mysql] #

[root@station1 mysql] # chown-R root. /

[root@station1 mysql] # ll

Total 76

Drwxr-xr-x 2 root mysql 4096 Sep 16 15:56 bin

-rw-r--r-- 1 root mysql 17987 Aug 29 2012 COPYING

Drwxr-xr-x 4 root mysql 4096 Sep 16 15:56 data

Drwxr-xr-x 2 root mysql 4096 Sep 16 15:55 docs

Drwxr-xr-x 3 root mysql 4096 Sep 16 15:56 include

-rw-r--r-- 1 root mysql 7604 Aug 29 2012 INSTALL-BINARY

Drwxr-xr-x 3 root mysql 4096 Sep 16 15:56 lib

Drwxr-xr-x 4 root mysql 4096 Sep 16 15:56 man

Drwxr-xr-x 10 root mysql 4096 Sep 16 15:56 mysql-test

-rw-r--r-- 1 root mysql 2552 Aug 29 2012 README

Drwxr-xr-x 2 root mysql 4096 Sep 16 15:56 scripts

Drwxr-xr-x 27 root mysql 4096 Sep 16 15:56 share

Drwxr-xr-x 4 root mysql 4096 Sep 16 15:56 sql-bench

Drwxr-xr-x 2 root mysql 4096 Sep 16 15:56 support-files

[root@station1 mysql] #

# copy Mysql configuration file and startup script, lib library, include header file path

[root@station1 mysql] # cp support-files/my-large.cnf / etc/my.cnf

[root@station1 mysql] # cp support-files/mysql.server / etc/init.d/mysqld

[root@station1 mysql] #

[root@station1 ~] # echo "/ usr/local/mysql/lib" > / etc/ld.so.conf.d/mysql.conf

[root@station1 ~] # ldconfig-v | grep mysql

/ usr/local/mysql/lib:

Libmysqlclient.so.18-> libmysqlclient_r.so.18.0.0

[root@station1 ~] #

[root@station1] # ln-s / usr/local/mysql / usr/include/mysql

[root@station1 ~] #

# configure PATH search path

[root@station1 mysql] # echo 'export PATH=$PATH:/usr/local/mysql/bin' > / etc/profile.d/mysql.sh

[root@station1 mysql] # source / etc/profile.d/mysql.sh

[root@station1 mysql] #

# Test Mysql [root@station1 mysql] # / etc/init.d/mysqld start

Starting MySQL.. [OK]

[root@station1 mysql] #

[root@station1 mysql] # mysql

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

Your MySQL connection id is 1

Server version: 5.5.28-log MySQL Community Server (GPL)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

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

Mysql >\ Q

Bye

[root@station1 mysql] #

[root@station1 mysql] # mysqladmin-u root-p password 'fangyu421'

Enter password:

[root@station1 mysql] #

[root@station1 mysql] # mysql-u root-p

Enter password:

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

Your MySQL connection id is 4

Server version: 5.5.28-log MySQL Community Server (GPL)

Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

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

Mysql >

# install php in combination with module

[root@station1 ~] # tar xf php-5.3.29.tar.bz2

[root@station1 ~] #

[root@station1 ~] # cd php-5.3.29

[root@station1 php-5.3.29] #. / configure-- prefix=/usr/local/php\

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

>-- with-openssl\

>-- with-mysqli=/usr/local/mysql/bin/mysql_config\

>-- enable-mbstring\

>-- with-freetype-dir\

>-- with-jpeg-dir\

>-- with-png-dir\

>-- with-zlib\

>-- with-libxml-dir=/usr\

>-- enable-xml\

>-- enable-sockets\

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

>-- with-mcrypt\

>-- with-config-file-path=/etc\

>-- with-config-file-scan-dir=/etc/php.d\

>-- with-bz2

[root@station1 ~] #

# combination of httpd and php

# modify the httpd.conf configuration file and add a line of text

[root@station1 httpd] # vi httpd.conf

AddType application/x-httpd-php .php

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

DirectoryIndex index.php index.html

[root@station1 httpd] #

# Test php

[root@station1 ~] # cd / usr/local/apache/htdocs/

[root@station1 htdocs] # ls

Index.html

[root@station1 htdocs] # mv index.html index.php

[root@station1 htdocs] # vi index.php

< ?php phpinfo(); ? >

[root@station1 htdocs] #

[root@station1 htdocs] # apachectl stop

[root@station1 htdocs] # apachectl start

[root@station1 htdocs] #

# client for testing

# client tests the connection between php and mysql

< ?php $conn = mysql_connect('localhost','root','fangyu421'); if ($conn){ echo "mysql connect ok"; }else { echo "mysql connect fail"; } ? >

# provide xcache Accelerator for php

[root@station1 ~] # tar xf xcache-3.1.0.tar.gz

[root@station1 ~] # cd xcache-3.1.0

[root@station1 xcache-3.1.0] #

[root@station1 xcache-3.1.0] # / configure-- enable-xcache-- with-php-config=/usr/local/php/bin/php-config

[root@station1 xcache-3.1.0] # make & & make install

[root@station1 xcache-3.1.0] #

Installing shared extensions: / usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/

[root@station1 xcache-3.1.0] #

# combination of php and xcache

[root@station1 xcache-3.1.0] # mkdir / etc/php.d

[root@station1 xcache-3.1.0] # cp xcache.ini / etc/php.d/

[root@station1 xcache-3.1.0] #

[root@station1 ~] # vi / etc/php.d/xcache.ini

Extension = / usr/local/php/lib/php/extensions/no-debug-non-zts-20090626/xcache.so module location

Xcache.admin.user = "fangyu"

Xcache.admin.pass = "fangyu421"

Xcache.size = 60m modify according to the configuration of your host

Xcache.count = number of 1 CPU

[root@station1 ~] #

[root@station1 ~] # vi / usr/local/apache/htdocs/index.php

[root@station1 ~] # apachectl stop

[root@station1 ~] # apachectl start

[root@station1 ~] #

# Test whether php supports xcache

# provide services to the public network

# create and configure databases and users required by wordpress

Mysql > create database wordpress

Query OK, 1 row affected (0.15 sec)

Mysql > grant all on wordpress.* to 'wp'@'localhost' identified by' fangyu421'

Query OK, 0 rows affected (0.15 sec)

Mysql >\ Q

Bye

[root@station1 ~] #

# install wordpress skipped here

# the client sets the hostname / etc/hosts, and if it is not a test environment, add a record on DNS

[root@rhel6 ~] # cat / etc/hosts

127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4

:: 1 localhost localhost.localdomain localhost6 localhost6.localdomain6

172.16.10.11 www.fangyu.com

[root@rhel6 ~] #

# configure httpd, where virtual hosts based on IP addresses are used

[root@station1 ~] # vi / etc/httpd/httpd.conf

# DocumentRoot "/ usr/local/apache/htdocs" commented out

Include / etc/httpd/extra/httpd-vhosts.conf

[root@station1 ~] #

[root@station1 ~] # vi / etc/httpd/extra/httpd-vhosts.conf

< VirtualHost 172.16.10.11:80 >

ServerAdmin fangyu@fangyu.com

DocumentRoot "/ usr/local/apache/htdocs/"

ServerName "www.fangyu.com"

ErrorLog "logs/fangyu.error_log"

CustomLog "logs/fangyu.access_log" common

< Directory "/var/local/apache/htdocs">

Options none

AllowOverride none

Order allow,deny

Allow from all

< /Directory >

< /VirtualHost >

[root@station1 ~] #

The client carries out the overall test results.

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