2015-12-16 LAMP第一部分--环境搭建

环境:centos 6.7; 32位系统
第1: 安装mysql
[root@niejicai-linux src]tar zxvf mysql-5.1.34-linux-i686-icc-glibc23.tar.gz
[ root@niejicai-linux src]# ls
mysql-5.1.34-linux-i686-icc-glibc23  mysql-5.1.34-linux-i686-icc-glibc23.tar.gz
[ root@niejicai-linux  src]# mv mysql-5.1.34-linux-i686-icc-glibc23 /usr/local/mysql
[root@niejicai-linux src]# useradd -s /sbin/nologin mysql
[root@niejicai-linux src]# cd /usr/local/mysql/
[root@niejicai-linux mysql]# mkdir -p /data/mysql
[root@niejicai-linux mysql]# chown -R mysql:mysql /data/mysql/
[ root@niejicai-linux mysql]# ls
bin      docs               INSTALL-BINARY  mysql-test  share
COPYING  EXCEPTIONS-CLIENT  lib             README      sql-bench
data     include            man             scripts     support-files
[ root@niejicai-linux mysql]#
[root@niejicai-linux mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/
Installing MySQL system tables...
151214 11:12:39 [Warning] Forcing shutdown of 2 plugins
OK
Filling help tables...
151214 11:12:39 [Warning] Forcing shutdown of 2 plugins
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

./bin/mysqladmin -u root password 'new-password'
./bin/mysqladmin -u root -h niejicai-linux password 'new-password'

Alternatively you can run:
./bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd . ; ./bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd ./mysql-test ; perl mysql-test-run.pl

Please report any problems with the ./bin/mysqlbug script!

The latest information about MySQL is available at  http://www.mysql.com/
Support MySQL by buying support/licenses from  http://shop.mysql.com/

[ root@niejicai-linux mysql]#
[root@niejicai-linux mysql]# ls /data/mysql/
mysql  test
[ root@niejicai-linux mysql]#

[root@niejicai-linux mysql]# cd support-files/
[ root@niejicai-linux support-files]# ls
binary-configure   my-huge.cnf             mysqld_multi.server
config.huge.ini    my-innodb-heavy-4G.cnf  mysql-log-rotate
config.medium.ini  my-large.cnf            mysql.server
config.small.ini   my-medium.cnf           ndb-config-2-node.ini
magic              my-small.cnf
[root@niejicai-linux support-files]# cp my-medium.cnf /etc/my.cnf
cp: overwrite `/etc/my.cnf'?  y
[ root@niejicai-linux support-files]# vim /etc/my.cnf
 log-bin=mysql-bin
 binlog_format=mixed
 server-id       = 1
把这个三个配置文件注释掉
[root@niejicai-linux support-files]# cp mysql.server /etc/init.d/mysqld
[root@niejicai-linux support-files]# vim /etc/init.d/mysqld
41 # in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.
 42
 43 # If you change base dir, you must also change datadir. These may get
 44 # overwritten by settings in the MySQL configuration files.
 45
 46 basedir=/usr/local/mysql
 47 datadir=/data/mysql
 48
 49 # Default value, in seconds, afterwhich the script should timeout waiting
 50 # for server start.

[root@niejicai-linux support-files]# chkconfig --add mysqld  加入到系统的服务列表里面去。
[ root@niejicai-linux support-files]# chkconfig mysqld on  设置开机启动
[root@niejicai-linux support-files]# /etc/init.d/mysqld start  (手动启动)
Starting MySQL......                                        [  OK  ]
[ root@niejicai-linux support-files]#

[root@niejicai-linux ~]# ps aux | grep mysql      看是否有进程!
root      4950  0.0  1.0   5068  1260 pts/0    S    10:16   0:00 /bin/sh /usr/lo            cal/mysql/bin/mysqld_safe --datadir=/data/mysql --pid-file=/data/mysql/niejicai-           linux.pid
mysql     5056  4.3 12.9 119052 15192 pts/0    Sl   10:16   0:05 /usr/local/mysq           l/bin/mysqld --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql --log           -error=/data/mysql/niejicai-linux.err --pid-file=/data/mysql/niejicai-linux.pid            --socket=/tmp/mysql.sock --port=3306
root      5083  0.0  0.6   4420   756 pts/1    S+   10:18   0:00 grep --color my           sql
[root@niejicai-linux ~]# netstat -lnp     查看端口是否开启(3306)!
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      5056/mysqld
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      2138/sshd
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      1988/cupsd
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      2315/master
tcp        0      0 :::22                       :::*                        LISTEN      2138/sshd
tcp        0      0 ::1:631                     :::*                        LISTEN      1988/cupsd
tcp        0      0 ::1:25                      :::*                        LISTEN      2315/master
udp        0      0 0.0.0.0:631                 0.0.0.0:*                               1988/cupsd
Active UNIX domain sockets (only servers)
Proto RefCnt Flags       Type       State         I-Node PID/Program name    Path
。。。。。
unix  2      [ ACC ]     STREAM     LISTENING     10561  2023/acpid          /var/run/acpid.socket
unix  2      [ ACC ]     STREAM     LISTENING     10599  2035/hald           @/var/run/hald/dbus-kEGLNIZI88
-----------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------

第2. 安装apache
[root@niejicai-linux src] tar jvxf httpd-2.2.27.tar.bz2
[ root@niejicai-linux src]# ls
httpd-2.2.27  httpd-2.2.27.tar.bz2 
[root@niejicai-linux src]# cd httpd-2.2.27
[root@niejicai-linux httpd-2.2.27]# ./configure --prefix=/usr/local/apache2  --enable-mods-shared=most  --enable-so 
[root@niejicai-linux httpd-2.2.27]#make && make install 
[ root@niejicai-linux src]#  echo $?     如果这里输出是零的话,就没有问题了!
0
[root@niejicai-linux ~]# cd /usr/local/apache2/
[ root@niejicai-linux apache2]# ls
bin    cgi-bin  error   icons    lib   man     modules
build  conf     htdocs  include  logs  manual
[ root@niejicai-linux apache2]#
[root@niejicai-linux apache2]# ls modules/      动态加载模块!
httpd.exp               mod_authz_user.so  mod_info.so
mod_actions.so          mod_autoindex.so   mod_log_config.so
mod_alias.so            mod_cgi.so         mod_logio.so
mod_asis.so             mod_dav_fs.so      mod_mime.so
mod_auth_basic.so       mod_dav.so         mod_negotiation.so
mod_auth_digest.so      mod_dbd.so         mod_reqtimeout.so
mod_authn_anon.so       mod_dir.so         mod_rewrite.so
mod_authn_dbd.so        mod_dumpio.so      mod_setenvif.so
mod_authn_dbm.so        mod_env.so         mod_speling.so
mod_authn_default.so    mod_expires.so     mod_status.so
mod_authn_file.so       mod_ext_filter.so  mod_substitute.so
mod_authz_dbm.so        mod_filter.so      mod_userdir.so
mod_authz_default.so    mod_headers.so     mod_version.so
mod_authz_groupfile.so  mod_ident.so       mod_vhost_alias.so
mod_authz_host.so       mod_imagemap.so
mod_authz_owner.so      mod_include.so
[ root@niejicai-linux apache2]#
[root@niejicai-linux apache2]# /usr/local/apache2/bin/httpd -t      检测配置文件是否有问题
httpd: Could not reliably determine the server's fully qualified domain name, using 218.204.57.254 for ServerName
Syntax OK
[root@niejicai-linux apache2]# /usr/local/apache2/bin/httpd -l
Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c
[root@niejicai-linux apache2]# /usr/local/apache2/bin/httpd -M
httpd: Could not reliably determine the server's fully qualified domain name, using 218.204.57.254 for ServerName
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
 authn_file_module (shared)
 authn_dbm_module (shared)
。。。。。。。。。
[root@niejicai-linux apache2]# cat /usr/local/apache2/build/config.nice
#! /bin/sh      一个Apache很老了,可以这样查看编译选项!
#
# Created by configure

"./configure" \
"--prefix=/usr/local/apache2" \
"--enable-mods-shared=most" \
"--enable-so" \
"$@"
[ root@niejicai-linux apache2]#
启动:
[root@niejicai-linux apache2]# /usr/local/apache2/bin/apachectl start
httpd: Could not reliably determine the server's fully qualified domain name, using 218.204.57.254 for ServerName
httpd (pid 2687) already running
[root@niejicai-linux apache2]# echo $?
0
[ root@niejicai-linux apache2]#
[root@niejicai-linux apache2]# ps aux |grep httpd
root      2687  0.0  1.8   4692  2124 ?        Ss   11:53   0:00 /usr/local/apache2/bin/httpd
daemon    2688  0.0  1.1   4828  1368 ?        S    11:53   0:00 /usr/local/apache2/bin/httpd
daemon    2689  0.0  1.1   4828  1368 ?        S    11:53   0:00 /usr/local/apache2/bin/httpd
daemon    2690  0.0  1.1   4828  1368 ?        S    11:53   0:00 /usr/local/apache2/bin/httpd
daemon    2691  0.0  1.1   4828  1368 ?        S    11:53   0:00 /usr/local/apache2/bin/httpd
daemon    2692  0.0  1.1   4828  1368 ?        S    11:53   0:00 /usr/local/apache2/bin/httpd
root      2719  0.0  0.7   4424   828 pts/1    S+   12:04   0:00 grep --color httpd
[ root@niejicai-linux apache2]#
[root@niejicai-linux apache2]# netstat -lnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      5056/mysqld    
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      2138/sshd      
tcp        0      0 127.0.0.1:631               0.0.0.0:*                   LISTEN      1988/cupsd     
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      2315/master    
tcp        0      0 :::80                       :::*                        LISTEN      2687/httpd     
tcp        0      0 :::22                       :::*                        LISTEN      2138/sshd      
tcp        0      0 ::1:631                     :::*                        LISTEN      1988/cupsd     
tcp        0      0 ::1:25                      :::*                        LISTEN      2315/master    
udp        0      0 0.0.0.0:631                 0.0.0.0:*                               1988/cupsd     

[ root@niejicai-linux apache2]#  /usr/local/apache2/bin/httpd -t
httpd: Could not reliably determine the server's fully qualified domain name, using 218.204.57.254 for ServerName
Syntax OK                                                                                                      把这行去掉!只需要更改如下的配置
[ root@niejicai-linux apache2]# vim conf/httpd.conf
 # This can often be determined automatically, but we recommend you specify
 # it explicitly to prevent problems during startup.
 # If your host doesn't have a registered DNS name, enter its IP address here.
ServerName www.example.com
 # DocumentRoot: The directory out of which you will serve your
[root@niejicai-linux apache2]# ./bin/apachectl -t      检测(-t=test测试)
Syntax OK
[root@niejicai-linux apache2]# ./bin/httpd -t
Syntax OK

[root@niejicai-linux apache2]# /usr/local/apache2/bin/apachectl  graceful (不杀死进程的情况下,过度重启)
测试成功:
在Windows上


在Linux服务器上测试
[root@niejicai-linux apache2]# curl localhost
<html><body><h1 >It works!</h1></body></html>[ root@niejicai-linux apache2]#
[root@niejicai-linux apache2]# curl localhost -I
HTTP/1.1 200 OK
Date: Tue, 15 Dec 2015 04:24:50 GMT
Server: Apache/2.2.27 (Unix) DAV/2
Last-Modified: Sat, 20 Nov 2004 20:16:24 GMT
ETag: "e3a12-2c-3e9564c23b600"
Accept-Ranges: bytes
Content-Length: 44
Content-Type: text/html
[ root@niejicai-linux apache2]#
-----------------------------------------------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------------------------------------------------
第3: 安装php
[ root@niejicai-linux src]# ls
httpd-2.2.27          mysql-5.1.34-linux-i686-icc-glibc23.tar.gz
httpd-2.2.27.tar.bz2   php-5.3.28.tar.gz
[root@niejicai-linux src]#tar zxf php-5.3.28.tar.gz 
[ root@niejicai-linux src]# ls
httpd-2.2.27                                 php-5.3.28
httpd-2.2.27.tar.bz2                        php-5.3.28.tar.gz
mysql-5.1.34-linux-i686-icc-glibc23.tar.gz
[root@niejicai-linux src]# cd php-5.3.28
[root@niejicai-linux php-5.3.28]#
[root@niejicai-linux php-5.3.28]# ./configure   --prefix=/usr/local/php   --with-apxs2=/usr/local/apache2/bin/apxs   --with-config-file-path=/usr/local/php/etc   --with-mysql=/usr/local/mysql   --with-libxml-dir   --with-gd   --with-jpeg-dir   --with-png-dir   --with-freetype-dir   --with-iconv-dir   --with-zlib-dir   --with-bz2   --with-openssl   --with-mcrypt   --enable-soap   --enable-gd-native-ttf   --enable-mbstring   --enable-sockets   --enable-exif   --disable-ipv6

Configuring extensions
checking size of long... (cached) 4
checking size of int... (cached) 4
checking for int32_t... yes
checking for uint32_t... yes
checking for sys/types.h... (cached) yes
checking for inttypes.h... (cached) yes
checking for stdint.h... (cached) yes
checking for string.h... (cached) yes
checking for stdlib.h... (cached) yes
checking for strtoll... yes
checking for atoll... yes
checking for strftime... (cached) yes
checking which regex library to use... php
checking whether to enable LIBXML support... yes
checking libxml2 install dir... yes
checking for xml2-config path...
configure: error: xml2-config not found. Please check your libxml2 insta llation.  这里有问题了,需要去排查!!!
[ root@niejicai-linux php-5.3.28]#
排查如下:
[root@niejicai-linux ~]# rpm -qa | grep libxml2
[root@niejicai-linux ~]# yum install -y libxml2
[root@niejicai-linux ~]# yum install -y  libxml2-devel 

然后继续编译:
[root@niejicai-linux php-5.3.28]# ./configure   --prefix=/usr/local/php   --with-apxs2=/usr/local/apache2/bin/apxs   --with-config-file-path=/usr/local/php/etc   --with-mysql=/usr/local/mysql   --with-libxml-dir   --with-gd   --with-jpeg-dir   --with-png-dir   --with-freetype-dir   --with-iconv-dir   --with-zlib-dir   --with-bz2   --with-openssl   --with-mcrypt   --enable-soap   --enable-gd-native-ttf   --enable-mbstring   --enable-sockets   --enable-exif   --disable-ipv6

checking for xml2-config path... /usr/bin/xml2-config
checking whether libxml build works... yes
checking for OpenSSL support... yes
checking for Kerberos support... no
checking for DSA_get_default_method in -lssl... no
checking for X509_free in -lcrypto... no
checking for pkg-config... /usr/bin/pkg-config
configure: error: Cannot find OpenSSL's <evp.h>    又出问题了继续排查!!!
[ root@niejicai-linux php-5.3.28]#
解决:
[ root@niejicai-linux  php-5.3.28]#yum install openssl 
[ root@niejicai-linux  php-5.3.28]#yum install openssl-devel

继续编译
[root@niejicai-linux php-5.3.28]# ./configure   --prefix=/usr/local/php   --with-apxs2=/usr/local/apache2/bin/apxs   --with-config-file-path=/usr/local/php/etc   --with-mysql=/usr/local/mysql   --with-libxml-dir   --with-gd   --with-jpeg-dir   --with-png-dir   --with-freetype-dir   --with-iconv-dir   --with-zlib-dir   --with-bz2   --with-openssl   --with-mcrypt   --enable-soap   --enable-gd-native-ttf   --enable-mbstring   --enable-sockets   --enable-exif   --disable-ipv6

checking if the location of ZLIB install directory is defined... yes
checking for gzgets in -lz... yes
checking whether to enable bc style precision math functions... no
checking for BZip2 support... yes
checking for BZip2 in default path... not found
configure: error: Please reinstall the BZip2 distribution     有出问题继续排查!!!!
[ root@niejicai-linux php-5.3.28]#
解决方法:
[root@niejicai-linux php-5.3.28]# yum install bzip2 bzip2-devel

继续编译
[root@niejicai-linux php-5.3.28]# ./configure   --prefix=/usr/local/php   --with-apxs2=/usr/local/apache2/bin/apxs   --with-config-file-path=/usr/local/php/etc   --with-mysql=/usr/local/mysql   --with-libxml-dir   --with-gd   --with-jpeg-dir   --with-png-dir   --with-freetype-dir   --with-iconv-dir   --with-zlib-dir   --with-bz2   --with-openssl   --with-mcrypt   --enable-soap   --enable-gd-native-ttf   --enable-mbstring   --enable-sockets   --enable-exif   --disable-ipv6

checking for T1lib support... no
checking whether to enable truetype string function in GD... yes
checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... yes
checking for floorf... yes
configure: error: jpeglib.h not found.       又出现问题了!!!!
[ root@niejicai-linux php-5.3.28]#
解决方法:
[root@niejicai-linux php-5.3.28]# yum install libjpeg libjpeg-devel

继续编译
[root@niejicai-linux php-5.3.28]# ./configure   --prefix=/usr/local/php   --with-apxs2=/usr/local/apache2/bin/apxs   --with-config-file-path=/usr/local/php/etc   --with-mysql=/usr/local/mysql   --with-libxml-dir   --with-gd   --with-jpeg-dir   --with-png-dir   --with-freetype-dir   --with-iconv-dir   --with-zlib-dir   --with-bz2   --with-openssl   --with-mcrypt   --enable-soap   --enable-gd-native-ttf   --enable-mbstring   --enable-sockets   --enable-exif   --disable-ipv6

checking for T1lib support... no
checking whether to enable truetype string function in GD... yes
checking whether to enable JIS-mapped Japanese font support in GD... no
checking for fabsf... yes
checking for floorf... yes
checking for jpeg_read_header in -ljpeg... yes
configure: error: png.h not found.              又出问题了,继续排查!!!
[ root@niejicai-linux php-5.3.28]#
解决方法:
[root@niejicai-linux php-5.3.28]# yum install libpng libpng-devel

继续编译
[root@niejicai-linux php-5.3.28]# ./configure   --prefix=/usr/local/php   --with-apxs2=/usr/local/apache2/bin/apxs   --with-config-file-path=/usr/local/php/etc   --with-mysql=/usr/local/mysql   --with-libxml-dir   --with-gd   --with-jpeg-dir   --with-png-dir   --with-freetype-dir   --with-iconv-dir   --with-zlib-dir   --with-bz2   --with-openssl   --with-mcrypt   --enable-soap   --enable-gd-native-ttf   --enable-mbstring   --enable-sockets   --enable-exif   --disable-ipv6

checking for fabsf... yes
checking for floorf... yes
checking for jpeg_read_header in -ljpeg... yes
checking for png_write_image in -lpng... yes
If configure fails try --with-xpm-dir=<DIR>
configure: error: freetype.h not found.                   又出现问题了!!!
[ root@niejicai-linux php-5.3.28]#
解决方法:
[root@niejicai-linux php-5.3.28]#yum install freetype-devel


继续编译
[root@niejicai-linux php-5.3.28]# ./configure   --prefix=/usr/local/php   --with-apxs2=/usr/local/apache2/bin/apxs   --with-config-file-path=/usr/local/php/etc   --with-mysql=/usr/local/mysql   --with-libxml-dir   --with-gd   --with-jpeg-dir   --with-png-dir   --with-freetype-dir   --with-iconv-dir   --with-zlib-dir   --with-bz2   --with-openssl   --with-mcrypt   --enable-soap   --enable-gd-native-ttf   --enable-mbstring   --enable-sockets   --enable-exif   --disable-ipv6


checking whether time.h and sys/time.h may both be included... yes
checking for working alloca.h... (cached) yes
checking for alloca... (cached) yes
checking for 8-bit clean memcmp... yes
checking for stdarg.h... (cached) yes
checking for mcrypt support... yes
configure: error: mcrypt.h not found. Please reinstall libmcrypt.     又出问题了!!!!
[ root@niejicai-linux php-5.3.28]#
解决方法:
[ root@niejicai-linux php-5.3.28]# yum install libmcrypt libmcrypt-devel

继续编译
[root@niejicai-linux php-5.3.28]# ./configure   --prefix=/usr/local/php   --with-apxs2=/usr/local/apache2/bin/apxs   --with-config-file-path=/usr/local/php/etc   --with-mysql=/usr/local/mysql   --with-libxml-dir   --with-gd   --with-jpeg-dir   --with-png-dir   --with-freetype-dir   --with-iconv-dir   --with-zlib-dir   --with-bz2   --with-openssl   --with-mcrypt   --enable-soap   --enable-gd-native-ttf   --enable-mbstring   --enable-sockets   --enable-exif   --disable-ipv6

如下已经安装成功!!

[root@niejicai-linux php-5.3.28]#make 



[root@niejicai-linux php-5.3.28]#make install

安装完成!!!!!!!@@

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

测试:::(
 /usr/local/apache2/conf/httpd.conf
为Apache 的配置文件!)
[root@niejicai-linux ~]# /usr/local/php/bin/php   
php的可执行文件在这个目录下!
[ root@niejicai-linux ~]#  vim 1.php              我们来写一个PHP,待下面进行测试!
[ root@niejicai-linux ~]# cat 1.php
<?php
echo "configuration";
echo "\n"
?>
[root@niejicai-linux ~]# /usr/local/php/bin/php 1.php   去执行一下看看,写的脚本是否有问题
configuration              没有问题


看看php加载了那些模块
[root@niejicai-linux ~]# /usr/local/php/bin/php -m    列出来加载的模块!

[root@niejicai-linux ~]# /usr/local/php/bin/php -i  查看php加载模块的参数!!

下面看一下Apache怎么去调用PHP

[root@niejicai-linux ~]# ls /usr/local/apache2/modules/libphp5.so
/usr/local/apache2/modules/libphp5.so
[root@niejicai-linux ~]# cp /usr/local/src/php-5.3.28/php.ini-development /usr/local/php/etc/php.ini
                                                                                                         这里是测试用的,就用development
                                                                                                         线上生成环境的话,就用production


[root@niejicai-linux ~]# /usr/local/php/bin/php -i |grep -i configuration
Configuration File (php.ini) Path => /usr/local/php/etc
Loaded Configuration File => /usr/local/php/etc/php.ini
Configuration
PHP Warning:  Unknown: It is not safe to rely on the system's timezone settings. You are     *required* to use the date.timezone setting or the date_default_timezone_set() function.     In case you used any of those methods and you are still getting this warning, you most li    kely misspelled the timezone identifier. We selected 'Asia/Chongqing' for 'CST/8.0/no DST    ' instead in Unknown on line 0

[root@niejicai-linux ~]#cat /usr/local/apache2/conf/httpd.conf  查看一下配置文件,是否自动加载

  LoadModule php5_module        modules/libphp5.so
已经自动加载!
也可以通过命令来检测一下
[root@niejicai-linux ~]# /usr/local/apache2/bin/apachectl -M
 php5_module (shared)  已经加载进来!!!

当然,现在还没有完全的解释你的php,还需要继续配置!

vim /usr/local/apache2/conf/httpd.conf找到:
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>
改为:
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Allow from all
</Directory>



找到:
AddType application/x-gzip .gz .tgz
在该行下面添加:

AddType application/x-httpd-php  .php (注意看格式,第一次操作的时候,就出现了问题!
找到:
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>
将该行改为:
<IfModule dir_module>
    DirectoryIndex index.html index.htm index.php
</IfModule>
找到:
#ServerName  www.example.com:80
修改为:
ServerName localhost:80
改完以上的配置,下面去验证一下,配置是否更改正确
[ root@niejicai-linux ~]# vim /usr/local/apache2/conf/httpd.conf
[ root@niejicai-linux ~]#  /usr/local/apache2/bin/apachectl -t
Syntax OK

[root@niejicai-linux ~]# /usr/local/apache2/bin/apachectl restart     更改配置文件之后需要重启!
[root@niejicai-linux ~]# mv 1.php /usr/local/apache2/htdocs/   这个是存放网站的目录下!!!!!,所以要把php放在这里了来!
[ root@niejicai-linux ~]#  curl localhost/1.php     测试是否解析成功!!!
<?php
echo "configuration";         如果是这样情况是否解析不成功的!!!
echo "\n"
?>
现在我们要进行一一排查!!
第一:
[root@niejicai-linux ~]# /usr/local/apache2/bin/apachectl -M |grep -i php
Syntax OK
 php5_module (shared)

第二:
[root@niejicai-linux ~]# vim /usr/local/apache2/conf/httpd.conf
 AddType application/x-httpd-php .php      看看是否有这个

<IfModule dir_module>
     DirectoryIndex index.html   index.php             看看是否添加了这个选项!
</IfModule>

第三:
[root@niejicai-linux ~]# getenforce
Disabled
[root@niejicai-linux ~]# iptables -nvL
Chain INPUT (policy ACCEPT 868 packets, 82081 bytes)
 pkts bytes target     prot opt in     out     source               destinati                          on

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destinati                          on

Chain OUTPUT (policy ACCEPT 686 packets, 125K bytes)
 pkts bytes target     prot opt in     out     source               destinati                          on
[ root@niejicai-linux ~]#  iptables -F
第四:
[root@niejicai-linux ~]# /usr/local/apache2/bin/apachectl -t
Syntax OK
[root@niejicai-linux ~]# /usr/local/apache2/bin/apachectl restart

最后我们在来测试一下,看看是否可以解析出来, 测试方式:
第一种:
[root@niejicai-linux ~]# curl localhost/1.php         按照这种情况,说明是可以解析出来了!!!!!
configuration
第二种:
<html><body><h1>It works!</h1></body></html>
configuration
第三种:
configuration
第四种:






-------------------------------------------------------------------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------------------------------------------------------------

另外,还可以换一下PHP
[ root@niejicai-linux ~]#  vim /usr/local/apache2/htdocs/niejicai.php
[root@niejicai-linux ~]# cat /usr/local/apache2/htdocs/niejicai.php
<?php
phpinfo();
?>
测试如下:








































  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值