CentOS7 LAMP compilation and installation, and centos7lamp Compilation

Source: Internet
Author: User
Tags install openssl php example

CentOS7 LAMP compilation and installation, and centos7lamp Compilation
1. Compile and install Apache1. Resolve dependencies (1) Compile and install apr (2) Compile and install apr-util (3) the httpd-2.4.27 compilation process also depends on the pcre-devel package, users must be installed in advance (4, group 2, compile and install httpd-2.4.273, configure Apache 2, compile and install Mysql1, prepare the database to store the file system 2, create a user, group 3, compile 4, initialize mysql database 5, set boot 6. logon detection 3. Compile and install PHP1, resolve dependencies 2. Install PHP3, provide configuration files for PHP 4. Edit the apache configuration file httpd. conf, with apache support php5, test php installation is successful: use environment: Centos7 64 source package: apr-1.5.2.tar.bz2apr-util-1.5.4.tar.bz2httpd-2.4.27.tar.gzmysql-5.6.25.tar.gzphp-5.6.10.tar.bz2 to get LAMP Ring Environment source package collection: https://pan.baidu.com/s/1eRBMSBg are personal collection, compilation and installation of Apache1, solve the dependency here is the use of httpd-2.4.27, need to upgrade apr and apr-util, you can use rpm package upgrade, the source code is used for upgrade. (1) Compile and install apr # tar-xjvf apr-1.5.2.tar.bz2 # cd apr-1.5.2 #. /configure -- prefix =/usr/local/apr # make & make instal (2) Compile and install apr-util # tar-xjvf apr-util-1.5.4.tar.bz2 # cd apr-util-1.5.4 #. /configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr # make & make instal (3) the httpd-2.4.27 compilation process depends on the pcre-devel package, which can be installed using source code or yum. Here, for convenience, yum is installed directly. # yum install pcre-devel (4) creates a user, group # groupadd-r apache # useradd-r-g apache apache2, compile and install httpd-2.4.27 # tar xf httpd-2.4.27.tar.gz # cd httpd-2.4.27 #. /configure -- prefix =/usr/local/apache -- sysconfdir =/etc/httpd -- enable-so -- enable-ssl -- enable-cgi -- enable-rewrite -- with-zlib -- -pcre -- with-apr =/usr/local/apr -- with-apr-util =/usr/local/apr-util -- enable-modules = most -- enable-mpms-shared = all -- with-mpm = event # checking whether to enable mod_ssl... configure: error: mod_ssl has been requested but can not be built due to prerequisite failures # The error indicates that openssl-devel # yum install openssl-devel # make-j 4 & make install use scripts to control Apache, start the service #/usr/local/apache2/bin/apachectl start use scripts to control Apache, stop Service #/usr/local/apache2/bin/apachectl stop3. Configure Apache # vi/etc/httpd. conf (1) Search ServerName www.example.com: 80, remove the preceding comment (2) Modify DocumentRoot to/home/htdocs, <Directory to/home/htdocs in the following sentence of this line is the www root Directory setting # cp/usr/local/apache/bin/apachectl/etc/init. d/httpd # vi httpd Add the following two lines of text under the first line # Comments to support chkconfig on RedHat Linux # chkconfig: 2345 90 90 # note that # description: http server # note that you must add # sign up for this service # chkconfig -- add httpd # auto start in all boot modes # chkconfig httpd on #345 auto start in Boot Mode 2. Compile and install Mysql1 and prepare create a mydata independent LVM2 file system # pvcreate/dev/sda3 # vgcreate myvg/dev/sda3 # lvcreate-L 10G-n mydata myvg # mke2fs-t ext4/dev/myvg/mydata # mkdir/mydata # echo "/dev/myvg/mydata ext4 defaults 0 0">/etc/fstab # mount-a2, create a user group # mkdir/usr/local/mysql # groupadd-r mysql # useradd-g mysql-r-s/sbin/nologin-M-d/mydata/data mysql # chown- R mysql: mysql/mydata/data # chown-R mysql: mysql/usr/local/mysql3. compilation starts from mysql5.5, and mysql source code installation begins with cmake, set the source code compilation configuration script # cmake-DCMAKE_INSTALL_PREFIX =/usr/local/mysql \-DMYSQL_DATADIR =/mydata/data \-DSYSCONFDIR =/etc \-runtime = 1 \-DWITH_INNOBASE_STORAGE_ENGINE = \-DWITH_MEMORY_STORAGE_ENGINE = 1 \-DWITH_READLINE = 1 \-DMYSQL_UNIX_ADDR =/var/lib/mysql. sock \-DMYSQL_TCP_PORT = 3306 \-DENABLED_LOCAL_INFILE = 1 \-character = 1 \-DEXTRA_CHARSETS = all \-DDEFAULT_CHARSET = utf8 \-DDEFAULT_COLLATION = utf8_general_ci

-DCMAKE_INSTALL_PREFIX = dir_name Set the mysql installation directory
-DMYSQL_UNIX_ADDR = file_name Set the listening socket path, which must be an absolute path name. The default value is/tmp/mysql. sock.
-DDEFAULT_CHARSET = charset_name Set the character set of the server.
By default, MySQL uses the latin1 (CP1252 Western Europe) Character Set. The cmake/character_sets.cmake file contains a list of allowed character set names.
-DDEFAULT_COLLATION = collation_name Set the server's sorting rules.
-DWITH_INNOBASE_STORAGE_ENGINE = 1
-DWITH_ARCHIVE_STORAGE_ENGINE = 1
-DWITH_BLACKHOLE_STORAGE_ENGINE = 1
-DWITH_PERFSCHEMA_STORAGE_ENGINE = 1
Storage engine options:
MyISAM, MERGE, MEMORY, and CSV engines are compiled to the server by default and do not need to be explicitly installed.
Statically compile a storage engine to the server and use-DWITH_engine_STORAGE_ENGINE = 1
Available storage engine values include ARCHIVE, BLACKHOLE, EXAMPLE, FEDERATED, INNOBASE (InnoDB), PARTITION (partitioning support), and PERFSCHEMA (Performance Schema)
-DMYSQL_DATADIR = dir_name Set the mysql database file directory
-DMYSQL_TCP_PORT = port_num Set the listening port of the mysql server. The default value is 3306.
-DENABLE_DOWNLOADS = bool Whether to download optional files. For example, if this option is enabled (set to 1), cmake downloads the test suite used by Google to run unit tests.
No cmake installation # yum insatall cmake-y may encounter the following error: remove CMakeCache.txt and rerun cmake. on Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates it is ncurses-deve # prompt to install software, according to the system installation package # make & make install 4, initialize mysql database copy configuration file # cp/usr/local/mysql/support-files/my-default.cnf/etc/my. cnf configuration file # vi/etc/my. cnf add datadir =/mydata/data #/usr/local/mysql/scripts/mysql_install_db -- user = mysql -- B Asedir =/usr/local/mysql -- datadir =/mydata/data # ln-s/usr/local/mysql/bin/*/bin/5. Set startup # chkconfig mysqld on6, login detection # mysql-u root-p three, compile and install PHP1, resolve dependencies # yum-y install bzip2-devel libmcrypt-devel libxml2-devel to install libmcrypt-devel needs to configure the epel source, epel source tar-xjvf php-5.6.10.tar.bz2 # cd php-5.6.10 #. /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 -- enable-maintainer-zts # Make & make install3. Provide the configuration file for PHP # cp php. ini-production/etc/php. ini4. Edit the apache configuration file httpd. conf. apache supports php # vim/etc/httpd. conf (1), add the following two lines AddType application/x-httpd-php. php AddType application/x-httpd-php-source. phps (2), locate to DirectoryIndex index.html and change to: DirectoryIndex index. php index.html and then restart httpd, or re-load the configuration file to test whether php can be used normally. 5. Test whether php is installed successfully: The index. php example on the test page is as follows: <? Php $ link = mysql_connect ('2017. 0.0.1 ', 'root', 'root'); if ($ link) echo "Success... "; else echo" Failure... "; mysql_close (); phpinfo ();?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.