


PHP - detailed steps to build a LAMP environment under CentOS 65
转载请注明出处:http://blog.csdn.net/l1028386804/article/details/48551221
1. Confirm whether the environment required to build LAMP has been installed:
[root@localhost ~]#rpm -q make gcc gcc-c++ zlib-devel libtool libtool-ltdl libtool-ltdl-devel bisonncurses-devel
2. If not installed, install it with yum:
[root@localhost~]#yum -y install make gcc gcc-c++ zlib-devel libtool libtool-ltdllibtool-ltdl-devel bison ncurses-devel
3. Since you need to use compilation and installation, check whether httpd, mysql, and php are installed:
[root@localhost ~]#rpm -q httpd mysql php
[root@localhost ~]#rpm -e httpd --nodeps
[root@localhost ~]#rpm -e mysql --nodeps
[root@localhost ~]#rpm -e php --nodeps
Copy after login Introduction to the compilation and installation process:
1) Unzip tar Compressed software package with .gz suffix: The soft code files of each software required to build the LAMP environment are packaged and compressed files provided to us in tar.gz or .tgz, so we must decompress them and then unpack them. The command is as follows: [root@localhost ~]#rpm -e httpd --nodeps [root@localhost ~]#rpm -e mysql --nodeps [root@localhost ~]#rpm -e php --nodeps
tar–zxvf *.tar.gz 2) Source code package installation process in Linux system: The software required to build the LAMP environment is developed using C language, so installing the source code file requires at least configuration and compilation and installation in three steps
Configure (configure), compile (make), install (makeinstall)
4. Compile and install libxml2
[root@localhostlinux]# tar -zxvf libxml2-2.6.30.tar.gz [root@localhostlinux]# cd libxml2-2.6.30 [root@localhostlibxml2-2.6.30]# ./configure --prefix=/usr/local/libxml2 [root@localhostlibxml2-2.6.30]# make [root@localhostlibxml2-2.6.30]# make install
5. Compile and install libmcrypt
[root@localhostlinux]# tar -zxvf libmcrypt-2.5.8.tar.gz
[root@localhostlinux]# cd libmcrypt-2.5.8
[root@localhostlibmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt
[root@localhostlibmcrypt-2.5.8]# make
[root@localhostlibmcrypt-2.5.8]# make install
Copy after login
6. Compile and install zlib[root@localhostlinux]# tar -zxvf libmcrypt-2.5.8.tar.gz [root@localhostlinux]# cd libmcrypt-2.5.8 [root@localhostlibmcrypt-2.5.8]# ./configure --prefix=/usr/local/libmcrypt [root@localhostlibmcrypt-2.5.8]# make [root@localhostlibmcrypt-2.5.8]# make install
[root@localhostlinux]# tar -zxvf zlib-1.2.3.tar.gz
[root@localhostlinux]# cd zlib-1.2.3
[root@localhostzlib-1.2.3]# CFLAGS="-O3 -fPIC" ./configure --prefix=/usr/local/zlib/
(用64位元的方法进行编译)
[root@localhostzlib-1.2.3]# make
[root@localhostzlib-1.2.3]# make install
Copy after login
7. Compile and install libpng[root@localhostlinux]# tar -zxvf zlib-1.2.3.tar.gz [root@localhostlinux]# cd zlib-1.2.3 [root@localhostzlib-1.2.3]# CFLAGS="-O3 -fPIC" ./configure --prefix=/usr/local/zlib/ (用64位元的方法进行编译) [root@localhostzlib-1.2.3]# make [root@localhostzlib-1.2.3]# make install
[root@localhostlinux]# tar -zxvf libpng-1.2.31.tar.gz
[root@localhostlinux]# cd libpng-1.2.31
[root@localhostlibpng-1.2.31]# ./configure --prefix=/usr/local/libpng \
>--enable-shared (建立共享库使用的GNU的libtool)
[root@localhostlibpng-1.2.31]# make
[root@localhostlibpng-1.2.31]# make install
Copy after login
8. Compile and install jpeg[root@localhostlinux]# tar -zxvf libpng-1.2.31.tar.gz [root@localhostlinux]# cd libpng-1.2.31 [root@localhostlibpng-1.2.31]# ./configure --prefix=/usr/local/libpng \ >--enable-shared (建立共享库使用的GNU的libtool) [root@localhostlibpng-1.2.31]# make [root@localhostlibpng-1.2.31]# make install
[root@localhostlinux]# tar -zxvf jpegsrc.v6b.tar.gz
[root@localhostlinux]# cd jpeg-6b
[root@localhostjpeg-6b]# mkdir /usr/local/jpeg (创建jpeg软件的安装目录)
[root@localhostjpeg-6b]# mkdir /usr/local/jpeg/bin (创建存放命令的目录)
[root@localhostjpeg-6b]# mkdir /usr/local/jpeg/lib (创建jpeg库文件所在目录)
[root@localhostjpeg-6b]# mkdir /usr/local/jpeg/<strong>include</strong> (创建存放头文件目录)
[root@localhostjpeg-6b]# mkdir -p /usr/local/jpeg/man/man1 (建立存放手册的目录)
[root@localhostjpeg-6b]# ./configure --prefix=/usr/local/jpeg \
>--enable-shared \ (建立共享库使用的GUN的libtool)
>--enable-static (建立静态库使用的GUN的libtool)
[root@localhostjpeg-6b]# make
[root@localhostjpeg-6b]# make install
Copy after login
If the following error occurs when executing make: [root@localhostlinux]# tar -zxvf jpegsrc.v6b.tar.gz [root@localhostlinux]# cd jpeg-6b [root@localhostjpeg-6b]# mkdir /usr/local/jpeg (创建jpeg软件的安装目录) [root@localhostjpeg-6b]# mkdir /usr/local/jpeg/bin (创建存放命令的目录) [root@localhostjpeg-6b]# mkdir /usr/local/jpeg/lib (创建jpeg库文件所在目录) [root@localhostjpeg-6b]# mkdir /usr/local/jpeg/<strong>include</strong> (创建存放头文件目录) [root@localhostjpeg-6b]# mkdir -p /usr/local/jpeg/man/man1 (建立存放手册的目录) [root@localhostjpeg-6b]# ./configure --prefix=/usr/local/jpeg \ >--enable-shared \ (建立共享库使用的GUN的libtool) >--enable-static (建立静态库使用的GUN的libtool) [root@localhostjpeg-6b]# make [root@localhostjpeg-6b]# make install
./libtool --mode=compile gcc-O2 -I. -c ./jcapimin.c
make: ./libtool: Command notfoundmake: *** [jcapimin.lo] Error 127Solution:
libtool and libtool-ltdl-devel are installed by default (please see process 2 if you need help)
[root@localhostjpeg-6b]# find / -name config.sub /usr/share/libtool/config/config.sub [root@localhostjpeg-6b]# find / -name config.guess /usr/share/libtool/config/config.guess [root@localhostjpeg-6b]# cp -vRp /usr/share/libtool/config/config.sub . [root@localhostjpeg-6b]# cp -vRp /usr/share/libtool/config/config.guess .
make clean and then reconfigure
9. Compile and install freetype
[root@localhostlinux]# tar -zxvf freetype-2.3.5.tar.gz [root@localhostlinux]# cd freetype-2.3.5 [root@localhostfreetype-2.3.5]# ./configure --prefix=/usr/local/freetype \ >--enable-shared (建立共享库使用的GUN的libtool) [root@localhostfreetype-2.3.5]# make [root@localhostfreetype-2.3.5]# make install
10. Compile and install autoconf
[root@localhostlinux]# tar -zxvf autoconf-2.61.tar.gz
[root@localhostlinux]# cd autoconf-2.61
[root@localhostautoconf-2.61]# ./configure
[root@localhostautoconf-2.61]# make
[root@localhostautoconf-2.61]# make install
Copy after login
11. Compile and install GD[root@localhostlinux]# tar -zxvf autoconf-2.61.tar.gz [root@localhostlinux]# cd autoconf-2.61 [root@localhostautoconf-2.61]# ./configure [root@localhostautoconf-2.61]# make [root@localhostautoconf-2.61]# make install
[root@localhostlinux]# tar -zxvf gd-2.0.35.tar.gz
[root@localhostlinux]# cd gd-2.0.35
[root@localhostgd-2.0.35]# ./configure --prefix=/usr/local/gd \
>--with-zlib=/usr/local/zlib/ \ (指定zlib库文件的位置)
>--with-jpeg=/usr/local/jpeg/ \ (指定jpeg库文件的位置)
>--with-png=/usr/local/libpng/ \ (指定png库文件的位置)
>--with-freetype=/usr/local/freetype/ (指定freetype字体库的位置)
[root@localhostgd-2.0.35]# make
[root@localhostgd-2.0.35]# make install
Copy after login If the following error occurs when executing make:
[root@localhostlinux]# tar -zxvf gd-2.0.35.tar.gz [root@localhostlinux]# cd gd-2.0.35 [root@localhostgd-2.0.35]# ./configure --prefix=/usr/local/gd \ >--with-zlib=/usr/local/zlib/ \ (指定zlib库文件的位置) >--with-jpeg=/usr/local/jpeg/ \ (指定jpeg库文件的位置) >--with-png=/usr/local/libpng/ \ (指定png库文件的位置) >--with-freetype=/usr/local/freetype/ (指定freetype字体库的位置) [root@localhostgd-2.0.35]# make [root@localhostgd-2.0.35]# make install
make[2]: *** [gd_png.lo] Error 1
make[2]: Leaving directory`/usr/src/linux/gd-2.0.35'make[1]: *** [all-recursive]Error 1make[1]: Leaving directory`/usr/ src/linux/gd-2.0.35'
make: *** [all] Error 2
Solution:
[root@localhostgd-2.0.35]# find / -name gd_png.c /usr/src/linux/gd-2.0.35/gd_png.c [root@localhostgd-2.0.35]# find / -name png.h /usr/local/libpng/<strong>include</strong>/png.h [root@localhostgd-2.0.35]# vi /usr/src/linux/gd-2.0.35/gd_png.c 将#<strong>include</strong> "png.h" 改为#<strong>include</strong> "/usr/local/libpng/<strong>include</strong>/png.h"
12. When compiling and installing Apache
[root@localhostlinux]# tar -zxvf httpd-2.2.9.tar.gz
[root@localhostlinux]# cd httpd-2.2.9
[root@localhosthttpd-2.2.9]# ./configure --prefix=/usr/local/<strong>Apache</strong> \
> --enable-so \ (以动态共享<strong>对象</strong>编译)
>--enable-rewrite (基于规则的URL操控)
[root@localhosthttpd-2.2.9]# make
[root@localhosthttpd-2.2.9]# make install
将<strong>Apache</strong>加入开机启动↓
[root@localhosthttpd-2.2.9]# cp -vRp /usr/local/<strong>Apache</strong>/bin/<strong>Apache</strong>ctl /etc/init.d/httpd
[root@localhosthttpd-2.2.9]# <strong>chmod</strong> +x /etc/init.d/httpd
添加<strong>Apache</strong>服务↓
[root@localhosthttpd-2.2.9]# chkconfig --add httpd
[root@localhosthttpd-2.2.9]# chkconfig --level 2345 httpd on
[root@localhosthttpd-2.2.9]# service httpd start
Copy after login If the following error occurs when starting the service: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomainfor ServerName
[root@localhostlinux]# tar -zxvf httpd-2.2.9.tar.gz [root@localhostlinux]# cd httpd-2.2.9 [root@localhosthttpd-2.2.9]# ./configure --prefix=/usr/local/<strong>Apache</strong> \ > --enable-so \ (以动态共享<strong>对象</strong>编译) >--enable-rewrite (基于规则的URL操控) [root@localhosthttpd-2.2.9]# make [root@localhosthttpd-2.2.9]# make install 将<strong>Apache</strong>加入开机启动↓ [root@localhosthttpd-2.2.9]# cp -vRp /usr/local/<strong>Apache</strong>/bin/<strong>Apache</strong>ctl /etc/init.d/httpd [root@localhosthttpd-2.2.9]# <strong>chmod</strong> +x /etc/init.d/httpd 添加<strong>Apache</strong>服务↓ [root@localhosthttpd-2.2.9]# chkconfig --add httpd [root@localhosthttpd-2.2.9]# chkconfig --level 2345 httpd on [root@localhosthttpd-2.2.9]# service httpd start
Solution:
[root@localhosthttpd-2.2.9]# vi /usr/local/<strong>Apache</strong>/conf/httpd.conf
service httpd does not support chkconfig
Solution:
[root@localhosthttpd-2.2.9]# vi /etc/rc.d/init.d/httpd
#chkconfig:2345 10 90 #description:Activates/Deactivates<strong>Apache</strong> Web Server
13. Compile and install mysql (the latest version All require cmake to compile and install)
[root@localhostlinux]# tar -zxvf cmake-2.8.7.tar.gz [root@localhostlinux]# cd cmake-2.8.7 [root@localhostcmake-2.8.7]# ./bootstrap [root@localhostcmake-2.8.7]# gmake [root@localhostcmake-2.8.7]# gmake install
[root@localhostcmake-2.8.7]# groupadd mysql [root@localhostcmake-2.8.7]# useradd -g mysql mysql [root@localhostlinux]# tar -zxvf mysql-5.5.15.tar.gz [root@localhostlinux]# cd mysql-5.5.15 [root@localhostmysql-5.5.15]# cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ (安装根目录) > -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysql.sock \ (UNIX socket文件) >-DDEFAULT_CHARSET=utf8 \ (默认字符集) >-DDEFAULT_COLLATION=utf8_general_ci \ (默认编码) >-DWITH_EXTRA_CHARSETS=utf8,gbk \ (额外的编码) >-DWITH_PERFSCHEMA_STORAGE_ENGINE=1 \(启用PERFSCHEMA引擎支持) >-DWITH_FEDERATED_STORAGE_ENGINE=1 \ (启用FEDERATED引擎支持) > -DWITH_PARTITI (启用PARTITION引擎支持) >-DWITH_ARCHIVE_STORAGE_ENGINE=1 \ (启用ARCHIVE引擎支持) >-DWITH_READLINE=1 \(使用readline功能) >-DMYSQL_DATADIR=/usr/local/mysql/data \ (数据库数据目录) >-DMYSQL_TCP_PORT=3306 (TCP/IP端口) [root@localhostmysql-5.5.15]# make [root@localhostmysql-5.5.15]# make install [root@localhostmysql-5.5.15]# cp -vRp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf
[root@localhostmysql-5.5.15]# vi /etc/my.cnf basedir=/usr/local/mysql datadir=/usr/local/mysql/data log-error=/usr/local/mysql/data/error.log pid-file=/usr/local/mysql/data/mysql.pid
[root@localhostmysql-5.5.15]# /usr/local/mysql/scripts/mysql_install_db \
>--defaults-flie=/etc/my.cnf \
> --basedir=/usr/local/mysql/\
>--datadir=/usr/local/mysql/data \
>--pid-file=/usr/local/mysql/data/mysql.pid \
> --user=mysql
Copy after login permission settings↓
[root@localhostmysql-5.5.15]# /usr/local/mysql/scripts/mysql_install_db \ >--defaults-flie=/etc/my.cnf \ > --basedir=/usr/local/mysql/\ >--datadir=/usr/local/mysql/data \ >--pid-file=/usr/local/mysql/data/mysql.pid \ > --user=mysql
[root@localhostmysql]# chown -R root . [root@localhostmysql]# chown -R mysql data [root@localhostmysql]# chgrp -R mysql .
[root@localhostmysql]# cp -vRp support-files/mysql.server /etc/init.d/mysqld [root@localhostmysql]# <strong>chmod</strong> +x /etc/init.d/mysqld
[root@localhostmysql]# chkconfig --add mysqld [root@localhostmysql]# chkconfig --level 345 mysqld on [root@localhostmysql]# service mysqld start
[root@localhostmysql]# bin/mysql mysql> deletefrom mysql.user where Host!='localhost'; (只留允许本机登录的帐号) mysql> flushprivileges; (刷新授权表) mysql> setpassword for 'root'@'localhost'=password('123456'); (设置用户密码) mysql> exit [root@localhostmysql]# bin/mysql -h localhost -u root -p123456 (登录mysql)
14. Compile and install php
[root@localhostlinux]# tar -zxvf php-5.3.19.tar.gz [root@localhostlinux]# cd php-5.3.19 [root@localhostphp-5.3.19]# ./configure --prefix=/usr/local/php \ >--with-apxs2=/usr/local/<strong>Apache</strong>/bin/apxs \ >--with-mysql=/usr/local/mysql/ \ >--with-libxml-dir=/usr/local/libxml2/ \ >--with-png-dir=/usr/local/libpng/ \ >--with-jpeg-dir=/usr/local/jpeg/ \ >--with-freetype-dir=/usr/local/freetype/ \ > --with-gd=/usr/local/gd/\ >--with-mcrypt=/usr/local/libmcrypt/ \ >--with-mysqli=/usr/local/mysql/bin/mysql_config \ > --enable-soap\ (变量激活SOAP和web services支持) >--enable-mbstring=all \ (使多字节字符串支持) >--enable-sockets (变量激活socket通讯特性) [root@localhostphp-5.3.19]# make [root@localhostphp-5.3.19]# make install [root@localhostphp-5.3.19]# cp -vRp php.ini-development /etc/php.ini [root@localhostphp-5.3.19]# vi /usr/local/<strong>Apache</strong>/conf/httpd.conf
AddType application/x-httpd-php .php
[root@localhostphp-5.3.19]# service httpd stop
[root@localhostphp-5.3.19]# service httpd start
Copy after login
[root@localhostphp-5.3.19]# vi /usr/local/<strong>Apache</strong>/htdocs/phpinfo.php
Copy after login Add the content as:
<?php
phpinfo();
?>
Copy after login opens the browser to access. If the PHP version interface appears, the installation is successful.
[root@localhostphp-5.3.19]# service httpd stop [root@localhostphp-5.3.19]# service httpd start
[root@localhostphp-5.3.19]# vi /usr/local/<strong>Apache</strong>/htdocs/phpinfo.php
<?php phpinfo(); ?>
The above introduces the detailed steps of setting up a LAMP environment under PHP - CentOS 65, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

Redis uses a single threaded architecture to provide high performance, simplicity, and consistency. It utilizes I/O multiplexing, event loops, non-blocking I/O, and shared memory to improve concurrency, but with limitations of concurrency limitations, single point of failure, and unsuitable for write-intensive workloads.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

Effective monitoring of Redis databases is critical to maintaining optimal performance, identifying potential bottlenecks, and ensuring overall system reliability. Redis Exporter Service is a powerful utility designed to monitor Redis databases using Prometheus. This tutorial will guide you through the complete setup and configuration of Redis Exporter Service, ensuring you seamlessly build monitoring solutions. By studying this tutorial, you will achieve fully operational monitoring settings
