The study of linux began very early. I learned unix in college. Later, I went to see linux every year. Because I was in a small city, I rarely used it in practical work. It is basically smart cloud. My colleagues also said that you can't use it when you learn it. The IT ecology is bad and useless! However, I always wanted to learn linux, so this time I decided to build a lamp environment, record it and take it as learning notes.
Many of the materials of lamp environment searched on the Internet are yum or old materials. In order to make yourself type a few more commands, I chose the way of source package. Seriously, for beginners like me, it may take a long time to solve even if the installation and configuration of the newer source package is a little different.
Therefore, in order to build this lamp environment, I have repeatedly compared data and tried it a little, no less than 10 times. I thought, why isn't there a relatively new sharing tutorial on the Internet that is easy for beginners to follow? Think about how you've finally built it and shared it. I hope it can help beginners like me.
Look at the online tutorials. They are the same. You copy mine and I copy yours. The author is lazy to write his own words.
I hope the logic of the tutorial is as follows: premise of installation preface - > compilation and installation - > configuration implementation - > ending. When I see the online commands to configure, I directly follow the installation and compilation commands. For a while, there is a command and here is a command. I can knock any command when I think of it. It's a mess, and I want to learn from Mr. Li Ming, Getting an sh script can be cumbersome. When I said this, I didn't think I was too angry. I just wrote out the unhappiness of the online tutorials I met in learning to build a lamp environment. Besides, I'm just a beginner. Where can I be proud of it? And I'm still guilty of sharing my lamp.
I built it in a virtual machine (vmware). The method is stupid. hey.
If you are a beginner like me and want to build your own lamp environment with a relatively new source package, you may be able to help you by following me.
VMware builds the lamp environment (centos 6.5). After installing centos, you need to configure three network connection modes for the network environment: 1. Bridge, use the real network card to communicate with your computer, and configure the ip to the same network segment as the real computer, so that you can communicate with your computer and other computers in the LAN, which is equivalent to a real computer in the LAN. 2NAT, the virtual machine communicates with your j computer through the fake network card VMnet8. (it can only communicate with your computer and does not occupy LAN ip) 3host only, the virtual machine communicates with your computer through the fake network card VMnet1. (it can only communicate with your computer and does not occupy LAN ip)
In order for other computers in the LAN to access my virtual server, I use the bridge mode. The ip network segment of the virtual machine must be the same as that of the network card used (which network connection mode will be used)
Before installation:
1. Create a directory
cd / mkdir -p /lamp/sh /lamp/tar_gz /lamp/backup
/lamp/tar_gz place source package / lamp/sh place sh script / lamp/backup place compilation and installation log
2,
yum -y install gcc gcc-c++
3,
vim /etc/sysconfig/selinux
The corresponding edit inside
SELINUX=disabled
4,
Upload all source packages downloaded to your computer to / lamp/tar_gz
5,
cd /lamp/sh vim auto-zxvf.sh
Copy the following code to auto-zxvf Sh (if you open it with windows editor and upload it again, an error will occur)
#!/bin/bash cd /lamp/tar_gz ls *.tar.gz > ls.list for TAR in `cat ls.list` do tar -zxvf $TAR done
Then save (wq) and hit the command
bash auto-zxvf.sh
After executing the above shell, cd /lamp/tar_gz, you can see the unpacked files
Start installation
To install apache:
#You need to install apr, apr util, PCRE and zlib required by apache first cd /lamp/tar_gz/apr-1.4.5 ./configure --prefix=/usr/local/apr/ make make install > /lamp/backup/apr.install.log cd /lamp/tar_gz/apr-util-1.3.12 ./configure --prefix=/usr/local/apr-util/ --with-apr=/usr/local/apr/ make make install > /lamp/backup/apr-util.install.log cd /lamp/tar_gz/pcre-8.32 ./configure --prefix=/usr/local/pcre/ make make install > /lamp/backup/pcre.install.log cd /lamp/tar_gz/zlib-1.2.8 ./configure make make install > /lamp/backup/zlib.install.log cd /lamp/tar_gz/httpd-2.4.10 ./configure --prefix=/usr/local/apache2 --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre --enable-modules=most make make install > /lamp/backup/apache2.install.log
Install mysql
#MySQL has been using cmake compiler since version 5.5 #Packages required before mysql installation cmake, ncurses, bison cd /lamp/tar_gz/cmake-2.8.5 ./configure --prefix=/usr/local/cmake/ make make install > /lamp/backup/cmake.install.log #Perform this step, otherwise - bash: cmake: command not found will be prompted export PATH=/usr/local/cmake/bin:$PATH cd /lamp/tar_gz/ncurses-5.7 ./configure --with-shared --without-debug --without-ada --enable-overwrite make make install > /lamp/backup/ncurses.install.log cd /lamp/tar_gz/bison-3.0 ./configure make make install > /lamp/backup/bison.install.log groupadd mysql useradd -g mysql mysql cd /lamp/tar_gz/mysql-5.6.22 cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_EXTRA_CHARSETS:STRING=utf8,gbk \ -DWITH_MYISAM_STORAGE_ENGINE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DWITH_READLINE=1 \ -DENABLED_LOCAL_INFILE=1 \ -DMYSQL_DATADIR=/usr/local/mysql \ -DMYSQL_TCP_PORT=3306 make make install > /lamp/backup/mysql.install.log
Install php
#This step made mistakes. Later, many schemes were found on the Internet, and the result was just add "-- without zlib" cd /lamp/tar_gz/libxml2-2.6.30 ./configure --prefix=/usr/local/libxml2/ --without-zlib make && make install > /lamp/backup/libxml2.install.log cd /lamp/tar_gz/libmcrypt-2.5.8 ./configure --prefix=/usr/local/libmcrypt/ make make install > /lamp/backup/libmcrypt.install.log cd /lamp/tar_gz//libpng-1.6.16 ./configure --prefix=/usr/local/libpng/ make make install > /lamp/backup/libpng.install.log #Mr. Li Ming's tutorials and other online tutorials after 2013 need to establish some folders, which may be due to the JPEG 6 version. I don't need to create new folders here cd /lamp/tar_gz/jpeg-9a ./configure --prefix=/usr/local/jpeg --enable-shared --enable-static make make install > /lamp/backup/jpeg.install.log cd /lamp/tar_gz/freetype-2.5.5 ./configure --prefix=/usr/local/freetype/ make make install > /lamp/backup/freetype.install.log cd /lamp/tar_gz/autoconf-2.69 ./configure make make install > /lamp/backup/autoconf.install.log cd /lamp/tar_gz/gd-2.0.35 ./configure --prefix=/usr/local/gd2/ --with-jpeg=/usr/local/jpeg/ --with-freetype=/usr/local/freetype/ make make install > /lamp/backup/gd2.install.log cd /lamp/tar_gz/php-5.5.21 #Don't write it like this: - with apxs2 = / usr / local / apache2 / bin / apxs / an additional slash indicates the directory, and an error will occur ./configure --prefix=/usr/local/php/ --with-libxml-dir=/usr/local/libxml2/ --with-mysql=/usr/local/mysql/ --with-apxs2=/usr/local/apache2/bin/apxs --with-config-file-path=/usr/local/php/etc make make install > /lamp/backup/php.install.log
Note: you can copy all the above codes (apache,mysql,php installation) into an SH file, such as auto make install SH, the file can be placed in / lamp/sh. Then just hit the command: bash auto make install SH, let all the source files compile and install automatically, and then you can go to see a small movie and have a chat
After installation, start configuration
Configuring apache
#Power on echo "/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local #Edit profile #httpd.conf if the path of the configuration file is not specified when installing apache, the default configuration file is used, which is used here according to the situation vim /usr/local/apache2/conf/httpd.conf #Remove the comment and replace with ServerName localhost:80 #In the search for AddType, add in the appropriate place AddType application/x-httpd-php .php .phtml #Add an index php, <IfModule dir_module> DirectoryIndex index.html index.php </IfModule> #Path, which can be modified according to personal conditions DocumentRoot "/usr/local/apache2/htdocs" :wq Save exit #Start and see /usr/local/apache2/bin/apachectl start
Configure mysql
#Change the mysql directory owner, group, and add w permissions to the group chown -R mysql:mysql /usr/local/mysql chmod +w /usr/local/mysql #Initialize mysql table, test table, information table, etc. cd /usr/local/mysql scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data #Copy overwrite profile \cp -f my.cnf /etc/my.cnf #Edit configuration vim /etc/my.cnf #Find and modify basedir = /usr/local/mysql datadir = /usr/local/mysql/data socket = /tmp/mysql.sock port = 3306 server_id = 1 :wq Save exit #Copy the boot file to the boot directory and edit the boot file cp support-files/mysql.server /etc/init.d/mysqld vim /etc/init.d/mysqld #Find and modify basedir=/usr/local/mysql datadir=/usr/local/mysql/data :wq Save exit #Use the command to start the MySQL console to generate a soft connection and put it in the / usr/bin directory, so that we can start the MySQL console as long as we enter mysql ln -s /usr/local/mysql/bin/mysql /usr/bin #Start mysql service service mysqld start(It is said that redhat Only then)perhaps/etc/init.d/mysqld start
php configuration
cd /lamp/tar_gz/php-5.5.21/ cp php.ini-development /usr/local/php/etc/php.ini
last
/usr/local/apache2/bin/apachectl restart
Finally, in VIM / usr / local / apache2 / HtDocs / phpinfo PHP write <? php echo phpinfo(); ?> Save and browse.