免费网站在线观看人数在哪,怎么做公众号网站,互联网广告投放代理公司,采购软件LAMP的安装 LAMP需要什么软件呢#xff1f;这里我们必须知道php是挂在Apache 下工作的#xff0c;而我们要用网页的php程序来控制mysql#xff0c;所以LAMP需要的软件 最基本的有httpd、mysql、mysql-Server、php、php-devel。 下载地址对应是#xff1a; http://www.apach… LAMP的安装 LAMP需要什么软件呢这里我们必须知道php是挂在Apache 下工作的而我们要用网页的php程序来控制mysql所以LAMP需要的软件 最基本的有httpd、mysql、mysql-Server、php、php-devel。 下载地址对应是 http://www.apache.org http://www.mysql.com http://www.php.net 一、编译安装apache 1、安装apache要先解决依赖关系又因为httpd受selinux的影响所以安装之前先确保selinux 没有开启或没生效的状态 # getenforce 查看selinux处于什么状态selinux有三种状态 1、disable 没有开启 2、enforcing 开启3、permissive 开启但不强制生效 若处于disable和permissive状态就不予处理了若是enforcing状态就用命令 # setenforce 0 关闭selinux 如果想让selinux永久的处于0状态就需要编辑其配置文件 /etc/selinux/config 或 /etc/sysconfig/selinux二者是同一个文件只不过是连接关系 打开# vim /etc/selinux/config 把SELINUXenforcing 改为SELINUXPermissive即可。 2、下载httpd-2.4.1当然可以以自身而定这里用httpd-2.4.1 httpd还依赖pcre-devel软件包 要事先下载并安装好不然下面httpd的编译可能会有错误。 3、编译安装httpd-4.2.1 # tar xf httpd-2.4.1.tar.bz2 # cd httpd-2.4.1 # ./configure --prefix/usr/local/apache \ --sysconfdir/etc/httpd --enable-so \ --enable-ssl --enable-cgi --enable-rewrite \ --with-zlib # make # make install 4、修改httpd的主配置文件定义httpd的Pid文件的路径 # vim /etc/httpd/httpd.conf找到ServerRoot /usr/local/apache在它下面添加如下行即可 PidFile /var/run/httpd.pid 5、在/etc/rc.d/init.d/目录下提供httpd的sysv脚本 # vim /etc/rc.d/init.d/httpd 新建文件内容如下 #!/bin/bash # # httpd Startup script for the Apache HTTP Server # # chkconfig: - 85 15 # description: Apache is a World Wide Web server. It is used to serve \ # HTML files and CGI. # processname: httpd # config: /etc/httpd/conf/httpd.conf # config: /etc/sysconfig/httpd # pidfile: /var/run/httpd.pid # Source function library. . /etc/rc.d/init.d/functions if [ -f /etc/sysconfig/httpd ]; then . /etc/sysconfig/httpd fi # Start httpd in the C locale by default. HTTPD_LANG${HTTPD_LANG-C} # This will prevent initlog from swallowing up a pass-phrase prompt if # mod_ssl needs a pass-phrase from the user. INITLOG_ARGS # Set HTTPD/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server # with the thread-based worker MPM; BE WARNED that some modules may not # work correctly with a thread-based MPM; notably PHP will refuse to start. # Path to the apachectl script, server binary, and short-form for messages. apachectl/usr/local/apache/bin/apachectl httpd${HTTPD-/usr/local/apache/bin/httpd} proghttpd pidfile${PIDFILE-/var/run/httpd.pid} lockfile${LOCKFILE-/var/lock/subsys/httpd} RETVAL0 start() { echo -n $Starting $prog: LANG$HTTPD_LANG daemon --pidfile${pidfile} $httpd $OPTIONS RETVAL$? echo [ $RETVAL 0 ] touch ${lockfile} return $RETVAL } stop() { echo -n $Stopping $prog: killproc -p ${pidfile} -d 10 $httpd RETVAL$? echo [ $RETVAL 0 ] rm -f ${lockfile} ${pidfile} } reload() { echo -n $Reloading $prog: if ! LANG$HTTPD_LANG $httpd $OPTIONS -t /dev/null; then RETVAL$? echo $not reloading due to configuration syntax error failure $not reloading $httpd due to configuration syntax error else killproc -p ${pidfile} $httpd -HUP RETVAL$? fi echo } # See how we were called. case $1 in start) start ;; stop) stop ;; status) status -p ${pidfile} $httpd RETVAL$? ;; restart) stop start ;; condrestart) if [ -f ${pidfile} ] ; then stop start fi ;; reload) reload ;; graceful|help|configtest|fullstatus) $apachectl $ RETVAL$? ;; *) echo $Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest} exit 1 esac exit $RETVAL 6、脚本创建好了要有执行权限 # chmod x /etc/rc.d/init.d/httpd 7、加入服务列表 # chkconfig --add httpd 添加到服务列表 # chkconfig httpd on 开机自动启用 8、启动 # service httpd start 启动时可能会报一个错误这个错误的原因是web服务器在启动的时候 会试图解析本地主机名还会试图反向解析本地ip地址如果正向反向都无法解析 就会报错这个错误不影响结果查看一下端口80是否开启 # netstat -tnlp 查看端口若有80就可以打开浏览器输入主机ip 比如我的主机ip是172.16.30.8就可以输入172.16.30.8这时会出现一个redhat 自带的欢迎页面这个页面默认情况下在/var/www/html下 如果我们不想用自带的页面可以自己写一个比如 # cd /var/www/html # vim index.html 内容如下一行 Welcome to httpd 保存退出 再在浏览器上输入主机ip注意页面的更新不需要重启服务但是更改配置文件需要重启服务 # service httpd restart 或重新载入# service httpd reload 二、安装mysql-5.5.20 1、下载mysql这里用mysql-5.5.20的版本 2、准备数据存放的文件系统 先划分一个逻辑分区这里的逻辑分区为/dev/sda5 # partprobe /dev/sda5 # pvcreate /dev/sda5 # vgcreate myvg /dev/sda5 # lvcreate -L 2G -n mysql myvg 注-L 指定逻辑卷大小 -n逻辑卷卷名 # mke2fs -j /dev/myvg/mysql # mkdir -pv /mydata/data # mount /dev/myvg/mysql /mydata # vim /etc/fstab 在下面添加如下一行 /dev/myvg/mysql /mydata ext3 defaults 0 0 3、新建用户以安全方式运行进程 # groupadd -r mysql # useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql # chown -R mysql:mysql /mydata/data 4、安装并初始化mysql-5.5.20 # tar xf mysql-5.5.19-linux2.6-i686.tar.gz -C /usr/local # cd /usr/local/ # ln -sv mysql-5.5.19-linux2.6-i686 mysql # cd mysql # chown -R mysql:mysql . # scripts/mysql_install_db --usermysql --datadir/mydata/data --user指定用户是mysql --datadir指定数据存放目录为/mydata/data # chown -R root . 将当前文件的属主改为root # chown -R mysql data 因为data是数据的默认存放目录为了安全将属主改为mysql 5、为mysql提供主配置文件 # cd /usr/local/mysql # cp support-files/my-large.cnf /etc/my.cnf # vim /etc/my.cnf 打开配置文件将thread_concurrency的值 改为CPU个数乘以2的值 如我的主机就一个cpu所以我这里改为thread_concurrency2 另外还需要添加如下行指定mysql数据文件的存放位置 datadir /mydata/data 6、为mysql提供sysv服务脚本 # cd /usr/local/mysql # cp support-files/mysql.server /etc/rc.d/init.d/mysqld 7、添加至服务列表 # chkconfig --add mysqld # chkconfig mysqld on 要想使用man手册查看mysqld的用法和使用mysql命令还需要改配置文件如下 8、能使用man命令查看mysql的相关命令 # vim /etc/man.config 找到MANPATH这行在其下添加如下行即可 MANPATH /usr/local/mysql/man 9、输出mysql的头文件至系统头文件路径/usr/include 通过连接实现 # ln -sv /usr/local/mysql/include /usr/include/mysql 10、输出mysql的库文件给系统库查找路径 # vim /etc/ld.so.conf.d/mysql.conf 写上如下一行 /usr/local/mysql/lib 11、修改PATH环境变量让系统可以直接使用mysql和http相关的命令 # vim /etc/profile 找到export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE INPUTRC这一行在他的上面添加一行如下 PATH$PATH:/usr/local/mysql/bin:/usr/local/apache/bin 12、而后让系统重新载入系统库 # ldconfig 13、启动测试 # service mysqld start 三、编译安装php-5.3.10 1、先下载源码包至本地 若想让php支持mcrypt扩展还要下载下面这两个rpm包 libmcrypt-2.5.7-5.el5.i386.rpm libmcrypt-devel-2.5.7-5.el5.i386.rpm 2、编译安装php-5.3.10 # tar xf php-5.3.10.tar.bz2 # cd php-5.3.10 # ./configure --prefix/usr/local/php --with-mysql/usr/local/mysql \ --with-openssl --with-mysqli/usr/local/mysql/bin/mysql_config \ --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir \ --with-zlib --with-libxml-dir/usr --enable-xml \ --with-apxs2/usr/local/apache/bin/apxs --with-mcrypt 其中./configure 后的 --prefix/usr/local/php --with-apxs2/usr/local/apache/bin/apxs --with-mysql/usr/local/mysql/ --with-libxml-dir --enable-mbstring 是必要选项 --with-mcrypt是支持mcrypt的扩展 # make # make test # make intall 3、为php提供配置文件 # cp php.ini-production /usr/local/php/lib/php.ini 4、编辑apache配置文件httpd.conf以apache支持php # vim /etc/httpd/httpd.conf 找到类似下面的行在其上添加 AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps 找到DirectoryIndex index.html 改为如下 DirectoryIndex index.php index.html 5、# service httpd restart 转载于:https://blog.51cto.com/4374568/812593