CentOS下安裝配置 Ngnix_tomcat_PHP_Mysql,centosmysql配置
安裝Nginx
yum install nginx
如果顯示找不到 nginx包,建立一個檔案/etc/yum.repos.d/nginx.repo,內容:
[nginx]name=nginx repobaseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/gpgcheck=0enabled=1
其中:OS替換成centos或者rhel,根據你安裝的發行版版本 OSRELEASE替換成5,6或者7,分別對應著5.想,6.x,7.x如:
[nginx]name=nginx repobaseurl=http://nginx.org/packages/centos/6/$basearch/gpgcheck=0enabled=1~
刪除之前的httpd
yum remove httpd
安裝
yum install ngnix
判斷conf
/usr/sbin/nginx -t
啟動:service nginx restart
加入自啟動chkconfig --levels 235 nginx on
安裝PHP
yum install php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-mssql php-snmp php-soap php-tidy
vi /etc/php.ini
在檔案末尾添加cgi.fix_pathinfo = 1
啟動php-fpm:
service php-fpm start
php-fpm加入啟動項:
chkconfig --levels 235 php-fpm on
安裝Tomcat下載解壓到/usr/local/tomcat連接埠改為8090啟動即可
安裝mysql:yum install mysql mysql-server
修改密碼:
grant all on *.* to 'root'@'localhost' IDENTIFIED BY '你的密碼'with grant option ;flush privileges
配置Nginx:進入/etc/nginx建立一個檔案:proxy.conf:
proxy_redirect off;proxy_set_header Host $host;proxy_set_header X-Real-IP $remote_addr;#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;client_max_body_size 10m;client_body_buffer_size 128k;proxy_connect_timeout 90;proxy_send_timeout 90;proxy_read_timeout 90;proxy_buffer_size 4k;proxy_buffers 4 32k;proxy_busy_buffers_size 64k;proxy_temp_file_write_size 64k;
進入:/etc/nginx/conf.d建立tomcat.conf
server { listen 8080; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { #root /usr/share/nginx/html; index index.html index.htm;proxy_pass http://127.0.0.1:8090/; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/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 127.0.0.1:9000; # fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME /scripts$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; #}}
nginx配置完成
配置default.conf(也可以建立一個):
server { listen 80; server_name localhost; #charset koi8-r; #access_log /var/log/nginx/log/host.access.log main; location / { #root /usr/share/nginx/html; root /var/www/html; index index.html index.htm; } #error_page 404 /404.html; # redirect server error pages to the static page /50x.html # error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/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 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$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/sbin/nginx -t -c /etc/nginx/nginx.conf
註:
chkconfig 使用範例:
chkconfig --list #列出所有的系統服務
chkconfig --add httpd #增加httpd服務
chkconfig --del httpd #刪除httpd服務
chkconfig --level httpd 2345 on #設定httpd在運行層級為2、3、4、5的情況下都是on(開啟)的狀態
chkconfig --list #列出系統所有的服務啟動情況
chkconfig --list mysqld #列出mysqld服務設定情況
chkconfig --level 35 mysqld on #設定mysqld在等級3和5為開機運行服務,--level 35表示操作只在等級3和5執行,on表示啟動,off表示關閉
chkconfig mysqld on #設定mysqld在各等級為on,“各等級”包括2、3、4、5等級
如何增加一個服務:
1.服務指令碼必須存放在/etc/ini.d/目錄下;
2.chkconfig --add servicename
在chkconfig工具服務列表中增加此服務,此時服務會被在/etc/rc.d/rcN.d中賦予K/S入口了;
3.chkconfig --level 35 mysqld on
修改服務的預設啟動等級。
centos配置 nginx +mysql +PHP 有沒有簡單方法
yum安裝最簡單
www.centos.bz/...-lnmp/
CentOS 62下怎安裝以及配置DHCP伺服器
系統內建,如果沒有安裝,用yum安裝即可。
yum install dhcp
安全完後,建立設定檔
cp /usr/share/doc/dhcp*/dhcpd.conf.sample /etc/dhcpd.conf
其中 option routers 為你要配置的網關地址(通常為dhcp即原生ip); option subnet-mask 子網路遮罩 ;
其他項預設即可。儲存設定檔後就可以啟動服務了。
/etc/init.d/dhcpd start