centos安裝lamp

安裝編譯工具、庫文件:

#yum install make apr* autoconf automake gcc gcc-c++ zlib-devel openssl openssl-devel pcre-devel gd kernel keyutils patch perl kernel-headers compat* mpfr cpp glibc libgomp libstdc++-devel ppl cloog-ppl keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm* freetype libjpeg* libpng* php-common php-gd ncurses* libtool* libxml2 libxml2-devel patch

安裝libmcrypt
cd /usr/local/src
tar zxvf  libmcrypt-2.5.7.tar.gz  

cd  libmcrypt-2.5.7
./configure  

make   
make install  

安裝cmake 

 
cd /usr/local/src
tar zxvf cmake-2.8.7.tar.gz
cd cmake-2.8.7
./configure
gmake

make 
make install  

安裝

apr
cd /usr/local/src
tar zxvf  apr-1.4.6.tar.gz
cd apr-1.4.6
./configure --prefix=/usr/local/apr
make
make install

安裝

apr-util
tar zxvf apr-util-1.4.1.tar.gz
cd apr-util-1.4.1
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
make
make install

安裝
apache

cd  httpd-2.4.2

mkdir /usr/local/apache2

./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-ssl --enable-rewrite --enable-cgi --enable-so --with-libxml2

make

make install

/usr/local/apache2/bin/apachectl -k start

測試一下頁面如果有:it works出現則成功。

vim /usr/local/apache2/conf/httpd.conf  

找到:DirectoryIndex index.html
修改爲:
DirectoryIndex index.html index.php
找到:
Options Indexes FollowSymLinks
修改爲:
Options FollowSymLinks    #不顯示目錄結構
找到
AllowOverride None 
修改爲:
AllowOverride All   #開啓apache支持僞靜態,有兩處都做修改
LoadModule rewrite_module modules/mod_rewrite.so   #
取消前面的註釋,開啓apache支持僞靜態
vi /etc/profile  #
添加apache服務系統環境變量
在最後添加下面這一行

export PATH=$PATH:/usr/local/apache2/bin
cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd      #
apache加入到系統啓動
vi /etc/init.d/httpd  

#!/bin/sh下面添加以下兩行
#chkconfig:2345 10 90
#descrption:Activates/Deactivates Apache Web Server
chown  daemon.daemon  -R /usr/local/apache2/htdocs 

chmod   700 /usr/local/apache2/htdocs  -R

chkconfig httpd on   
/etc/init.d/httpd start
service httpd restart

安裝mysql

cd /usr/local/src/mysql-5.5.24

groupadd mysql
useradd -g mysql -s /bin/false mysql

mkdir /usr/local/mysql

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  -DSYSCONFDIR=/etc

make;make install
cd /usr/local/mysql

cp ./support-files/my-huge.cnf /etc/my.cnf

./scripts/mysql_install_db --user=mysql

cp ./support-files/mysql.server /etc/init.d/mysqld

chown mysql:mysql /etc/init.d/mysqld 
chkconfig mysqld on
 chmod 755 /etc/init.d/mysqld

vim /etc/init.d/mysqld

basedir = /usr/local/mysql   #MySQL程序安裝路徑
vim /etc/profile

export PATH=$PATH:/usr/local/mysql/bin

myslq的庫文件鏈接到系統默認的位置

ln -s /usr/local/mysql/include/mysql /usr/include/mysql

reboot

mysql_secure_installation    #設置Mysql密碼
 
根據提示按Y 回車輸入2次密碼
 
或者直接修改密碼/usr/local/mysql/bin/mysqladmin -u root -p password "123456" #修改密碼
  service mysqld restart  #
重啓

netstat -ntl

如有3306端口被監聽,成功啓動

PHP
安裝

tar -zvxf /root/lamp/php-5.3.10.tar.gz -C /usr/local/src/

cd php-5.3.10

mkdir /usr/local/php5

180  ./configure --prefix=/usr/local/php5 --with-config-file-path=/usr/local/php5/etc --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/tmp/mysql.sock --with-gd --with-iconv --with-freetype --with-jpeg --with-png --with-zlib --with-libxml --enable-xml --enable-discard-path --enable-magic-quotes --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-force-cgi-redirect --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --with-mime-magic --enable-suhosin --enable-session --with-mcrypt 

make ;make install

mkdir /usr/local/php5/etc

cp php.ini-production /usr/local/php5/etc/php.ini

rm /etc/php.ini

ln -s /usr/local/php5/etc/php.ini /etc/php.ini

vim /etc/php.ini

  找到:;open_basedir =
修改爲:
open_basedir = .:/tmp/   #防止php***跨站,重要!!
找到:
disable_functions =
修改爲:
disable_functions = passthru,exec,system,chroot,scandir,chgrp,chown,shell_exec,proc_open,proc_get_status,ini_alter,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,stream_socket_server,escapeshellcmd,dll,popen,disk_free_space,checkdnsrr,checkdnsrr,getservbyname,getservbyport,disk_total_space,posix_ctermid,posix_get_last_error,posix_getcwd, posix_getegid,posix_geteuid,posix_getgid, posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid, posix_getppid,posix_getpwnam,posix_getpwuid, posix_getrlimit, posix_getsid,posix_getuid,posix_isatty, posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid, posix_setpgid,posix_setsid,posix_setuid,posix_strerror,posix_times,posix_ttyname,posix_uname
#
列出PHP可以禁用的函數,如果某些程序需要用到這個函數,可以刪除,取消禁用。
找到:
;date.timezone =
修改爲:
date.timezone = PRC
找到:
expose_php = On
修改爲:
expose_php = OFF  #禁止顯示php版本的信息
找到:
display_errors = On
修改爲:
display_errors = OFF  #關閉錯誤提示
配置編輯apache配置文件
LoadModule php5_module        modules/libphp5.so這一行下面添加、
AddType application/x-httpd-php .php
apache支持php
vi /usr/local/apache2/conf/httpd.conf  #

來自:系統運維 www.osyunwei.com 溫馨提醒:qihang01原創內容版權所有,轉載請註明出處及原文鏈接

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章