Create a blog for mysql database, apacha server, and php Server
1. install mysql:
Prepare zip: mysql-5.5.33-linux2.6-x86_64.tar.gz
[Root @ www ~] # Groupadd-r mysql <====================== create a mysql Group, because mysql runs on mysql Users
[Root @ www ~] # Useradd-g mysql-r-s/sbin/nologin mysql <=========== create a mysql User
[Root @ www ~] # Id mysql <=============================================================confirm ready?
Uid = 496 (mysql) gid = 493 (mysql) groups = 493 (mysql)
[Root @ www ~] # Ls
Anaconda-ks.cfg install. log install. log. syslog mysql-5.5.33-linux2.6-x86_64.tar.gz
[Root @ www ~] # Tar xf mysql-5.5.33-linux2.6-x86_64.tar.gz-C/usr/local <====== unzip the compressed package
[Root @ www ~] # Cd/usr/local <======================== switch to this directory, view the generated file
[Root @ www local] # ls
Bin etc games include lib lib64 libexec mysql-5.5.33-linux2.6-x86_64 sbin share src
[Root @ www local] # ln-sv mysql-5.5.33-linux2.6-x86_64/mysql <======== create a link for the file, it is more convenient to use later
'Mysql'-> 'MySQL-5.5.33-linux2.6-x86_64 /'
[Root @ www local] # mkdir/data <======================== create a data directory, used to mount the following devices:
[Root @ www local] # fdisk/dev/sda <===========================create a partition
WARNING: DOS-compatible mode is deprecated. It's stronugly recommended
Switch off the mode (command 'C') and change display units
Sectors (command 'u ').
Command (m for help): n
Command action
E extended
P primary partition (1-4)
P
Partition number (1-4): 3
First cylinder (7859-15665, default 7859 ):
Using default value 7859
Last cylinder, + cylinders or + size {K, M, G} (7859-15665, default 15665): + 20G
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl () to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used
The next reboot or after you run partprobe (8) or kpartx (8)
Syncing disks.
[Root @ www local] # cat/proc/partitions <======= check the partition status. if the new partition is not displayed, restart it.
Major minor # blocks name
8, 0, 125829120, sda
8 1 204800 sda1
8 2 62914560 sda2
8 3 20979891 sda3 <========================= this is the new partition
253 0 20971520 dm-0
253 1 2097152 DM-1
253 2 10485760 DM-2
253 3 20971520 DM-3
[Root @ www local] # pvcreate/dev/sda3
Physical volume "/dev/sda3" successfully created
[Root @ www local] # vgcreate myvg/dev/sda3
Volume group "myvg" successfully created
[Root @ www local] # lvcreate-L 10G-n mydata myvg
Logical volume "mydata" created
[Root @ www local] # lvs <=================== view the new volume group information
Lv vg Attr LSize Pool Origin Data % Move Log Cpy % Sync Convert
Mydata myvg-wi-a ---- 10.00g
Root vg0-wi-ao --- 20.00g
Swap vg0-wi-ao --- 2.00g
Usr vg0-wi-ao --- 10.00g
Var vg0-wi-ao --- 20.00g
[Root @ www local] # mke2fs-t ext4/dev/myvg/mydata <=========== format the volume Group
[Root @ www local] # vim/etc/fstab <===================== start mounting
# Created by anaconda on Sat Mar 22 10:51:06 2014
#
# Accessible filesystems, by reference, are maintained under '/dev/disk'
# See man pages fstab (5), findfs (8), mount (8) and/or blkid (8) for more info
#
/Dev/mapper/vg0-root/ext4 ULTS 1 1
UUID = 21013d46-de12-479a-beed-1a04aa11033d/boot ext4 ULTS 1 2
/Dev/mapper/vg0-usr/usr ext4 defaults 1 2
/Dev/mapper/vg0-var/var ext4 defaults 1 2
/Dev/mapper/vg0-swap swap defaults 0 0
Tmpfs/dev/shm tmpfs defaults 0 0
Devpts/dev/pts devpts gid = 5, mode = 620 0 0
Sysfs/sys sysfs defaults 0 0
Proc/proc defaults 0 0
/Dev/myvg/mydata/data ext4 defaults 0 0 <= This is the volume Group to attach
~
[Root @ www local] # mount-a <=============== reload the volume Group and mount it
[Root @ www local] # mount <============================ check the mounted volume group information
/Dev/mapper/vg0-root on/type ext4 (rw)
Proc on/proc type proc (rw)
Sysfs on/sys type sysfs (rw)
Devpts on/dev/pts type devpts (rw, gid = 5, mode = 620)
Tmpfs on/dev/shm type tmpfs (rw)
/Dev/sda1 on/boot type ext4 (rw)
/Dev/mapper/vg0-usr on/usr type ext4 (rw)
/Dev/mapper/vg0-var on/var type ext4 (rw)
None on/proc/sys/fs/binfmt_misc type binfmt_misc (rw)
Sunrpc on/var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/Dev/mapper/myvg-mydata on/data type ext4 (rw) <========= here is the newly mounted volume group information
[Root @ www local] # cd/data
[Root @ www data] # mkdir mydata <========================== create a mydata Directory
[Root @ www data] # chown-R mysql. mysql mydata/<======= modify the owner group of the Directory
[Root @ www data] # ll <================================ = confirm the modified information
Total 20
Drwx ------ 2 root 16384 Mar 22 12:01 lost + found
Drwxr-xr-x 2 mysql 4096 Mar 22 mydata
[Root @ www data] # cd/usr/local/mysql
[Root @ www mysql] # chown-R root. mysql./* <============= modify the owner and Group of the mysql file
[Root @ www mysql] # ll <================================ = confirm that the change is successful
Total 200
Drwxr-xr-x 2 root mysql 4096 Mar 22 bin
-Rw-r -- 1 root mysql 17987 Jul 15 2013 COPYING
Drwxr-xr-x 3 root mysql 4096 Mar 22 data
Drwxr-xr-x 2 root mysql 4096 Mar 22 docs
Drwxr-xr-x 3 root mysql 4096 Mar 22 include
-Rw-r -- 1 root mysql 134493 Jul 15 2013 INSTALL-BINARY
Drwxr-xr-x 3 root mysql 4096 Mar 22 lib
Drwxr-xr-x 4 root mysql 4096 Mar 22 man
Drwxr-xr-x 10 root mysql 4096 Mar 22 mysql-test
-Rw-r -- 1 root mysql 2496 Jul 15 2013 README
Drwxr-xr-x 2 root mysql 4096 Mar 22 scripts
Drwxr-xr-x 27 root mysql 4096 Mar 22 share
Drwxr-xr-x 4 root mysql 4096 Mar 22 SQL-statements
Drwxr-xr-x 3 root mysql 4096 Mar 22 support-files
[Root @ www mysql] # scripts/mysql_install_db -- datadir =/data/mydata -- user = mysql <= install and initialize mysql, which is an important step before installation
Installing MySQL system tables...
OK
Filling help tables...
OK
[Root @ www mysql] # ls/data/mydata
Mysql performance_schema test
[Root @ www mysql] # cp support-files/mysql. server/etc/rc. d/init. d/mysqld <=== = provide service scripts
[Root @ www mysql] # chkconfig -- add mysqld <========================= automatic startup start this process
[Root @ www mysql] # chkconfig -- list mysqld
Mysqld 0: off1: off2: on3: on4: on5: on6: off
[Root @ www mysql] # cp support-files/my-large.cnf/etc/my. cnf <============ provides the configuration file. Note that the original file is overwritten.
Cp: overwrite '/etc/my. cnf '? Y
[Root @ www mysql] # vim/etc/my. cnf <=============== edit the configuration file
# The MySQL server
[Mysqld]
Port = 3306
Socket =/tmp/mysql. sock
Skip-external-locking
Key_buffer_size = 256 M
Max_allowed_packet = 1 M
Table_open_cache = 256
Sort_buffer_size = 1 M
Read_buffer_size = 1 M
Read_rnd_buffer_size = 4 M
Myisam_sort_buffer_size = 64 M
Thread_cache_size = 8
Query_cache_size = 16 M
# Try number of CPU's * 2 for thread_concurrency
Thread_concurrency 4 <================================================approximate about 40 rows, change it here
Datadir =/data/mydata <================================== = add this information, mysql Directory
[Root @ www mysql] # service mysqld start <======================== start verify that mysql can be started normally.
Starting MySQL... [OK]
[Root @ www mysql] # vim/etc/profile. d/mysql. sh <============== import the command file for mysql
Export PATH =/usr/local/mysql/bin: $ PATH
~
[Root @ www mysql] # cd
[Root @ www ~] #./Etc/profile. d/mysql. sh <==================== let the system execute the file just created
Now mysql may run. let's go to mysql and check out what else to set.
[Root @ www ~] # Mysql
Welcome to the MySQL monitor. Commands end with; or/g.
Your MySQL connection id is 1
Server version: 5.5.33-log MySQL Community Server (GPL)
Copyright (c) 2000,201 3, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
Affiliates. Other names may be trademarks of their respective
Owners.
Type 'help; 'or'/h' for help. type'/C' to clear the current input statement.
Mysql>
Mysql> use mysql <============================= create a user table
Database changed
Mysql> SELECT user, host, password from user; <========================
+ ------ + --------------- + ---------- +
| User | host | password |
+ ------ + --------------- + ---------- +
| Root | localhost |
| Root | www.jiayu.com |
| Root | 127.0.0.1 |
| Root |: 1 |
| Localhost |
| Www.jiayu.com |
+ ------ + --------------- + ---------- +
6 rows in set (0.01 sec)
Mysql> drop user ''@ 'www .jiayu.com '; <=======================================
Query OK, 0 rows affected (0.00 sec)
Mysql> drop user ''@ 'localhost '; <==========================================
Query OK, 0 rows affected (0.00 sec)
Mysql> UPDATE user SET password = PASSWORD ('Love') WHERE user = 'root'; <============ create a password
Query OK, 4 rows affected (0.02 sec)
Rows matched: 4 Changed: 4 Warnings: 0
Mysql> SELECT user, host, password from user; <==================================== check whether the password is generated
+ ------ + --------------- + --------------------------------------------- +
| User | host | password |
+ ------ + --------------- + --------------------------------------------- +
| Root | localhost | * 656B19382E8A16676406422882380722D756E17A |
| Root | www.jiayu.com | * 656B19382E8A16676406422882380722D756E17A |
| Root | 127.0.0.1 | * 656B19382E8A16676406422882380722D756E17A |
| Root |: 1 | * 656B19382E8A16676406422882380722D756E17A |
+ ------ + --------------- + --------------------------------------------- +
4 rows in set (0.00 sec)
Mysql> flush privileges; ======================================================== ====
Query OK, 0 rows affected (0.00 sec)
[Root @ www ~] # Mysql-uroot-hlocalhost-plove <========= after the password is created, you must enter mysql
Welcome to the MySQL monitor. Commands end with; or
[Root @ www ~] # Vim. my. cnf <============== if it is too difficult to enter the system above, create a hidden file and save the password to it.
[Mysql]
User = root
Host = localhost
Password = love
~
[Root @ www ~] # Mysql <=================================================== === No password is required if you enter mysql again.
Welcome to the MySQL monitor. Commands end with; or/g.
Your MySQL connection id is 3
[Root @ www ~] # Ln-sv/usr/local/mysql/include // usr/include/mysql <==================== export header files
'/Usr/include/mysql'->'/usr/local/mysql/include /'
[Root @ www ~] # Vim/etc/ld. so. conf. d/mysql. conf ======================================================== export outbound files
/Usr/local/mysql/lib
[Root @ www ~] # Ldconfig
[Root @ www ~] # Ldconfig-p | grep mysql
Libtcmalloc_minimal.so.0 (libc6, x86-64) =>/usr/local/mysql/lib/libtcmalloc_minimal.so.0
Libmysqlclient_r.so.16 (libc6, x86-64) =>/usr/lib64/mysql/libmysqlclient_r.so.16
Libmysqlclient. so.18 (libc6, x86-64) =>/usr/local/mysql/lib/libmysqlclient. so.18 <=== key to see this item
Libmysqlclient. so.16 (libc6, x86-64) =>/usr/lib64/mysql/libmysqlclient. so.16
Libmysqlclient. so (libc6, x86-64) =>/usr/local/mysql/lib/libmysqlclient. so
II. install httpd: httpd installation depends on apr and apr-util. Therefore, you must install these two files before installation.
Httpd-2.4.9.tar.bz2
Apr-1.5.0.tar.bz2
Apr-util-1.5.3.tar.bz2
[Root @ www ~] # Yum install pcre-devel-y
[Root @ www ~] # Tar xf apr-1.5.0.tar.bz2
[Root @ www ~] # Cd apr-1.5.0
[Root @ www apr-1.5.0] # ../configure -- prefix =/usr/local/apr
[Root @ www apr-1.5.0] # make & make install
[Root @ www ~] # Tar xf apr-util-1.5.3.tar.bz2
[Root @ www ~] # Cd apr-util-1.5.3
[Root @ www apr-util-1.5.3] #./configure -- prefix =/usr/local/apr-util -- with-apr =/usr/local/apr/
[Root @ www apr-1.5.0] # make & make install
[Root @ www httpd-2.4.9] #. /configure -- prefix =/usr/local/apache -- sysconfdir =/etc/httpd24 -- enable-so -- enable-ssl -- enable-cgi -- with-zlib -- with-pcre -- enable -rewrite -- with-apr =/usr/local/apr -- with-apr-util =/usr/local/apr-util/-- enable-modules = most -- enable-mpms- shared = all -- with-mpm = event
[Root @ www httpd-2.4.9] make & make install
-- Prefix =/usr/local/apache <=========== specify the installation path
-- Sysconfdir =/etc/httpd24 <============= storage location of the configuration file
-- Enable-so -- enable-ssl -- enable-cgi <=== enable so, ssl, cgi
-- Enable-rewrite <============================ enable the font setting function
-- With-apr =/usr/local/apr <============= where to find apr during installation
-- With-apr-util =/usr/local/apr-util/<= where to find apr-util during installation
-- Enable-mpms-shared = all <========= edit the mpms function
-- With-mpm = event <======================== specify the event mode for php
[Root @ www httpd-2.4.9] # cd/etc/rc. d/init. d
[Root @ www init. d] # cp httpd httpd24
[Root @ www init. d] # vim httpd24
# Path to the apachectl script, server binary, and short-form for messages.
Apachectl =/usr/local/apache/bin/apachectl <= around 40 rows. change the original path to this
Httpd =$ {HTTPD-/usr/local/apache/bin/httpd} <=== specify a new path
[Root @ www init. d] # chkconfig -- add httpd24
[Root @ www init. d] # chkconfig -- list httpd24
Httpd24 0: off1: off2: off3: off4: off5: off6: off
[Root @ www ~] # Vim/etc/profile. d/httpd. sh
Export PATH =/usr/local/apache/bin: $ PATH
[Root @ www ~] #./Etc/profile. d/httpd. sh
[Root @ www ~] # Vim/etc/httpd24/httpd. conf
# Do not add a slash at the end of the directory path. If you point
# ServerRoot at a non-local disk, be sure to specify a local disk on
# Mutex directive, if file-based mutexes are used. If you want to share
# Same ServerRoot for multiple httpd daemons, you will need to change
# Least PidFile.
#
ServerRoot "/usr/local/apache"
PidFile "var/run/httpd. conf" <= About 40 rows. add the pidFile
[Root @ www ~] # Service httpd24 start
Starting httpd: [OK]
Install the php Server
File to be prepared
Php-5.4.26.tar.bz2
Xcache-3.0.3.tar.bz2
PhpMyAdmin-4.0.5-all-languages.zip
[Root @ www ~] # Tar xf php-5.4.26.tar.bz2
[Root @ www ~] # Cd php-5.4.26
[Root @ www php-5.4.26] #./configure -- prefix =/usr/local/php
-- With-mysql =/usr/local/mysql -- with-openssl -- enable-fpm -- enable-sockets -- enable-sysvshm -- with-mysqli =/usr/local/mysql/bin /mysql_config -- enable-mbstring -- with-freetype-dir -- with-jpeg-dir -- with-png-dir -- with-zlib-dir -- with-libxml-dir =/usr -- enable-xml -- with-mhash -- with-mcrypt -- with-config-file-path =/etc -- with-config-file-scan-dir =/etc/php. d -- with-bz2 -- with-curl
[Root @ www php-5.4.26] # make & make install
[Root @ www php-5.4.26] # cp php. ini-production/etc/php. ini
Edit configuration file
[Root @ www php-5.4.26] # vim/etc/httpd24/httpd. conf
There are two rows below AddType at about 382 rows
AddType application/x-httpd-php. php
AddType application/x-httpd-php-source. phps
Change the value to the following at around 252 rows:
DirectoryIndex index. php index.html
Root @ www ~] # Service httpd24 reload
Reloading httpd:
[Root @ www ~] # Ss-tnlp
The following shows how php works.
[Root @ www ~] # Cd/usr/local/apache
[Root @ www apache] # ls
Bin build cgi-bin error htdocs icons include logs man manual modules
[Root @ www apache] # cd htdocs
[Root @ www htdocs] # ls
Index.html
[Root @ www htdocs] # mv index.html index. php
[Root @ www htdocs] # ls
Index. php
[Root @ www htdocs] # vim index. php
Phpinfo ();
?>
~ Open your server address in the browser to see if it is running properly.
This article is from the "linux" blog, please be sure to keep this source http://8519539.blog.51cto.com/8509539/1386687