下载免编译的软件包
cd /usr/local/src
wget http://mirrors.sohu.com/mysql/MySQL-5.1/mysql-5.1.73-linux-x86_64-glibc23.tar.gz
解压
tar xvf mysql-5.1.73-linux-x86_64-glibc23.tar.gz
挪动到指定目录
mv mysql-5.1.73-linux-x86_64-glibc23 /usr/local/mysql
建立mysql用户
useradd -s /sbin/nologin mysql
创建datadir,数据文件会放在里面
mkdir -p /data/mysql
更改权限
chown -R mysql:mysql /data/mysql/
定义安装db脚本
./scripts/mysql_install_db --user=mysql --datadir=/data/mysql/
拷贝主配置文件
cp support-files/my-large.cnf /etc/my.cnf
拷贝启动脚本文件
cp support-files/mysql.server /etc/init.d/mysqld
更改权限
chmod 755 /etc/init.d/mysqld
编辑启动脚本文件
vim /etc/init.d/mysqld
datadir=/data/mysql
设定开机启动
chkconfig --add mysqld
chkconfig mysqld on
service mysqld start
确认是否启动
ps aux | grep mysqld
下载apache包
cd /usr/local/src
wget http://www.lishiming.net/data/attachment/forum/httpd-2.2.24.tar.bz2
tar jvxf httpd-2.2.24.tar.bz2
cd httpd-2.2.24
安装依赖包
yum install -y pcre pcre-devel apr apr-devel zlib-devel gcc
配置
./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre
编译
make
安装
make install
检查上条命令是否正常执行
echo $?
/usr/local/apache2/bin/apachectl –M
mpm开头的是apache的工作模式。shared表示动态共享,static表示静态共享。
下载Php包
cd /usr/local/src/
wget http://cn2.php.net/distributions/php-5.4.44.tar.gz
tar xvf php-5.4.44.tar.gz
安装依赖包
yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel epel-release libmcrypt-devel
yum -y install libjpeg-devel
yum install -y epel-release
yum install -y libmcrypt-devel
配置
cd php-5.4.44
./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
echo $?
编译
make
编译文件测试
make test
安装
make install
拷贝php配置文件
cp php.ini-production /usr/local/php/etc/php.ini
修改apache配置文件
vim /usr/local/apache2/conf/httpd.conf
定义Server名字
ServerName localhost:80
如果不修改访问会显示403
Options FollowSymLinks
AllowOverride None
Order deny,allow
Allow from all
加上对应类型支持Php脚本解析
AddType application/x-compress .Z
AddType application/x-gzip .gz .tgz
AddType application/x-httpd-php .php
增加针对php的索引
DirectoryIndex index.html index.htm index.php
确认php配置文件是否正常
/usr/local/apache2/bin/apachectl -t
启动服务
/usr/local/apache2/bin/apachectl start
查看进程
ps aux | grep httpd
写入测试php网页
vim /usr/local/apache2/htdocs/1.php
本机测试
curl localhost/1.php
下载discuz!
mkdir /data/www
cd /data/www/
wget http://download.comsenz.com/DiscuzX/3.2/Discuz_X3.2_SC_GBK.zip
unzip Discuz_X3.2_SC_GBK.zip
mv upload/* .
配置一地个虚拟主机
vim /usr/local/apache2/conf/httpd.conf
# Virtual hosts
去掉前面的#号
Include conf/extra/httpd-vhosts.conf
注释掉前面其它的VirtualHost,加入如下配置
vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
DocumentRoot "/data/www"
ServerName www.123.com
检查apache配置文件是否正确
/usr/local/apache2/bin/apachectl -t
重启apache服务
/usr/local/apache2/bin/apachectl restart
配置mysql,为Discuz!增加一个账户
/usr/local/mysql/bin/mysql -u root
创建一个库
mysql> create database discuz;
Query OK, 1 row affected (0.01 sec)
赋予权限给新用户
mysql> grant all on discuz.* to 'gyt'@'localhost' identified by 'root1234';
Query OK, 0 rows affected (0.07 sec)
默认运行apache的账号
vim /usr/local/apache2/conf/httpd.conf
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon
编辑windows测试客户端host文件,增加如下参数:
C:\Windows\System32\drivers\etc
点击,我同意
需要更改权限。
修改目录权限
chown -R daemon:daemon data/ uc_server/data uc_client/data config
选择全新安装,点击下一步。
输入数据库用户账号/密码。设置admin账号密码。
记好Discuz!论坛管理员账号/密码。
刚装好的Discuz!论坛,有一个管理后台admin,本身有密码,但是为了更加安全,再设置一层用户认证。
限制了某些文件必须输入账号/密码才能访问。
Direcotry指定对哪个目录进行验证,AuthName自定义,AuthUserFile指定用户密码文件在哪里。
vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
DocumentRoot "/data/www"
ServerName www.123.com
AllowOverride AuthConfig
AuthName "alksdjflkasjdf"
AuthType Basic
AuthUserFile /data/.htpasswd
require valid-user
创建进行验证的用户
/usr/local/apache2/bin/htpasswd -cm /data/.htpasswd admin
检查apache配置是否正确
/usr/local/apache2/bin/apachectl -t
重启,graceful相当于reload
/usr/local/apache2/bin/apachectl graceful
查看加密的密码
cat /data/.htpasswd
[root@localhost www]# cat /data/.htpasswd
gyt:$apr1$/4qKQ0fY$3rCU7oE.wWlwCLv9MXYH3.
[root@localhost www]#
修改默认第一个虚机主机。
有个特点就是凡是解析到这台机器的域名,不管是什么域名,只要配置文件中没有配置,都会访问到这个主机上来。
所以应该禁止掉。
vim /usr/local/apache2/conf/extra/httpd-vhosts.conf
# ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/tmp/tmp"
ServerName www.55tmp.com
Order allow,deny
Deny from all
# ServerAlias www.dummy-host.example.com
# ErrorLog "logs/dummy-host.example.com-error_log"
# CustomLog "logs/dummy-host.example.com-access_log" common
mkdir /tmp/tmp
/usr/local/apache2/bin/apachectl graceful
下载memcache包
cd /usr/local/src/
wget http://www.lishiming.net/data/attachment/forum/memcache-2.2.3.tgz
tar zxvf memcache-2.2.3.tgz
cd memcache-2.2.3
安装依赖包
yum install -y m4 autoconf
用php生成configure文件
/usr/local/php/bin/phpize
配置
./configure --with-php-config=/usr/local/php/bin/php-config
编译
make
安装
make install
创建extension 目录
mkdir /usr/local/php/ext
拷贝memcache模块至ext目录。
cp modules/memcache.so /usr/local/php/ext/
编辑php配置文件,配置如下2行参数
vim /usr/local/php/etc/php.ini
extension_dir = "/usr/local/php/ext"
extension = memcache.so
查看extension_dir方法
/usr/local/php/bin/php -i | grep extension_dir
检测和查看具体的模块,如果有memcache说明配置成功
/usr/local/php/bin/php -m
本次LNMP环境需要的依赖包,Mysql部分参考LAMP 章节Mysql部分安装即可。
yum install -y libcurl-devel
yum install -y libtool-ltdl-devel
yum install -y libxml2-devel openssl openssl-devel bzip2 bzip2-devel libpng libpng-devel freetype freetype-devel epel-release libmcrypt-devel
yum -y install libjpeg-devel
yum install -y epel-release
yum install -y libmcrypt-devel
yum install gcc
yum install libcurl
下载PHP源码包
cd /usr/local/src
wget http://au1.php.net/distributions/php-5.4.44.tar.bz2
解压源码包,创建账号,用于运行php-fpm服务,在LNMP环境张,php是以一个服务来提供服务的。
tar jxf php-5.4.44.tar.bz2
useradd -s /sbin/nologin php-fpm
cd php-5.4.44
配置编译选项
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm --with-fpm-user=php-fpm --with-fpm-group=php-fpm --with-mysql=/usr/local/mysql --with-mysql-sock=/tmp/mysql.sock --with-libxml-dir --with-gd -with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-ftp --enable-mbstring --enable-exif --enable-zend-multibbyte --disable-ipv6 --with-pear --with-curl --with-openssl
编译php
make
安装php
make install
拷贝配置文件
cp php.ini-production /usr/local/php/etc/php.ini
备份php-fpm默认文件
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf.default.bak
更改为conf文件
mv /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
修改配置文件
vim /usr/local/php/etc/php-fpm.conf
[global]
; Pid file
; Note: the default prefix is /usr/local/php/var
; Default Value: none
pid = /usr/local/php/var/run/php-fpm.pid
; Error log file
; If it's set to "syslog", log is sent to syslogd instead of being written
; in a local file.
; Note: the default prefix is /usr/local/php/var
; Default Value: log/php-fpm.log
error_log = /usr/local/php/var/log/php-fpm.log
[www]
user = php-fpm
group = php-fpm
listen = /tmp/php-fcgi.sock
pm = dynamic
pm.max_children = 50
pm.start_servers = 20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
rlimit_files = 1024
检查配置是否正确
/usr/local/php/sbin/php-fpm –t
拷贝一个启动脚本到/etc/init.d下
cp /usr/local/src/php-5.4.44/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
更改脚本权限
chmod 755 /etc/init.d/php-fpm
service php-fpm start
开机启动
chkconfig php-fpm on
检测是否启动
ps aux | grep php-fpm
更改权限
chmod 777 /tmp/php-fcgi.sock
更改属主属组
chown php-fpm:php-fpm /tmp/php-fcgi.sock
下载、解压Nginx
cd /usr/local/src/
wget http://nginx.org/download/nginx-1.8.0.tar.gz
tar zxvf nginx-1.8.0.tar.gz
配置编译选项
cd nginx-1.8.0
yum -y install pcre-devel openssl openssl-devel
./configure --prefix=/usr/local/nginx --with-http_realip_module --with-http_sub_module --with-http_gzip_static_module --with-http_stub_status_module --with-pcre
编译
make
安装
make install
启动Nginx
/usr/local/nginx/sbin/nginx
通过进程确认
ps aux | grep nginx
配置Nginx配置文件,使其能够支持php
vim /usr/local/nginx/conf/nginx.conf
找到
location = /50x.html {
root html;
}
后面修改如下配置
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
root html;
fastcgi_pass unix:/tmp/php-fcgi.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/local/nginx/html$fastcgi_script_name;
include fastcgi_params;
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
重新加载
/usr/local/nginx/sbin/nginx -s reload
创建测试文件
vim /usr/local/nginx/html/2.php
测试
curl localhost/2.php
出现这个,代表环境Ok。
php works
查看jdk版本
java -version
确认java命令信息
whereis java
记录java home
vim /etc/java/java.conf
JVM_ROOT=/usr/lib/jvm
#JAVA_HOME=$JVM_ROOT/jre
下载tomcat
cd /usr/local/src
wget http://apache.fayea.com/tomcat/tomcat-7/v7.0.70/bin/apache-tomcat-7.0.70.tar.gz
解压
tar zxvf apache-tomcat-7.0.70.tar.gz
移动程序目录
mv apache-tomcat-7.0.70 /usr/local/tomcat
配置启动脚本
cp -pv /usr/local/tomcat/bin/catalina.sh /etc/init.d/tomcat
编辑脚本
vim /etc/init.d/tomcat
增加2个参数
JAVA_HOME=/usr/lib/jvm/jre
CATALINA_HOME=/usr/local/tomcat
启动
/etc/init.d/tomcat start
访问测试
编辑配置文件
vim /usr/local/tomcat/conf/server.xml
修改connector port 默认端口8080为80
<Connector port="80" protocol="HTTP/1.1"
在host后面
添加一个host
<Host name="www.111.com" appBase="/data/tomcatweb"
unpackWARs="false" autoDeploy="true"
xmlValidation="false" xmlNamespaceAware="false">
访问测试
添加一个测试网页
[root@localhost ~]# cat /data/tomcatweb/111.jsp
Now time is:<%=new java.util.Date()%>
[root@localhost ~]#
访问测试
yum -y install glibc-devel.i686
yum install /lib/ld-linux.so.2
yum install openssl-devel
从oracle官网下载
http://www.oracle.com/technetwork/java/javase/downloads/
解压
tar xvf jdk-8u101-linux-i586.tar.gz
移动程序文件
mv jdk1.8.0_101/ /usr/local/jdk1.8.0_101
编辑变量
vim /etc/profile.d/java.sh
JAVA_HOME=/usr/local/jdk1.8.0_101
JAVA_BIN=/usr/local/jdk1.8.0_101/bin
JRE_HOME=/usr/local/jdk1.8.0_101/jre
PATH=$PATH:/usr/local/jdk1.8.0_101/bin:/usr/local/jdk1.8.0_101/jre/bin
CLASSPATH=/usr/local/jdk1.8.0_101/jre/lib:/usr/local/jdk1.8.0_101/lib:/usr/local/jdk1.8.0_101/jre/lib/charsets.jar
在系统中生效
source /etc/profile.d/java.sh
查看Java版本
java -version
下载
wget www.aminglinux.com/bbs/data/attachment/forum/resin-4.0.36.tar.gz
解压
tar jxvf resin-4.0.36.tar.gz
cd resin-4.0.36
配置编译选项
./configure --prefix=/usr/local/resin --with-java-home=/usr/local/jdk1.8.0_101/
编译
make
安装
make install
确认是否执行成功
echo $?
/etc/init.d/resin start
vim /data/123/111.jsp
Now time is:<%=new java.util.Date()%>
测试ok
curl -x 127.0.0.1:8080 www.123.com/111.jsp
Now time is:Wed Jul 20 11:24:32 EDT 2016
yum install gcc
yum install pcre-devel
yum install zlib-devel
yum install bzip2
yum install bzip2-devel
cd /usr/local/src/
wget http://download.lighttpd.net/lighttpd/releases-1.4.x/lighttpd-1.4.41.tar.gz
tar xvf lighttpd-1.4.41.tar.gz
cd lighttpd-1.4.41
./configure --prefix=/usr/local/lighttpd
make && make install
echo $?
mkdir -p /etc/lighttpd/conf.d
cd /etc/lighttpd/conf.d
touch access_log.conf
touch debug.conf
touch dirlisting.conf
touch mime.conf
mkdir -p /srv/www/htdocs
mkdir -p /var/log/lighttpd/
mkdir /srv/www/vhosts
cd /var/log/lighttpd/
touch error.log
cp doc/config/lighttpd.conf /usr/local/lighttpd/
cp doc/config/lighttpd.conf /etc/lighttpd/.
chown -R lighttpd.lighttpd /var/log/lighttpd
chown -R lighttpd.lighttpd /etc/lighttpd
/usr/local/lighttpd/sbin/lighttpd -f /etc/lighttpd/lighttpd.conf
lsof -i:80
[root@localhost htdocs]# vim /srv/www/htdocs/index.html
fsfsfs
/usr/local/lighttpd/sbin/lighttpd -tt -f /etc/lighttpd/lighttpd.conf
curl -i http://192.168.211.128
手机扫一扫
移动阅读更方便
你可能感兴趣的文章