源码lnmp
1、準備工作:
配置yum源
安裝開發工具、編譯工具gcc gcc-c++ make
配置固定ip地址 關閉iptables selinux
netstat -anpult | grep :3306
netstat -anpult | grep :80
若端口占用kill
并service httpd stop ; chkconfig httpd off
service mysqld stop ; chkconfig mysqld off?
mv /etc/my.cnf /etc/my.cnf.bak
2、源碼安裝nginx-1.2.0:
下載nginx-1.2.0
useradd -s /sbin/nologin -M www
進入nginx-1.2.0目錄
./configure?--prefix=/usr/local/nginx?--pid-path=/usr/local/nginx/nginx.pid?--user=www ? --group=www?--with-http_ssl_module ? --with-http_flv_module?--with-http_stub_status_module?--with-http_gzip_static_module
無錯誤后make && meke install
啟動服務/usr/local/nginx/sbin/nginx
訪問測試elinks --dump http://localhost
看到 Welcome to nginx 表示nginx安裝完成。
3、安裝源碼mysql:
useradd -s /sbin/nologin -M mysql
下載cmake-2.8.10.2.tar.gz
tar -zxf?cmake-2.8.10.2.tar.gz
cd?cmake-2.8.10.2
./bootstrap --prefix=/usr/local/cmake
make && makeinstall
下載mysql-5.5.13.tar.gz
tar -zxf?mysql-5.5.13.tar.gz
cd?mysql-5.5.13
/usr/local/cmake/bin/cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql ? ?-DSYSCONFDIR=/etc ? -DMYSQL_DATADIR=/usr/local/mysql/data ?-DMYSQL_TCP_PORT=3306 ? -DMYSQL_UNIX_ADDR=/tmp/mysqld.sock ? -DMYSQL_USER=mysql ? -DEXTRA_CHARSETS=all ? -DWITH_READLINE=1 ? -DWITH_SSL=system ? -DWITH_EMBEDDED_SERVER=1 ? -DENABLED_LOCAL_INFILE=1 ? -DWITH_INNOBASE_STORAGE_ENGINE=1
無錯誤后make && make install
初始化授權庫
cd /usr/local/mysql
./scripts/mysql --user=mysql
生成主配置文件
cp /mysql-5.5.13/support-files/my-medium.cnf /etc/my.cnf
#在[mysqld]下設置:datadir = /usr/local/mysql/data
echo "export PATH=/usr/local/mysql/bin/:$PATH" >> /etc/profile ? ?
mysqladmin -uroot password '123'
jobs
[1]+ ?Running ? ? ?/usr/local/mysql/bin/mysqld_safe --user=mysql &
kill -9 %1
cp /mysql-5.5.13/support-files/mysql.server /etc/init.d/mysqldd
chmod +x /etc/init.d/mysqldd
chkconfig --add mysqldd
chown -R mysql:mysql /usr/local/mysql/
4、安裝PHP:
下載php-5.4.9.tar.gz ?libmcrypt-2.5.8.tar.gz ?mhash-0.9.9.9.tar.gz ?libiconv-1.13.tar.gz
tar -zxf?php-5.4.9.tar.gz
tar -zxf?mhash-0.9.9.9.tar.gz
tar -zxf?libmcrypt-2.5.8.tar.gz
tar -zxf?libiconv-1.13.tar.gz
./mhash-0.9.9.9/configure && make && make insetall
./libmcrypt-2.5.8/configure && make && make install
cd libmcrypt-2.5.8/libltdl
./configure ?--with-gmetad ?--enable-gexec ?--enable-ltdl-install
make && make install
./libiconv-1.13configure && make && make install
ldconfig -v
yum -y install libxml2-devel
yum -y install libcurl
yum -y install libcurl-devel
yum -y install libjpeg-devel
yum -y install libpng-devel
yum -y install freetype-devel
yum -y install openldap-devel
yum -y install php-ldap
cp -frp /usr/lib64/libldap* /usr/lib/
cd php-5.4.9
ln -sv /usr/local/lib/libmcrypt* ? ? /usr/lib/
ln -sv /usr/local/lib/libmhash* ? ?/usr/lib/
ln -sv /usr/local/lib/libiconv* ? ?/usr/lib/
cat /etc/ld.so.conf
include ld.so.conf.d/*.conf
/usr/local/mysql/lib/
/usr/local/mysql/include/
/usr/local/lib
:wq
cp php-5.4.9/ext/phar/phar.php php-5.4.9/ext/phar/phar.phar
ldconfig ?-v
./configure --prefix=/usr/local/php5nginx --with-config-file-path=/usr/local/php5nginx/etc ?--with-mysql=/usr/local/mysql ?--with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir ? --with-jpeg-dir --with-png-dir ? ? --with-zlib ? ?--with-libxml-dir=/usr ?--enable-xml ? ?--disable-rpath ? --enable-bcmath --enable-shmop ?--enable-sysvsem --enable-inline-optimization ?--with-curl ? --with-curlwrappers --enable-mbregex ? --enable-fpm ?--enable-mbstring ? ?--with-mcrypt ? --with-gd ? --enable-gd-native-ttf --with-openssl ? --with-mhash ? --enable-pcntl --enable-sockets ? --with-ldap ? --with-ldap-sasl --with-xmlrpc ? ?--enable-zip ? --enable-soap
make ?ZEND_EXTRA_LIBS='-liconv'
make install
cp?php-5.4.9/php.ini-production /usr/local/php5nginx/etc/php.ini
nginx + fast-cgi 使nginx能夠解析php頁面
cp /usr/local/php6nginx/php-fpm.conf.default /usr/local/php6nginx/php-fpm.conf
cd?/usr/local/php6nginx/
grep -v "^;" php-fpm.conf | grep -v "^$"
cp php-5.4.9/sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
chmod +x /etc/rc.d/init.d/php-fpm
chkconfig --add php-fpm
vim /usr/local/nginx/conf/nginx.conf
65-71行取消注釋
echo "fastcgi_param ?SCRIPT_FILENAME ? ?$document_root$fastcgi_script_name;" >> /usr/local/nginx/conf/fastcgi_params
/usr/local/nginx/sbin/nginx -t
/usr/local/nginx/sbin/nginx -s stop
/usr/local/nginx/sbin/nginx
<?php
? ? #echo "hello world!!!";
phpinfo();
?>" > /usr/local/nginx/html/test.php
測試nginx能否解析php頁面。
授權php對數據庫的權限
/usr/local/mysql/bin/mysql -uroot -p123
mysql>grant all on bbsdb.* to webuser@"localhost" identified by "123";
mysql>create database bbsdb;
mysql>quit
echo “
<?php
$linkdb=mysql_connect("localhost","webuser","123");
if($linkdb){
? ? echo "linkdb ok";
}else{
? ? echo "linkdb not ok";
}
?>” ?> /usr/local/nginx/html/linkdb.php
訪問http://localhost/linkdb.php
顯示linkdb ok 完成。
轉載于:https://blog.51cto.com/105496232/1794749
總結
- 上一篇: I/O多路转接之poll——基于TCP协
- 下一篇: FirewallD is not run