Deployment and Application of LAMP platform
Deployment and Application of LAMP platform
I install the Apache service
1 remove httpd installed in rpm mode
Rpm-e httpd-- nodeps
2 install supported software packages
Yum-y install apr apr-devel cyrus-sasl-devel expat-devel libdb-devel openldap-devel apr-util-devel apr-util pcre-devel pcre
The result is shown in the figure:
3 source code compilation and installation
Upload rz httpd...
Decompress tar zxf httpd... -C / usr/src
Cd / usr/src/httpd...
Configuration and compilation installation
. / configure-prefix=/usr/local/httpd-enable-so-enable-rewrite-enable-charset-lite-enable-cgi & & make & & make install
Add system services
Vim / lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target
[Service]
Type=forking
PIDFile=/usr/local/httpd/logs/httpd.pid
ExecStart=/usr/local/bin/apachectl $OPTIONS
ExecReload=/bin/kill-HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=graphical.target
4 start the system service
Systemctl start (stop) httpd
Systemctl enable httpd booting automatically
If it appears: Job for httpd.service failed because the control process exited with error code. See "systemctl status httpd.service" and "journalctl-xe" for details.
Check the configuration file to ensure that the connection is optimized when there is no error.
Ln-s / usr/local/httpd/bin/* / usr/local/bin/
The result is shown in the figure:
Vim / usr/local/httpd/conf/httpd.conf
Second, install and start MySQL
1 yum-y install ncurses-devel
2 install the cmake compiler installation package
Rz upload
Tar zxf cmake..
Cd cmake...
. / configure & & gmake & & gmake install
3 source code compilation and installation
Create group user groupadd mysql
Create user useradd-M-s / sbin/nologin mysql-g mysql
Decompress tar zxf mysql... -C / usr/src
Configure cd / usr/src/mysql... .
Cmake-DCMAKE_INSTALL_PREFIX=/usr/local/mysql-DSYSCONFDIR=/etc-DDEFAULT_CHARSET=utf8-DDEFAULT_COLLATION=utf8_general_ci-DWITH_EXTRA_CHARSETS=all
Compile and install make & & make install
4 adjustments after installation
Permission setting chown-R mysql:mysql / usr/local/mysql
Create a profile:
CentOS 7 supports MariaDB database by default, and / etc/my.cnf is the configuration of MariaDB by default.
The file therefore needs to be replaced with the original file of MySQL
Rm-rf / etc/my.cnf
Cp support-files/my-default.cnf / etc/my.cnf
Initialize the database
/ usr/local/mysql/scripts/mysql_install_db-user=mysql-basedir=/usr/local/mysql-datadir=/usr/local/mysql/data/
Set up variable environment
Echo "PATH=$PATH:/usr/local/mysql/bin" > > / etc/profile
. / etc/profile takes effect
If FATAL ERROR: please install the following Perl modules before executing / usr/local/mysql/scripts/mysql_install_db:
Data::Dumper
Solution: yum-y install autoconf
5 add system services
Cp support-files/mysql.server / usr/local/mysql/bin/mysql.sh
Chmod + x / usr/local/mysql/bin/mysql.sh
Method 1: ln-s / usr/local/mysql/bin/* / usr/local/bin/ is enabled with mysql.sh start
Method 2: vim / usr/lib/systemd/system/mysqld.service
Reload: systemctl daemon-reload restart
Systemctl stop (start) mysqld
Third, construct the running environment of PHP
1. View and uninstall the rpm package PHP
Rpm-e php php-cli php-ldap php-common php-mysql-- nodeps
two。 Install the mcrypt encryption tool
Premise: yum-y install zlib-devel xz-devel libxml2-devel
(1) decompression
Libmcrypt mhash mcrypt (available for download from http://sourceforge.net)
(2) cd / usr/src/libmcypt...
. / configure & & make & & make install
Ln-s / usr/local/lib/libmcrypt. / usr/lib
(3) cd / usr/src/mhash...
. / configure & & make & & make install
Ln-s / usr/local/lib/libmhash / usr/lib
(4) cd / usr/src/mcrypt...
. / configure & & make & & make install
If you report an error (configure: error: * libmcrypt was not found)
Then reconfigure the installation after export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
3. Compile and install PHP
(1) decompress: tar zxf php-5... -C / usr/src
(2) compile and install
Cd / usr/src/php-5...
. / configure-prefix=/usr/local/php5-- with-mcrypt-- with-apxs2=/usr/local/httpd/bin/apxs-- with-mysql=/usr/local/mysql-- with-mysqli=/usr/local/mysql/bin/mysql_config-- with-config-file-path=/usr/local/php5-- enable-mbstring & & make & & make install
4. Set up the LAMP build environment
(1) php.ini configuration adjustment
After installing the PHP package, the server does not automatically create a configuration file for php.ini, but provides two samples in the source package directory
Php.ini-development development version
Php.ini-production production version
Cp / usr/src/php... / php.ini-development / usr/local/php5/php.ini
Vim / usr/local/php5/php.ini
Default_charset = "utf-8"
Short_open_tag = on
Extension=php_mysqli.dll
(2) add ZendGuardLoader optimization module (http://www.zend.com))
Tar zxf zend... -C / usr/src
Cd / usr/src/zend...
Cp Zend... / usr/local/php5/lib/php
Vim / usr/loca/php5/php.ini
Zend_extension=/usr/local/php5/lib/php/ZendGuardLoader.so
Zend_loader.enable=1
(3) httpd.conf configuration adjustment
Vim / usr/local/httpd/conf/httpd.conf
DirectoryIndex index.html index.php
AddType application/x-httpd-php .php
/ usr/local/httpd/bin/apachectl restart
(4) testing
① tests whether the PHP web page is displayed correctly
Vim / usr/local/httpd/htdocs/test1.php
Results:
② tests whether PHP web pages can access the MySQL database
Vim / usr/local/httpd/htdocs/test2.php
Results:
5. Install phpMyadmin (official address: http://www.phpadmin.net)
(1) decompression
(2) mv phpMyadmin... / usr/local/httpd/htdocs/phpmyadmin
(3) cd / usr/local/httpd/htdocs/phpmyadmin
Cp config.sample.inc.php config.inc.php
(4) access testing
Mysqladmin-u root-p password '123456'
Results: