In recent days, we often need to configure the apache + php + mysql environment in Linux. In the past, I always used yum in centos.
In recent days, we often need to configure the apache + php + mysql environment in Linux. In the past, I used to directly install yum in centos. Convenience is very convenient. But I always think that something is missing. In addition, the default source in Centos only supports PHP to Update to 5.1.6 and must be changed to the source. many sources found earlier are unavailable. Very troublesome. So I am so worried. Install the SDK directly using the compilation method. Now let's share my installation process.
First install the GCC GCC-C ++ compiler. The two compilers do not have high or low versions. Therefore, yum is directly used for installation.
yum install gcc gcc-c++
The packages we need to install have been downloaded here. We can use ba to put the bao package under/usr/local/src.
Then we start to install MySQL
First install Ncurese
tar -zxvf ncurese-5.9.tar.gzcd ncurese-5.9./configuremake && make install
After the installation is complete, we can start to install MySQL:
tar -zxvf mysql-5.1.68.tar.gz./configure --prefix=/usr/local/mysql --sysconfdir=/etc --datadir=/svr/mysqldata --with-charset=utf8 --with-extra-charsets=complex --enable-thread-safe-client --with-big-tables --with-ssl --with-embedded-server --enable-local-infile --enable-assembler --with-plugins=innobase --with-plugins=partitionmake && make install
After installing MySQL in the wan, we can start configuring MySQL.
Configure MySQL
#1. create mysql users and user groups groupadd mysqluseradd-g mysql-s/sbin/nologin mysql #2. configure the path strength information chown-R mysql: mysql/usr/local/mysql/to grant MySQL directory permissions to MySQL Users and Groups #3. create profile cp/usr/local/src/mysql-5.1.68/support-files/my-medium.cnf/etc/my. cnf # Edit/etc/my. cnfvi/etc/my. cnf add datadir = The first directory/svr/mysqldata #4 under [mysqld. initialize database/usr/local/mysql/bin/mysql_install_db -- user = mysql #5. grant the Database Directory permission of mysqldata to mysql User chown-R mysql: mysql/svr/mysqldata #6. start mysql/usr/local/mysql/bin/mysqld_safe -- user = mysql. add the mysql to servicecp/usr/local/src/mysql-5.1.68/support-files/mysql. server/etc/init. d/mysqldchmod 755/etc/init. d/mysqldchkconfig -- add mysqldchkconfig mysqld onservice mysqld restart #8. add the password/usr/local/mysql/bin/mysqladmin-uroot-p password to the Root user.
Now we have installed MySQL. So let's start installing Apache.
First, install apr and apr-util.
# Install tar-zxvf apr-1.4.6.tar.gzcd apr-1.4.6 for apr. /configuremake & make install # install tar-zxvf apr-util-1.5.2.tar.gzcd for apr-util. /configure -- with-apr =/usr/local/apr/make & make install
OK. Then, we can start to install apache.
tar -zxvf httpd-2.2.24.tar.gzcd httpd-2.2.24./configure --prefix=/usr/local/apache2 --enable-so --enable-rewrite --enable-mods-shared=most --enable-dav --with-apr=/usr/local/apr/bin/apr-1-config --with-apr-util=/usr/local/apr/bin/apu-1-config --enable-modules=so --enable-maintainer-modemake && make install
After apachee is installed, we are not busy with configuration. After the PHP installation is complete, configure it together. Next, we will start to install PHP.
First install zlib
tar -zxvf zlib-1.2.7.tar.gzcd zlib-1.2.7./configuremake && make install
Then install Libmcrypt
tar -zxvf libmcrypt-2.5.8.tar.gzcd libmcrypt-2.5.8./configuremakemake installcd libltdl./configure --enable-ltdl-installmakemake install
Then install libpng.
tar -zxvf libpng-1.6.1.tar.gzcd libpng-1.6.1./configuremake && make install
Then install iis6
tar -zxvf jpegsrc.v6b.tar.gzcd jpeg-6bmkdir /usr/local/jpeg6mkdir /usr/local/jpeg6/binmkdir /usr/local/jpeg6/libmkdir /usr/local/jpeg6/includemkdir -p /usr/local/jpeg6/man/man1./configure --prefix=/usr/local/jpeg6/ --enable-shared --enable-staticmakemake install
Install freetype again
tar -zxvf freetype-2.4.0.tar.gzcd freetype-2.4.0./configure --prefix=/usr/local/freetype/makemake install
Then install the gd Library
tar -zxvf gd-2.0.35.tar.gzcd gd-2.0.35./configure --prefix=/usr/local/gd2/ --with-jpeg=/usr/local/jpeg6/ --with-freetype=/usr/local/freetype/makemake install
Install libxml again
tar -zxvf libxml2-2.7.3.tar.gzcd libxml2-2.7.3./configuremakemake install
Finally, install CURL.
tar -zxvf curl-7.29.0.tar.gzcd curl-7.29.0./configure --prefix=/usr/local/curl/makemake install
After the installation is complete, we can start to install PHP.
tar -zxvf php-5.2.17.tar.gzcd php-5.2.17./configure --prefix=/usr/local/php/ --with-apxs2=/usr/local/apache2/bin/apxs --disable-debug --enable-safe-mode --enable-xml --with-mysql=/usr/local/mysql --with-gd=/usr/local/gd2 --with-zlib --with-zlib-dir=/usr/local/lib --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock --disable-posix --with-config-file-path=/usr/local/lib --with-jpeg-dir=/usr/local/jpeg6 --with-curl=/usr/local/curl/ --enable-zip --enable-mbstring --enable-pdo --with-pdo_mysql=/usr/local/mysql/ --enable-soap --with-png-dir=/usr/local/lib --with-freetype-dir=/usr/local/freetype --enable-zip --enable-json --enable-sockets --with-iconvmakemake install
Then we create a PHP configuration file.
cp php.ini-dist /usr/local/php/lib/php.ini
Finally, we will configure the Apache configuration file.
Vi/usr/local/apache2/conf/httpd. conf # Add: AddType application/x-httpd-php. phpAddType application/x-httpd-php-source. phps # note that the two lines are added after the other AddType # Make sure the file contains the following section, if there is no place, add LoadModule php5_module modules/libphp5.so after all loadmodules # because my local installation version is high, it is php5, if it is LoadModule php4_module # modules/libphp4.so, you can also # Find DirectoryIndex index.html. the line var is followed by the index. php is generally in line 1 # save and exit
Then ba adds Apache to the system service
Cp/usr/local/apache2/bin/apachectl/etc/rc. d/init. d/httpdvi/etc/rc. d/init. d/httpd # Find "#! /Bin/sh, and add: # chkconfig: 35 70 30 # description: Apache # save and exit chkconfig -- add httpdchkconfig httpd onservice httpd start # if an error is reported at this time. The error message is as follows # Cannot load/usr/local/apache2/modules/libphp5.so into server:/usr/local/apache2/modules/libphp5.so: cannot restore segment prot after reloc: permission denied # run chcon-c-v-R-u system_u-r object_r-t textrel_shlib_t/usr/local/apache2/modules/libphp5.so # and then run service httpd start # if the access fails. Enable access from Port 80 and Port 3306 in the firewall.